Example #1
0
 /**
  * @param ResponseInterface|Response6Interface $response
  *
  * @return string
  *
  * @throws CommunicationException
  */
 public static function getRawResponseBody($response)
 {
     $statusCode = $response->getStatusCode();
     $rawResponse = $response->getBody()->getContents();
     if ($statusCode != 200) {
         throw CommunicationException::createFromHTTPResponse($statusCode, $rawResponse);
     }
     return $rawResponse;
 }
Example #2
0
 private static function checkForErrors($rawResponse)
 {
     if (is_numeric($rawResponse)) {
         switch ($rawResponse) {
             case static::VALIDATION_FAILED:
                 throw new CommunicationException('Input Validation Failed', CommunicationException::INVALID_INPUT);
             case static::AUTHENTICATION_FAILED:
                 throw CommunicationException::createFromHTTPResponse('401', '');
             case static::PANEL_AUTHORIZATION_FAILED:
                 throw new CommunicationException('Forbidden [Panel is disabled]', CommunicationException::FORBIDDEN);
             case static::WEB_SERVICE_AUTHORIZATION_FAILED:
                 throw CommunicationException::createFromHTTPResponse('403', '');
             case static::INVALID_FROM:
                 throw new CommunicationException('Invalid From', CommunicationException::INVALID_INPUT);
             case static::INVALID_TO:
                 throw new CommunicationException('Invalid To', CommunicationException::INVALID_INPUT);
             case static::INTERNAL_SERVER_ERROR:
                 throw new CommunicationException('Internal Server Error', CommunicationException::GENERAL_HTTP_ERROR);
         }
     }
 }