Skip to content

Commit

Permalink
Handle HTTP PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-k authored Jul 12, 2022
1 parent a574db9 commit e5c320b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Http/PipedriveClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ public function put($url, $parameters = [])
return $this->execute($request, ['form_params' => $parameters]);
}

/**
* Perform a PATCH request.
*
* @param $url
* @param array $parameters
* @return Response
*/
public function patch($url, $parameters = [])
{
$request = new GuzzleRequest('PATCH', $url);
$form = 'form_params';

// 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
// request as usual using the form_params with the given parameters.
if (isset($parameters['file'])) {
$form = 'multipart';
$parameters = $this->multipart($parameters);
}

if (isset($parameters['json'])) {
$form = RequestOptions::JSON;
$parameters = array_except($parameters, RequestOptions::JSON);
}

return $this->execute($request, [$form => $parameters]);
}

/**
* Perform a DELETE request.
*
Expand Down

0 comments on commit e5c320b

Please sign in to comment.