From 1242748b52d35a546e55e52cc395f92f154bc9de Mon Sep 17 00:00:00 2001 From: Mateusz Grochala Date: Wed, 6 Sep 2017 13:19:16 +0200 Subject: [PATCH] Guzzle 6 support --- src/Rossedman/Teamwork/Client.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Rossedman/Teamwork/Client.php b/src/Rossedman/Teamwork/Client.php index 82aeedc..32c9ca6 100644 --- a/src/Rossedman/Teamwork/Client.php +++ b/src/Rossedman/Teamwork/Client.php @@ -134,8 +134,14 @@ public function buildRequest($endpoint, $action, $params = [], $query = null) $params = json_encode($params); } - $this->request = $this->client->createRequest($action, - $this->buildUrl($endpoint), ['auth' => [$this->key, 'X'], 'body' => $params] + $options = ['auth' => [$this->key, 'X']]; + + if ($action == 'POST') { + $options = array_merge(['body' => $params], $options); + } + + $this->request = $this->client->request($action, + $this->buildUrl($endpoint), $options ); if ($query != null) @@ -154,9 +160,9 @@ public function buildRequest($endpoint, $action, $params = [], $query = null) */ public function response() { - $this->response = $this->client->send($this->request); - - return $this->response->json(); + $this->response = $this->request->getBody(); + + return $this->response->getContents(); } /** @@ -213,4 +219,4 @@ public function getRequest() { return $this->request; } -} \ No newline at end of file +}