Skip to content

Commit

Permalink
Add MyEndpoint.updatePreferences endpoint and MyPreferences resou…
Browse files Browse the repository at this point in the history
…rce (#284)
  • Loading branch information
spajxo authored Dec 23, 2024
1 parent 5e04add commit d77215f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [Unreleased]
- Add `MyEndpoint.updatePreferences` endpoint and `MyPreferences` resource
- Add `SignatureScenarioVersionInfo.role`
- Add `BatchSendingsEndpoint.send` endpoint
- Add `BatchSendingsEndpoint.list` endpoint
Expand Down
12 changes: 12 additions & 0 deletions src/Endpoint/MyEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DigitalCz\DigiSign\DigiSign;
use DigitalCz\DigiSign\Resource\BaseResource;
use DigitalCz\DigiSign\Resource\MyInfo;
use DigitalCz\DigiSign\Resource\MyPreferences;

/**
* @extends ResourceEndpoint<BaseResource>
Expand Down Expand Up @@ -47,4 +48,15 @@ public function identifications(): MyIdentificationsEndpoint
{
return new MyIdentificationsEndpoint($this);
}

/**
* @param mixed[] $body
*/
public function updatePreferences(array $body): MyPreferences
{
return $this->createResource(
$this->putRequest('/preferences', ['json' => $body]),
MyPreferences::class,
);
}
}
1 change: 1 addition & 0 deletions src/Resource/MyInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class MyInfo extends BaseResource
/** @var string[] */
public array $permissions;
public ?MyAccount $account;
public MyPreferences $preferences;
}
13 changes: 13 additions & 0 deletions src/Resource/MyPreferences.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

class MyPreferences extends BaseResource
{
public bool $prefillAsRecipient;
public bool $autoscrollTags;
public bool $welcomeVideoHide;
public bool $welcomeVideoClose;
}
6 changes: 6 additions & 0 deletions tests/Endpoint/MyEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public function testInfo(): void
self::assertLastRequest('GET', '/api/my/info');
}

public function testUpdatePreferences(): void
{
self::endpoint()->updatePreferences(['foo' => 'bar']);
self::assertLastRequest('PUT', '/api/my/preferences', ['foo' => 'bar']);
}

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

0 comments on commit d77215f

Please sign in to comment.