solvecrew / ExpoNotificationsBundle

Symfony bundle to handle the BE parts of the push notifications from the expo react-native framework.
MIT License
20 stars 17 forks source link

change this "handleHttpResponse" from privet to public #27

Open 88hichem88 opened 4 years ago

88hichem88 commented 4 years ago
/**
 * Creates a detailed response array for the given notifications.
 *
 * param array $httpResponse
 * param array $notificationContentModels
 *
 * @return array
 */
public function handleHttpResponse(
    array $httpResponse,
    array $notificationContentModels
): array
{
    foreach ($httpResponse as $key => $httpResponseDetails) {
        // Being pessimistic here.
        $wasSuccessful = false;

        if ($httpResponseDetails['status'] != 'error') {
            $wasSuccessful = true;
        } else {
            // Set the response message if there is one.
            if ($httpResponseDetails['message']
                && strlen($httpResponseDetails['message']) > 0
            ) {
                $notificationContentModels[$key]->setResponseMessage($httpResponseDetails['message']);
            }

            // Set the response detail if there is one.
            if ($httpResponseDetails['details']
                && count($httpResponseDetails['details']) > 0
            ) {
                $notificationContentModels[$key]->setResponseDetails($httpResponseDetails['details']);
            }
        }

        $notificationContentModels[$key]->setWasSuccessful($wasSuccessful);
    }

    return $notificationContentModels;
}