-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Enver Cigal
committed
May 26, 2022
1 parent
48f6f1e
commit 15fb739
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,20 @@ You can get changed permission by IYS | |
IysManager::make()->createPermissionDriver()->getChangedPermissions(); | ||
``` | ||
|
||
You can get permission status by permission model | ||
|
||
```php | ||
IysManager::make()->createPermissionDriver()->getPermissionStatus( | ||
Permission::make() | ||
->setConsentDate('2022-02-10 09:50:02') | ||
->setSource(ConsentSourceTypes::MOBILE) | ||
->setRecipient('[email protected]') | ||
->setRecipientType(RecipientTypes::INDIVIDUAL) | ||
->setStatus(StatusTypes::APPROVE) | ||
->setType(PermissionTypes::EMAIL) | ||
); | ||
``` | ||
|
||
## Testing | ||
|
||
``` bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,4 +433,72 @@ public function test_throw_exception_get_changed_permissions() | |
|
||
IysManager::make()->createPermissionDriver()->getChangedPermissions(); | ||
} | ||
|
||
/** | ||
* @throws RequestException | ||
*/ | ||
public function test_get_permission_status() | ||
{ | ||
$recipient = '[email protected]'; | ||
|
||
$consentDate = '2020-07-08 07:07:07'; | ||
|
||
$endpoint = "/sps/$this->iysCode/brands/$this->brandCode/consents/status"; | ||
|
||
$this->createHttpFakeToken(); | ||
|
||
Http::fake([ | ||
$endpoint => Http::response([ | ||
'consentDate' => $consentDate, | ||
'source' => ConsentSourceTypes::MOBILE, | ||
'recipientType' => RecipientTypes::INDIVIDUAL, | ||
'status' => StatusTypes::APPROVE, | ||
'type' => PermissionTypes::EMAIL, | ||
'recipient' => $recipient, | ||
'retailerCode' => 55550127, | ||
'creationDate' => '2020-08-06 15:50:23', | ||
'retailerTitle' => 'Test Company', | ||
'retailerAccessCount' => 3, | ||
'transactionId' => 'abc623z3cq4bhac9b88dadd49b767a2322be140a9n9cuc25abf1ac5392c4ca12', | ||
]) | ||
]); | ||
|
||
IysManager::make()->createPermissionDriver()->getPermissionStatus(Permission::make() | ||
->setConsentDate($consentDate) | ||
->setSource(ConsentSourceTypes::MOBILE) | ||
->setRecipient($recipient) | ||
->setRecipientType(RecipientTypes::INDIVIDUAL) | ||
->setStatus(StatusTypes::APPROVE) | ||
->setType(PermissionTypes::EMAIL)); | ||
|
||
Http::assertSent(function (Request $request) use ($endpoint, $recipient) { | ||
return $request->url() == $this->url . $endpoint && | ||
$request['recipient'] == $recipient && | ||
$request['recipientType'] == RecipientTypes::INDIVIDUAL->value && | ||
$request['type'] == PermissionTypes::EMAIL->value; | ||
}); | ||
} | ||
|
||
public function test_throw_exception_get_permission_status() | ||
{ | ||
$endpoint = "/sps/$this->iysCode/brands/$this->brandCode/consents/status"; | ||
|
||
$this->createHttpFakeToken(); | ||
|
||
Http::fake([ | ||
$endpoint => Http::response([ | ||
[ | ||
"errors" => [ | ||
[ | ||
"code" => "H097", | ||
"message" => "İzin sorgulama isteği geçerli olmalıdır." | ||
] | ||
] | ||
]], 400), | ||
]); | ||
|
||
$this->expectException(RequestException::class); | ||
|
||
IysManager::make()->createPermissionDriver()->getChangedPermissions(); | ||
} | ||
} |