raw_json = $json_response; $this->log = AmazonDebug::getLog(AmazonDebug::getId()); $this->parseJsonResponse($json_response); } /** * @return array */ public function getLog(): array { return $this->log; } /** * @return string */ public function getId(): string { return $this->id; } /** * @return string */ public function getCreationRequestId(): string { return $this->creation_request_id; } /** * @return string */ public function getStatus(): string { return $this->status; } /** * @return string */ public function getRawJson(): string { return json_encode($this->raw_json); } /** * @param array $json_response * @return CancelResponse */ public function parseJsonResponse(array $json_response): self { if (!is_array($json_response)) { throw AmazonErrors::getError( 'FAILURE', 'E001', 'NonScalarValue', 'Response must be a scalar value', 0 ); } if (array_key_exists('gcId', $json_response)) { $this->id = $json_response['gcId']; } if (array_key_exists('creationRequestId', $json_response)) { $this->creation_request_id = $json_response['creationRequestId']; } // SUCCESS, FAILURE, RESEND if (array_key_exists('status', $json_response)) { $this->status = $json_response['status']; } return $this; } } // __END__