diff --git a/src/Contracts/GuestResourceContract.php b/src/Contracts/GuestResourceContract.php index 80e0b31..b2c75b0 100644 --- a/src/Contracts/GuestResourceContract.php +++ b/src/Contracts/GuestResourceContract.php @@ -4,11 +4,12 @@ namespace AirLST\SdkPhp\Contracts; +use Saloon\Contracts\ArrayStore; use Saloon\Http\Response; interface GuestResourceContract { - public function list(): Response; + public function list(array $query): Response; public function validateCode(string $code): Response; diff --git a/src/Requests/Guest/ListRequest.php b/src/Requests/Guest/ListRequest.php index 276c925..fa0f2ae 100644 --- a/src/Requests/Guest/ListRequest.php +++ b/src/Requests/Guest/ListRequest.php @@ -11,6 +11,8 @@ class ListRequest extends Request { protected Method $method = Method::GET; + public function __construct(protected array $additionalQuery) {} + public function resolveEndpoint(): string { return '/'; @@ -19,7 +21,9 @@ public function resolveEndpoint(): string protected function defaultQuery(): array { return [ + 'page' => 1, 'perPage' => 100, + ...$this->additionalQuery, ]; } } \ No newline at end of file diff --git a/src/Resources/GuestResource.php b/src/Resources/GuestResource.php index d9d705d..a2c48c3 100644 --- a/src/Resources/GuestResource.php +++ b/src/Resources/GuestResource.php @@ -20,9 +20,9 @@ public function validateCode(string $code): Response return $this->connector->send(new ValidateCodeRequest($code)); } - public function list(): Response + public function list(array $query = []): Response { - return $this->connector->send(new ListRequest()); + return $this->connector->send(new ListRequest($query)); } public function get(string $code): Response diff --git a/tests/Requests/Guest/ListRequestTest.php b/tests/Requests/Guest/ListRequestTest.php index f27c332..dda99d3 100644 --- a/tests/Requests/Guest/ListRequestTest.php +++ b/tests/Requests/Guest/ListRequestTest.php @@ -13,7 +13,7 @@ public function testList(): void { $mockClient = $this->mock(ListRequest::class); - $this->core->withMockClient($mockClient)->send(new ListRequest()); + $this->core->withMockClient($mockClient)->send(new ListRequest(['page' => 1])); $mockClient->assertSent(ListRequest::class); }