function __construct($response) { if ($response->code !== 200) { throw APIRequestException::fromResponse($response); } $payload = json_decode($response->raw_body, true); $this->process($payload); $this->json = $response->raw_body; $this->response = $response; $this->isOk = true; }
function __construct($response) { if ($response->code !== 200) { throw APIRequestException::fromResponse($response); } if ($response->raw_body) { $this->body = json_decode($response->raw_body, true); } else { $this->body = null; } $this->json = $response->raw_body; $this->response = $response; $this->isOk = true; }
function __construct($response) { if ($response->code !== 200) { throw APIRequestException::fromResponse($response); } $payload = json_decode($response->raw_body, true); $received_list = array(); foreach ($payload as $received) { array_push($received_list, new Report($received)); } $this->received_list = $received_list; $this->json = $response->raw_body; $this->response = $response; $this->isOk = true; }
function __construct($response) { if ($response->code !== 200) { throw APIRequestException::fromResponse($response); } $payload = json_decode($response->raw_body, true); foreach ($this->expected_keys as $key) { if (array_key_exists($key, $payload)) { $this->{$key} = $payload[$key]; } } $this->json = $response->raw_body; $this->response = $response; $this->isOk = true; }