rawResponse)) { $this->decodedResponse = json_decode($this->rawResponse, true); } } public function getHttpCode(): int { return $this->code; } public function getResponse(): array { return $this->decodedResponse; } public function getRawResponse(): string { return $this->rawResponse; } public function wasSuccessful(): bool { return $this->decodedResponse && !$this->decodedResponse['error']; } public function getErrorMessage(): string { return $this->decodedResponse['error']['message'] ?? 'None'; } public function getErrorCode(): int { return intval($this->decodedResponse['error']['code'] ?? 0); } public function getError(): string { return $this->getErrorMessage() . ' (Code ' . $this->getErrorCode() . ')'; } public function generatePHPUnitMessage(): string { return 'The API request failed with the following message: ' . $this->getError(); } public function getResult(): mixed { return $this->decodedResponse['result'] ?? ''; } }