Skip to content

Commit 2c886cd

Browse files
committed
fix searchContacts to support query params
use query request option in Guzzle client instead of appending to API URI added CHANGELOG
1 parent 7c82a1d commit 2c886cd

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CHANGELOG
2+
3+
## [0.3.x (Unreleased)](https://github.com/onlime/bexio-api-client/compare/0.3.1...main)
4+
5+
## [0.3.1 (2022-03-23)](https://github.com/onlime/bexio-api-client/releases/tag/0.3.0...0.3.1)
6+
7+
- Fix `Contact::searchContacts()` to support query params.
8+
- Use `query` request option in Guzzle client instead of appending query params to API URI directly to avoid conflicts with already existing query params in configured API URI.
9+
- Fix phpDoc comments for `$id` method params.
10+
- Add this CHANGELOG
11+
12+
## [0.3.0 (2022-03-18)](https://github.com/onlime/bexio-api-client/releases/tag/0.2.1...0.3.0)
13+
14+
- Implement Bexio API v3 support with OpenID Connect authentication
15+
- Detach fork from christianruhstaller/bexio-api-php-client, released as new package
16+
17+
## [0.2.1 (2019-01-16)](https://github.com/onlime/bexio-api-client/releases/tag/0.2.0...0.2.1)
18+
19+
- Add `createInvoicePayment` and `deleteInvoicePayment`
20+
21+
## [0.2.0 (2019-01-16)](https://github.com/onlime/bexio-api-client/releases/tag/0.1.0...0.2.0)
22+
23+
- Update phpDoc for `getContacts` to reflect parameters
24+
25+
## [0.1.0 (2017-08-31)](https://github.com/onlime/bexio-api-client/releases/tag/0.1.0)
26+
27+
- Initial release
28+
- Fix contacts search and add discount and invoice resources

src/Bexio/AbstractClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ abstract class AbstractClient
1111

1212
abstract protected function request(string $path = '', string $method = self::METHOD_GET, array $data = [], array $queryParams = []);
1313

14-
public function get(string $path, array $data = [], array $queryParams = [])
14+
public function get(string $path, array $queryParams = [])
1515
{
16-
return $this->request($path, self::METHOD_GET, $data, $queryParams);
16+
return $this->request($path, self::METHOD_GET, queryParams: $queryParams);
1717
}
1818

1919
public function post(string $path, array $data = [], array $queryParams = [])

src/Bexio/Client.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,24 @@ protected function request(string $path = '', string $method = self::METHOD_GET,
174174
$path
175175
]));
176176

177-
if (!empty($queryParams)) {
178-
$apiUrl .= '?' . http_build_query($queryParams);
179-
}
180-
181177
$options = [
182178
'headers' => [
183179
'Authorization' => 'Bearer ' . $this->getAccessToken(),
184-
'Accept' => 'application/json'
180+
'Accept' => 'application/json',
185181
],
186-
'allow_redirects' => false
182+
'allow_redirects' => false,
187183
];
188-
if (!empty($data)) {
189-
$options[(self::METHOD_GET == $method) ? 'query' : 'json'] = $data;
184+
185+
if (!empty($queryParams)) {
186+
$options['query'] = $queryParams;
187+
}
188+
189+
if (!empty($data) && self::METHOD_GET !== $method) {
190+
$options['json'] = $data;
190191
}
191192

192-
$client = new GuzzleClient();
193193
try {
194-
$response = $client->request($method, $apiUrl, $options);
194+
$response = (new GuzzleClient())->request($method, $apiUrl, $options);
195195
} catch (ClientException $e) {
196196
// transform Guzzle ClientException into some more readable form, so that body content does not get truncated
197197
$body = json_decode($e->getResponse()->getBody()->getContents());

src/Bexio/Resource/Contact.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getContacts(array $params = [])
2929
*/
3030
public function searchContacts(array $params = [], array $queryParams = [])
3131
{
32-
return $this->client->post('contact/search', $params);
32+
return $this->client->post('contact/search', $params, $queryParams);
3333
}
3434

3535
/**

0 commit comments

Comments
 (0)