Skip to content

Commit

Permalink
fix: client to use JSON body in request
Browse files Browse the repository at this point in the history
recommended by Pipedrive, and handles null values
  • Loading branch information
fgibaux committed Jun 9, 2023
1 parent 8c50ff7 commit e54f554
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Http/PipedriveClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class PipedriveClient implements Client
*/
protected $isOauth = false;

const DEFAULT_BODY_FORMAT = RequestOptions::JSON;

/**
* GuzzleClient constructor.
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
}

/**
Expand All @@ -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
Expand Down Expand Up @@ -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]);
}

/**
Expand Down

0 comments on commit e54f554

Please sign in to comment.