From e54f554a286e81a13cba10f0943dad61f9c68c97 Mon Sep 17 00:00:00 2001 From: fgibaux Date: Thu, 3 Nov 2022 11:32:45 +0000 Subject: [PATCH] fix: client to use JSON body in request recommended by Pipedrive, and handles null values --- src/Http/PipedriveClient.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Http/PipedriveClient.php b/src/Http/PipedriveClient.php index 409a357..ae00bff 100644 --- a/src/Http/PipedriveClient.php +++ b/src/Http/PipedriveClient.php @@ -23,6 +23,8 @@ class PipedriveClient implements Client */ protected $isOauth = false; + const DEFAULT_BODY_FORMAT = RequestOptions::JSON; + /** * GuzzleClient constructor. * @@ -100,7 +102,7 @@ public function get($url, $parameters = []) public function post($url, $parameters = []) { $request = new GuzzleRequest('POST', $url); - $form = 'form_params'; + $form = self::DEFAULT_BODY_FORMAT; // If any file key is found, we will assume we have to convert the data // into the multipart array structure. Otherwise, we will perform the @@ -155,7 +157,7 @@ public function put($url, $parameters = []) { $request = new GuzzleRequest('PUT', $url); - return $this->execute($request, ['form_params' => $parameters]); + return $this->execute($request, [self::DEFAULT_BODY_FORMAT => $parameters]); } /** @@ -168,7 +170,7 @@ public function put($url, $parameters = []) public function patch($url, $parameters = []) { $request = new GuzzleRequest('PATCH', $url); - $form = 'form_params'; + $form = self::DEFAULT_BODY_FORMAT; // If any file key is found, we will assume we have to convert the data // into the multipart array structure. Otherwise, we will perform the @@ -197,7 +199,7 @@ public function delete($url, $parameters = []) { $request = new GuzzleRequest('DELETE', $url); - return $this->execute($request, ['form_params' => $parameters]); + return $this->execute($request, [self::DEFAULT_BODY_FORMAT => $parameters]); } /**