Skip to content

Commit

Permalink
DGS-1720 add approve and deny to identification (#179)
Browse files Browse the repository at this point in the history
* Add fields to Identification

* Add approve/deny enpoints to IdentificationsResource

* Add test

* Fix test

* Add crud methods definitions

* remove blank line
  • Loading branch information
mertic18 authored Oct 18, 2023
1 parent e89702d commit d294a34
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Add `anonymizeAt` and `anonymizedAt` to `Envelope`
- Add anonymize action to `Envelope`
- Add `AccountEmailSendersEndpoint` and `AccountEmailSender` resource
- Add `approvedAt`, `deniedAt` and `denailMessage` to `Identification`
- Add `Identification.approve` endpoint and `Identification.deny` endpoint

### Changed
- Change `EnvelopeDocument.file` to nullable
Expand Down
16 changes: 16 additions & 0 deletions src/Endpoint/IdentificationsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/**
* @extends ResourceEndpoint<Identification>
* @method Identification get(string $id)
* @method Identification create(array $body)
* @method Identification update(string $id, array $body)
*/
final class IdentificationsEndpoint extends ResourceEndpoint
{
Expand All @@ -20,4 +23,17 @@ public function __construct(DigiSign $parent)
{
parent::__construct($parent, '/api/identifications', Identification::class);
}

public function approve(Identification|string $id): Identification
{
return $this->makeResource($this->postRequest('/{id}/approve', ['id' => $id]));
}

/**
* @param mixed[] $body
*/
public function deny(Identification|string $id, array $body = []): Identification
{
return $this->makeResource($this->postRequest('/{id}/deny', ['id' => $id, 'json' => $body]));
}
}
3 changes: 3 additions & 0 deletions src/Resource/Identification.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ class Identification extends BaseResource
public ?DateTime $startedAt;
public ?DateTime $openedAt;
public ?DateTime $completedAt;
public ?DateTime $approvedAt;
public ?DateTime $deniedAt;
public ?string $denialMessage;
}
12 changes: 12 additions & 0 deletions tests/Endpoint/IdentificationsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ public function testCRUD(): void
self::assertCrudRequests(self::endpoint(), '/api/identifications');
}

public function testApprove(): void
{
self::endpoint()->approve('foo');
self::assertLastRequest('POST', '/api/identifications/foo/approve');
}

public function testDeny(): void
{
self::endpoint()->deny('foo');
self::assertLastRequest('POST', '/api/identifications/foo/deny');
}

protected static function endpoint(): IdentificationsEndpoint
{
return self::dgs()->identifications();
Expand Down

0 comments on commit d294a34

Please sign in to comment.