Skip to content

Commit

Permalink
Merge branch 'drscream-contacts-filter-update' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix committed Apr 13, 2024
2 parents 674a380 + 1c073d3 commit 25bc9d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ $client = $api->contact();

// filters
$client->size = 100;
$client->email = 'john.doe@example.com';
$client->name = 'John Doe';
$client->number = 123456;
$client->customer = true;
$client->vendor = false;
Expand Down Expand Up @@ -279,4 +281,4 @@ $response = $client->getPage(0);
// can be possible null because the response body can be empty
$json = \Sysix\LexOffice\Utils::getJsonFromResponse($response); // as object
$json = \Sysix\LexOffice\Utils::getJsonFromResponse($response, true); // as associative array
```
```
6 changes: 6 additions & 0 deletions src/Clients/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Contact extends PaginationClient

protected string $resource = 'contacts';

public ?string $email = null;

public ?string $name = null;

public ?int $number = null;

public ?bool $customer = null;
Expand All @@ -25,6 +29,8 @@ class Contact extends PaginationClient

protected function buildQueryParams(array $params): string
{
$params['email'] = $this->email;
$params['name'] = $this->name;
$params['number'] = $this->number;
$params['customer'] = $this->customer;
$params['vendor'] = $this->vendor;
Expand Down
4 changes: 3 additions & 1 deletion tests/Clients/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public function testGetPageWithFilters(): void
{
[$api, $client] = $this->createClientMockObject(Contact::class);

$client->email = 'john.doe@example.com';
$client->name = 'John Doe';
$client->number = 12345;
$client->customer = true;
$client->vendor = false;

$client->getPage(0);

$this->assertEquals(
$api->apiUrl . '/v1/contacts?page=0&number=12345&customer=1&vendor=0&size=100',
$api->apiUrl . '/v1/contacts?page=0&email=john.doe%40example.com&name=John+Doe&number=12345&customer=1&vendor=0&size=100',
$api->getRequest()->getUri()->__toString()
);
}
Expand Down

0 comments on commit 25bc9d3

Please sign in to comment.