From 37c6bec7c6ca78fcec71ad55666fbc5bd75dca4a Mon Sep 17 00:00:00 2001 From: Dmitriy Larionov Date: Tue, 16 Oct 2018 11:23:51 +0500 Subject: [PATCH] Update AbstractRequest.php --- src/Message/AbstractRequest.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index aa85c1d..ddfb6b2 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -156,14 +156,19 @@ public function sendData($data) { $url = $this->getEndPoint() . $this->getMethod(); $this->validate('userName', 'password'); + $data = array_merge( + [ + 'userName' => $this->getUserName(), + 'password' => $this->getPassword(), + ], + $data + ); + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $url, $this->getHeaders(), - json_encode(array_merge([ - 'userName' => $this->getUserName(), - 'password' => $this->getPassword() - ], $data)) + http_build_query($data, '', '&') ); $responseClassName = str_replace('Request', 'Response', \get_class($this)); @@ -174,7 +179,9 @@ public function sendData($data) ); } - return $reflection->newInstance($this, json_decode($httpResponse->getBody(true), true)); + $content = json_decode($httpResponse->getBody()->getContents(), true); + + return $reflection->newInstance($this, $content); } /**