Skip to content

Commit

Permalink
feat: Return PSR7 response object from executeRaw
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaumgartl committed Apr 2, 2024
1 parent dbadcc6 commit 2e5f8c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ $response = $client->execute([
]);
```

## Raw responses

Return PSR-7 [response object](https://github.com/php-fig/http-message/blob/master/src/ResponseInterface.php) (e.g. to handle binary data).

```php
$client = new \Flora\Client('http://api.example.com/');
$response = $client->executeRaw([
'resource' => 'article',
'id' => 1337,
'action' => 'pdf',
]);
```

## Asynchronous requests (using `guzzlehttp/promises`)

```php
Expand Down
6 changes: 6 additions & 0 deletions src/Flora/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public function executeParallel(array $params): array
return Utils::unwrap($promises);
}

public function executeRaw(array $params): ResponseInterface
{
$request = $this->requestFactory->create($params);
return $this->httpClient->sendRequest($request);
}

/**
* @param ResponseInterface $response
* @return stdClass
Expand Down

0 comments on commit 2e5f8c2

Please sign in to comment.