Skip to content

Commit

Permalink
[Feature] added query parameters to list request
Browse files Browse the repository at this point in the history
  • Loading branch information
jantinnerezo committed May 14, 2024
1 parent 77dc6a9 commit dd156bb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Contracts/GuestResourceContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 12 in src/Contracts/GuestResourceContract.php

View workflow job for this annotation

GitHub Actions / build

Method AirLST\SdkPhp\Contracts\GuestResourceContract::list() has parameter $query with no value type specified in iterable type array.

public function validateCode(string $code): Response;

Expand Down
4 changes: 4 additions & 0 deletions src/Requests/Guest/ListRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ListRequest extends Request
{
protected Method $method = Method::GET;

public function __construct(protected array $additionalQuery) {}

Check failure on line 14 in src/Requests/Guest/ListRequest.php

View workflow job for this annotation

GitHub Actions / build

Method AirLST\SdkPhp\Requests\Guest\ListRequest::__construct() has parameter $additionalQuery with no value type specified in iterable type array.

public function resolveEndpoint(): string
{
return '/';
Expand All @@ -19,7 +21,9 @@ public function resolveEndpoint(): string
protected function defaultQuery(): array
{
return [
'page' => 1,
'perPage' => 100,
...$this->additionalQuery,
];
}
}
4 changes: 2 additions & 2 deletions src/Resources/GuestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 23 in src/Resources/GuestResource.php

View workflow job for this annotation

GitHub Actions / build

Method AirLST\SdkPhp\Resources\GuestResource::list() has parameter $query with no value type specified in iterable type array.
{
return $this->connector->send(new ListRequest());
return $this->connector->send(new ListRequest($query));
}

public function get(string $code): Response
Expand Down
2 changes: 1 addition & 1 deletion tests/Requests/Guest/ListRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit dd156bb

Please sign in to comment.