public function validateResponse($response)
    {
        if ($response->code !== '200 OK') {
            throw new BulkSmsException('BulkSMS API responded with HTTP status code ' . $response->code);
        }

        $parts = explode('|', $response->body);

        if (!is_numeric($parts[ 0 ])) {
            throw new \UnexpectedValueException(
                'Unknown response code: ' . $parts[ 0 ] . ' - full response: ' . $response->body
            );
        }

        $code = (int) $parts[ 0 ];

        if ($code === 0 || $code === 1) {
            return true;
        }

        $message = array_key_exists($code, static::$statusMessages)
            ? static::$statusMessages[ $code ]
            : $parts[ 1 ];
        throw new BulkSmsException('BulkSMS API responded with code: ' . $code . ' - ' . $message);
    }
public function validateResponse($response)
    {
        if ($response->code !== '200 OK') {
            throw new BulkSmsException('BulkSMS API responded with HTTP status code ' . $response->code);
        }

        $parts = explode('|', $response->body);

        if (!is_numeric($parts[ 0 ])) {
            throw new \UnexpectedValueException(
                'Unknown response code: ' . $parts[ 0 ] . ' - full response: ' . $response->body
            );
        }

        $code = (int) $parts[ 0 ];

        if ($code === 0 || $code === 1) {
            return true;
        }

        $message = array_key_exists($code, static::$statusMessages)
            ? static::$statusMessages[ $code ]
            : $parts[ 1 ];
        throw new BulkSmsException('BulkSMS API responded with code: ' . $code . ' - ' . $message);
    }
public function validateResponse ( $ response ) { if ( $ response -> code !== '200 OK' ) { throw new BulkSmsException ( 'BulkSMS API responded with HTTP status code ' . $ response -> code ) ; } $ parts = explode ( '|' , $ response -> body ) ; if ( ! is_numeric ( $ parts [ 0 ] ) ) { throw new \ UnexpectedValueException ( 'Unknown response code: ' . $ parts [ 0 ] . ' - full response: ' . $ response -> body ) ; } $ code = ( int ) $ parts [ 0 ] ; if ( $ code === 0 || $ code === 1 ) { return true ; } $ message = array_key_exists ( $ code , static :: $ statusMessages ) ? static :: $ statusMessages [ $ code ] : $ parts [ 1 ] ; throw new BulkSmsException ( 'BulkSMS API responded with code: ' . $ code . ' - ' . $ message ) ; }
Validate a response from the API to check for errors

@param  anlutro\cURL\Response $response

@return bool
@throws BulkSmsException
Validate a response from the API to check for errors