public function normalizeForHasher(Call $call, HeadersInterface $headers) { $normalizedData = array(); $normalizedData[] = $call->getMethod(); $normalizedData[] = $call->getRequestUri(); $normalizedData[] = $headers['Date']->getHeader(); $normalizedData[] = $headers['Accept']->getHeader(); $normalizedData[] = $headers['Accept-Language']->getHeader(); $normalizedData[] = $call->getNonce(); $normalizedData[] = $call->getFormattedBody(); $serializedData = implode("", $normalizedData); return $serializedData; }
protected function parse() { // var_dump($this->request); // var_dump($this->response); if ($this->response->isServerError()) { throw new Exception(sprintf("API server error - statuscode [%s] with message [%s] / [%s]", $this->response->getStatusCode(), $this->response->getReasonPhrase(), $this->response->getContent())); } if ($this->response->isForbidden()) { throw new Exception(sprintf("API call forbidden - statuscode [%s] with message [%s]", $this->response->getStatusCode(), $this->response->getReasonPhrase())); } $deSerializedBody = ""; if ($this->response->getContent()) { $deSerializedBody = $this->serializer->decode($this->response->getContent(), $this->call->getFormat()); } if (null === $deSerializedBody) { echo $this->response->getContent(); throw new \Exception("API response could not deserialize"); } $this->apiResponse = new ApiResponse($this->response->getStatusCode(), $this->response->getReasonPhrase(), $this->response->getHeadersArray(), $deSerializedBody); if (isset($deSerializedBody['status']) && $deSerializedBody['status'] != 'success') { throw new Exception(sprintf("API call error - statuscode [%s] with message [%s] / [%s]", $deSerializedBody['code'], $deSerializedBody['text'], $this->response->getContent())); } }
public function delete() { $this->call->setMethod('DELETE'); return $this->dispatch(); }