Skip to content

Commit

Permalink
Release/v1.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
caiquearaujo committed Sep 28, 2022
2 parents 1e8d1cc + 6cdaace commit 9fc6223
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@
* [ADD] Abstract model and models.
* [ADD] Abstract classes for API wrapper and API endpoints;
* [ADD] Clone method to `Configuration`;
* [ADD] Enviroment interface to manipulate client configuration.
* [ADD] Enviroment interface to manipulate client configuration.

## `1.0.10` at `2022-09-28`

* [FIX] Invalid field name and timezone implementation at `CredentialModel`.
6 changes: 5 additions & 1 deletion src/Models/CredentialModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public function isExpired () : bool {
* Export object data to an array.
*
* @since 1.0.9
* @since 1.0.10 timezone export
* @return array
*/
public function export(): array
Expand All @@ -163,6 +164,7 @@ public function export(): array
'token_type' => $this->get('token_type', static::TOKEN_TYPE_BEARER),
'access_token' => $this->get('access_token'),
'scope' => $this->get('scope'),
'timezone' => $this->has('timezone') ? $this->get('timezone')->getName() : 'UTC',
'consented_on' => $this->has('consented_on') ? $this->get('consented_on')->getTimestamp() : null,
'expires_on' => $this->has('expires_on') ? $this->get('expires_on')->getTimestamp() : null,
'expires_in' => $this->get('expires_in'),
Expand All @@ -174,6 +176,7 @@ public function export(): array
*
* @param array $data
* @since 1.0.9
* @since 1.0.10 expired_on to expires_on, timezone import
* @return self
*/
public static function import(array $data)
Expand All @@ -183,9 +186,10 @@ public static function import(array $data)
$m->set('token_type', $data['token_type'] ?? static::TOKEN_TYPE_BEARER);
$m->set('access_token', $data['access_token'] ?? null);
$m->set('scope', $data['scope'] ?? null);
$m->set('timezone', $data['timezone'] ?? new DateTimeZone('UTC'));

if ( !empty($data['consented_on']) ) $m->set('consented_on', $data['consented_on']);
if ( !empty($data['expired_on']) ) $m->set('expired_on', $data['expired_on']);
if ( !empty($data['expires_on']) ) $m->set('expires_on', $data['expires_on']);
if ( !empty($data['expires_in']) ) $m->set('expires_in', $data['expires_in']);

return $m;
Expand Down
1 change: 1 addition & 0 deletions tests/Models/ApplicationModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function assertIfCanMutateCredential ()
'token_type' => 'Bearer',
'access_token' => 'jwt',
'scope' => ['read', 'write'],
'timezone' => 'UTC',
'consented_on' => 1662001200,
'expires_on' => 1662001200+300,
'expires_in' => 300,
Expand Down
3 changes: 3 additions & 0 deletions tests/Models/CredentialModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public function assertIfIsExported ()
'token_type' => 'Bearer',
'access_token' => null,
'scope' => null,
'timezone' => 'UTC',
'consented_on' => null,
'expires_on' => null,
'expires_in' => null,
Expand All @@ -162,6 +163,7 @@ public function assertIfIsExported ()
'token_type' => 'Bearer',
'access_token' => 'jwt',
'scope' => ['read', 'write'],
'timezone' => 'UTC',
'consented_on' => 1662001200,
'expires_on' => 1662001200+300,
'expires_in' => 300,
Expand All @@ -187,6 +189,7 @@ public function assertIfIsCreated ()
'token_type' => 'Bearer',
'access_token' => 'jwt',
'scope' => ['read', 'write'],
'timezone' => 'UTC',
'consented_on' => 1662001200,
'expires_on' => 1662001200+300,
'expires_in' => 300,
Expand Down

0 comments on commit 9fc6223

Please sign in to comment.