Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add filter by driver #78

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Tests/Feature/Rule/IndexRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public static function ruleFilterDataProvider(): array
'queryKey' => 'product_id',
'queryValue' => '1',
],
[
'method' => 'driver',
'value' => 'huddle',
'queryKey' => 'driver',
'queryValue' => 'huddle',
],
[
'method' => 'levelId',
'value' => 1,
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ public function it_should_return_credentials(): void
$codeVerifier = 'testVerifier';
$redirectUrl = 'https://example.com/callback';
$clientId = 123;
$testTenantId = 456;

$mockResponse = new GuzzleResponse(200, [], json_encode(['access_token' => 'testAccessToken', 'refresh_token' => 'testRefreshToken'], JSON_THROW_ON_ERROR));
$mockGuzzleClient = $this->createMock(GuzzleClient::class);
$mockGuzzleClient->method('request')->willReturn($mockResponse);

$client = new Client(null, null, null, null, $mockGuzzleClient);
$response = $client->getCredentials($code, $codeVerifier, $redirectUrl, $clientId);
$response = $client->getCredentials($code, $codeVerifier, $redirectUrl, $clientId, $testTenantId);

$this->assertEquals(200, $response->status());
$this->assertEquals('testAccessToken', $response->body()['access_token']);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plug-and-pay/sdk-php",
"version": "1.2.1",
"version": "1.2.2",
"description": "This is a PHP SDK to make easier to communicate with the Plug&Pay API.",
"keywords": [
"PlugAndPay",
Expand Down
7 changes: 7 additions & 0 deletions src/Filters/RuleFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public function group(RuleGroupType $value): self
return $this;
}

public function driver(string $value): self
{
$this->parameters['driver'] = $value;

return $this;
}

public function tenantId(int $value): self
{
$this->parameters['tenant_id'] = $value;
Expand Down
3 changes: 2 additions & 1 deletion src/Service/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,15 @@ public function generateAuthorizationUrl(int $clientId, string $state, string $c
* @throws NotFoundException
* @throws ValidationException
*/
public function getCredentials(string $code, string $codeVerifier, string $redirectUrl, int $clientId): Response
public function getCredentials(string $code, string $codeVerifier, string $redirectUrl, int $clientId, int $tenantId): Response
{
$response = $this->request(self::METHOD_POST, '/oauth/token', [
'grant_type' => 'authorization_code',
'client_id' => $clientId,
'redirect_uri' => $redirectUrl,
'code_verifier' => $codeVerifier,
'code' => $code,
'tenant_id' => $tenantId,
]);

return $this->fromGuzzleResponse($response);
Expand Down
Loading