Skip to content

Commit

Permalink
Rename method names for permission driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Enver Cigal committed May 30, 2022
1 parent 15fb739 commit 8319cd7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0]

### Changed features

Rename method names for permission driver
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Authentication token is generated per UserManager instance. Expire time is two h
With the usage in this example, you can submit a single release. This method works with the "Permission" model

```php
IysManager::make()->createPermissionDriver()->sendSinglePermission(
IysManager::make()->createPermissionDriver()->sendSingle(
Permission::make()
->setConsentDate('2022-02-10 09:50:02')
->setSource(ConsentSourceTypes::MOBILE)
Expand Down Expand Up @@ -134,24 +134,24 @@ You can send permissions by filling out the permission list model. The permissio
->setSource(ConsentSourceTypes::MOBILE)
->setRecipientType(RecipientTypes::INDIVIDUAL);

IysManager::make()->createPermissionDriver()->sendPermissions($permissionList);
IysManager::make()->createPermissionDriver()->sendMultiple($permissionList);
```

You can get send permission information with request id

```php
IysManager::make()->createPermissionDriver()->getPermissionsStatus('request_id');
IysManager::make()->createPermissionDriver()->getStatusByRequestId('request_id');
```
You can get changed permission by IYS

```php
IysManager::make()->createPermissionDriver()->getChangedPermissions();
IysManager::make()->createPermissionDriver()->getChanges();
```

You can get permission status by permission model

```php
IysManager::make()->createPermissionDriver()->getPermissionStatus(
IysManager::make()->createPermissionDriver()->getStatus(
Permission::make()
->setConsentDate('2022-02-10 09:50:02')
->setSource(ConsentSourceTypes::MOBILE)
Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/Permission/PermissionDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PermissionDriver extends AbstractDriver
/**
* @throws RequestException
*/
public function sendSinglePermission(Permission $permission)
public function sendSingle(Permission $permission)
{
return Http::timeout($this->timeout)
->withToken($this->bearer)->asJson()->acceptJson()
Expand All @@ -28,7 +28,7 @@ public function sendSinglePermission(Permission $permission)
/**
* @throws RequestException
*/
public function sendPermissions(PermissionList $permissionList)
public function sendMultiple(PermissionList $permissionList)
{
return Http::timeout($this->timeout)
->withToken($this->bearer)->asJson()->acceptJson()
Expand All @@ -39,7 +39,7 @@ public function sendPermissions(PermissionList $permissionList)
/**
* @throws RequestException
*/
public function getPermissionsStatus(string $requestId)
public function getStatusByRequestId(string $requestId)
{
return Http::timeout($this->timeout)
->withToken($this->bearer)->asJson()->acceptJson()
Expand All @@ -50,7 +50,7 @@ public function getPermissionsStatus(string $requestId)
/**
* @throws RequestException
*/
public function getChangedPermissions(?string $after = null, SourceTypes $source = SourceTypes::IYS, int $limit = 999)
public function getChanges(?string $after = null, SourceTypes $source = SourceTypes::IYS, int $limit = 999)
{
$query = [
'source' => $source->value,
Expand All @@ -70,7 +70,7 @@ public function getChangedPermissions(?string $after = null, SourceTypes $source
/**
* @throws RequestException
*/
public function getPermissionStatus(Permission $permission)
public function getStatus(Permission $permission)
{
$permissionData = $permission->toArray();

Expand Down
22 changes: 11 additions & 11 deletions tests/PermissionDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function test_can_send_permission()
]),
]);

IysManager::make()->createPermissionDriver()->sendSinglePermission(
IysManager::make()->createPermissionDriver()->sendSingle(
Permission::make()
->setConsentDate($consentDate)
->setSource(ConsentSourceTypes::MOBILE)
Expand Down Expand Up @@ -99,7 +99,7 @@ public function test_throw_exception_send_permission()

$this->expectException(RequestException::class);

IysManager::make()->createPermissionDriver()->sendSinglePermission(
IysManager::make()->createPermissionDriver()->sendSingle(
Permission::make()
->setConsentDate($consentDate)
->setSource(ConsentSourceTypes::MOBILE)
Expand Down Expand Up @@ -171,7 +171,7 @@ public function test_can_send_permissions()
->setStatus(StatusTypes::REJECT)
->setType(PermissionTypes::MESSAGE));

IysManager::make()->createPermissionDriver()->sendPermissions($permissionList);
IysManager::make()->createPermissionDriver()->sendMultiple($permissionList);

Http::assertSent(function (Request $request) use ($endpoint, $recipientFirst, $recipientSecond, $consentDate) {
return $request->url() == $this->url . $endpoint &&
Expand Down Expand Up @@ -235,7 +235,7 @@ public function test_throw_exception_send_permissions()

$this->expectException(RequestException::class);

IysManager::make()->createPermissionDriver()->sendPermissions($permissionList);
IysManager::make()->createPermissionDriver()->sendMultiple($permissionList);
}

/**
Expand Down Expand Up @@ -281,7 +281,7 @@ public function test_get_status_permissions()

$this->createHttpFakeToken();

IysManager::make()->createPermissionDriver()->getPermissionsStatus($requestId);
IysManager::make()->createPermissionDriver()->getStatusByRequestId($requestId);

Http::assertSent(function (Request $request) use ($endpoint) {
return $request->url() == $this->url . $endpoint;
Expand Down Expand Up @@ -313,7 +313,7 @@ public function test_throw_exception_get_status_permissions()

$this->expectException(RequestException::class);

IysManager::make()->createPermissionDriver()->getChangedPermissions();
IysManager::make()->createPermissionDriver()->getChanges();
}

/**
Expand Down Expand Up @@ -350,7 +350,7 @@ public function test_get_changed_permissions()
]
)]);

IysManager::make()->createPermissionDriver()->getChangedPermissions();
IysManager::make()->createPermissionDriver()->getChanges();

Http::assertSent(function (Request $request) use ($endpoint) {
return $request->url() == $this->url . $endpoint;
Expand Down Expand Up @@ -394,7 +394,7 @@ public function test_get_changed_permissions_with_options()
]
)]);

IysManager::make()->createPermissionDriver()->getChangedPermissions($after, SourceTypes::HS, $limit);
IysManager::make()->createPermissionDriver()->getChanges($after, SourceTypes::HS, $limit);

Http::assertSent(function (Request $request) use ($endpoint) {
return $request->url() == $this->url . $endpoint;
Expand Down Expand Up @@ -431,7 +431,7 @@ public function test_throw_exception_get_changed_permissions()

$this->expectException(RequestException::class);

IysManager::make()->createPermissionDriver()->getChangedPermissions();
IysManager::make()->createPermissionDriver()->getChanges();
}

/**
Expand Down Expand Up @@ -463,7 +463,7 @@ public function test_get_permission_status()
])
]);

IysManager::make()->createPermissionDriver()->getPermissionStatus(Permission::make()
IysManager::make()->createPermissionDriver()->getStatus(Permission::make()
->setConsentDate($consentDate)
->setSource(ConsentSourceTypes::MOBILE)
->setRecipient($recipient)
Expand Down Expand Up @@ -499,6 +499,6 @@ public function test_throw_exception_get_permission_status()

$this->expectException(RequestException::class);

IysManager::make()->createPermissionDriver()->getChangedPermissions();
IysManager::make()->createPermissionDriver()->getChanges();
}
}

0 comments on commit 8319cd7

Please sign in to comment.