Skip to content

Commit

Permalink
Added missing methods put() and patch() to testing HTTP client (#…
Browse files Browse the repository at this point in the history
…5453)
  • Loading branch information
lucasdotvin authored Feb 22, 2023
1 parent b4e9ed4 commit 36a2579
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public function put(string $uri, array $data = [], array $headers = [])

return $this->packer->unpack((string) $response->getBody());
}

public function patch(string $uri, array $data = [], array $headers = [])
{
$response = $this->request('PATCH', $uri, [
'headers' => $headers,
'form_params' => $data,
]);

return $this->packer->unpack((string) $response->getBody());
}

public function delete(string $uri, array $data = [], array $headers = [])
{
Expand Down
20 changes: 20 additions & 0 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ public function post(string|UriInterface $uri, array $data = [], array $headers

return $this->packer->unpack((string) $response->getBody());
}

public function put(string|UriInterface $uri, array $data = [], array $headers = [])
{
$response = $this->client->put($uri, [
'headers' => $headers,
'form_params' => $data,
]);

return $this->packer->unpack((string) $response->getBody());
}

public function patch(string|UriInterface $uri, array $data = [], array $headers = [])
{
$response = $this->client->patch($uri, [
'headers' => $headers,
'form_params' => $data,
]);

return $this->packer->unpack((string) $response->getBody());
}

public function json(string|UriInterface $uri, array $data = [], array $headers = [])
{
Expand Down

0 comments on commit 36a2579

Please sign in to comment.