You are here

private function Client::handleSuccess in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/maxmind/web-service-common/src/WebService/Client.php \MaxMind\WebService\Client::handleSuccess()

Parameters

string $body The successful request body:

string $service The service name:

Return value

array The decoded request body

Throws

WebServiceException if the request body cannot be decoded as JSON

1 call to Client::handleSuccess()
Client::handleResponse in includes/vendor/maxmind/web-service-common/src/WebService/Client.php

File

includes/vendor/maxmind/web-service-common/src/WebService/Client.php, line 393

Class

Client
This class is not intended to be used directly by an end-user of a MaxMind web service. Please use the appropriate client API for the service that you are using. @package MaxMind\WebService @internal

Namespace

MaxMind\WebService

Code

private function handleSuccess($body, $service) {
  if (strlen($body) == 0) {
    throw new WebServiceException("Received a 200 response for {$service} but did not " . "receive a HTTP body.");
  }
  $decodedContent = json_decode($body, true);
  if ($decodedContent === null) {
    throw new WebServiceException("Received a 200 response for {$service} but could " . 'not decode the response as JSON: ' . $this
      ->jsonErrorDescription() . ' Body: ' . $body);
  }
  return $decodedContent;
}