Skip to content

Commit

Permalink
Add new endpoints and resources (#182)
Browse files Browse the repository at this point in the history
Added the `MyEndpoint.info` and `MyAccountEndpoint.switch` endpoints, and the `MyInfo` resource. These updates provide users the ability to access additional information and functionality within the application. Tests for these additions have also been implemented to ensure their correct function. Also, conducted a small cleanup in the `MyAccount` resource.
  • Loading branch information
spajxo authored Oct 25, 2023
1 parent 92f657f commit 1985892
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [Unreleased]
### Added
- Add `MyEndpoint.info` endpoint and `MyInfo` resource
- Add `MyAccountEndpoint.switch` endpoint
- Add `AccountSmsSendersEndpoint` and `AccountSmsSender` resource
- Add `envelopeAnonymizeRetention` and `envelopeAnonymizeGroups` to `AccountSecurity`
- Add `anonymizeAt` and `anonymizedAt` to `Envelope`
Expand Down
5 changes: 5 additions & 0 deletions src/Endpoint/MyAccountsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public function decline(string $id): void
{
$this->postRequest('/{id}/decline', ['id' => $id]);
}

public function switch(string $id): void
{
$this->postRequest('/{id}/switch', ['id' => $id]);
}
}
6 changes: 6 additions & 0 deletions src/Endpoint/MyEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DigitalCz\DigiSign\DigiSign;
use DigitalCz\DigiSign\Resource\BaseResource;
use DigitalCz\DigiSign\Resource\MyInfo;

/**
* @extends ResourceEndpoint<BaseResource>
Expand Down Expand Up @@ -36,4 +37,9 @@ public function contacts(): MyContactsEndpoint
{
return new MyContactsEndpoint($this);
}

public function info(): MyInfo
{
return $this->createResource($this->getRequest('/info'), MyInfo::class);
}
}
4 changes: 0 additions & 4 deletions src/Resource/MyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
class MyAccount extends BaseResource
{
public string $id;

public string $name;

public string $status;

public bool $active;

public ?string $idpDomain;
}
16 changes: 16 additions & 0 deletions src/Resource/MyInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

class MyInfo extends BaseResource
{
public string $email;
public ?string $firstName;
public ?string $lastName;

/** @var string[] */
public array $permission;
public ?MyAccount $account;
}
6 changes: 6 additions & 0 deletions tests/Endpoint/MyAccountsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public function testDecline(): void
self::assertLastRequest('POST', '/api/my/accounts/foo/decline');
}

public function testSwitch(): void
{
self::endpoint()->switch('foo');
self::assertLastRequest('POST', '/api/my/accounts/foo/switch');
}

private static function endpoint(): MyAccountsEndpoint
{
return self::dgs()->my()->accounts();
Expand Down
6 changes: 6 additions & 0 deletions tests/Endpoint/MyEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public function testChildren(): void
self::assertDefaultEndpointPath(self::endpoint()->contacts(), '/api/my/contacts');
}

public function testInfo(): void
{
self::endpoint()->info();
self::assertLastRequest('GET', '/api/my/info');
}

private static function endpoint(): MyEndpoint
{
return self::dgs()->my();
Expand Down

0 comments on commit 1985892

Please sign in to comment.