Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifications #213

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [Unreleased]
### Added
- Add `Identificaiton.cancelledAt`
- Add `Identificaiton.discardedAt`
- Add `Identification.result` and its sub-entities
- Add `IdentificationsEndpoint.cancel`
- Add `IdentificationsEndpoint.discard`
- Add `IdentificationsEndpoint.restore`
- Add `Identification.forReviewAt`
- Add `EnvelopeRecipient.channelForNotifications`
- Add `EnvelopeTemplateRecipient.channelForNotifications`
Expand Down
18 changes: 18 additions & 0 deletions src/Endpoint/IdentificationsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,22 @@ public function deny(Identification|string $id, array $body = []): Identificatio
{
return $this->makeResource($this->postRequest('/{id}/deny', ['id' => $id, 'json' => $body]));
}

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

/**
* @param mixed[] $body
*/
public function discard(Identification|string $id, array $body = []): Identification
{
return $this->makeResource($this->postRequest('/{id}/discard', ['id' => $id, 'json' => $body]));
}

public function restore(Identification|string $id): Identification
{
return $this->makeResource($this->postRequest('/{id}/restore', ['id' => $id]));
}
}
3 changes: 3 additions & 0 deletions src/Resource/Identification.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Identification extends BaseResource
public ?DateTime $approvedAt;
public ?DateTime $deniedAt;
public ?DateTime $forReviewAt;
public ?DateTime $cancelledAt;
public ?DateTime $discardedAt;
public ?string $denialMessage;
public ?IdentificationResult $result;
public ?IdentifyScenarioVersionInfo $scenarioVersion;
}
14 changes: 14 additions & 0 deletions src/Resource/IdentificationBankStatement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class IdentificationBankStatement extends BaseResource
{
use EntityResourceTrait;

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

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class IdentificationDocument extends BaseResource
{
use EntityResourceTrait;

public string $type;
public File $front;
public ?File $back;
}
12 changes: 12 additions & 0 deletions src/Resource/IdentificationInspection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class IdentificationInspection extends BaseResource
{
use EntityResourceTrait;
}
18 changes: 18 additions & 0 deletions src/Resource/IdentificationResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class IdentificationResult extends BaseResource
{
use EntityResourceTrait;

public ?IdentificationDocument $primaryDocument;
public ?IdentificationDocument $secondaryDocument;
public ?IdentificationBankStatement $bankStatement;
public ?IdentificationSelfie $selfie;
public ?IdentificationInspection $inspection;
}
14 changes: 14 additions & 0 deletions src/Resource/IdentificationSelfie.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class IdentificationSelfie extends BaseResource
{
use EntityResourceTrait;

public Image $image;
}
30 changes: 30 additions & 0 deletions tests/Endpoint/IdentificationsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@ public function testDeny(): void
self::assertLastRequest('POST', '/api/identifications/foo/deny');
}

public function testDenyWithBody(): void
{
self::endpoint()->deny('foo', ['foo' => 'bar']);
self::assertLastRequest('POST', '/api/identifications/foo/deny', ['foo' => 'bar']);
}

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

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

public function testDiscardWithBody(): void
{
self::endpoint()->discard('foo', ['foo' => 'bar']);
self::assertLastRequest('POST', '/api/identifications/foo/discard', ['foo' => 'bar']);
}

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

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