Skip to content

Commit

Permalink
Merge pull request #32 from signnow/add-update-document-name-action
Browse files Browse the repository at this point in the history
Added action to modify document name
  • Loading branch information
JiSoft authored Mar 1, 2023
2 parents a713c48 + f986285 commit 0241221
Showing 4 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.2.6] - 2023-02-28
### Added
- Support modify document name

## [v2.2.5] - 2022-11-22
### Added
- Support move document
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ Simple API Client to integrate SignNow with your application or website. Sign do
* [Retrieve document](#retrieve-document)
* [Delete document](#delete-document)
* [Download document](#download-document)
* [Modify document name](#modify-document-name)
* [Create a single-use link for document downloading](#document-download-link)
* [Create a role-based invite to sign a document](#role-invite-document)
* [Create a simple free form invite to sign a document](#free-form-invite-document)
@@ -212,6 +213,24 @@ $entityManager->get(new DocumentDownload(), ['id' => $documentUniqueId], ['type'
// if need table containing the document's history set with_history=1
$entityManager->get(new DocumentDownload(), ['id' => $documentUniqueId], ['type' => 'collapsed', 'with_history' => 1]);
```
#### <a name="modify-document-name"></a>Modify document name
```php
use SignNow\Api\Action\Document;
use SignNow\Api\Action\OAuth as SignNowOAuth;

$auth = new SignNowOAuth(HOST);
$entityManager = $auth->bearerByPassword(
BASIC_TOKEN,
USER,
PASSWORD
);

$documentUniqueId = 'd136ce0211a74a808de9fefe7249446fe452e566';
$documentName = 'Your document name to be modified';

$document = new Document($entityManager);
$documentEntity = $document->modifyName($documentUniqueId, $documentName);
```
#### <a name="document-download-link"></a>Create a single-use link for document downloading
```php
use SignNow\Api\Entity\Document\DownloadLink;
18 changes: 18 additions & 0 deletions src/Action/Document.php
Original file line number Diff line number Diff line change
@@ -167,4 +167,22 @@ public function createDownloadLink(string $documentUniqueId): DocumentDownloadLi
]
);
}

/**
* @param string $newDocumentName
* @param string $documentUniqueId
*
* @return DocumentEntity|object
* @throws EntityManagerException
* @throws ReflectionException
*/
public function modifyName(string $documentUniqueId, string $newDocumentName): DocumentEntity
{
$document = new DocumentEntity();
$document->setId($documentUniqueId);
$document->setDocumentName($newDocumentName);
$this->entityManager->setUpdateHttpMethod(Request::METHOD_PUT);

return $this->entityManager->update($document);
}
}
20 changes: 20 additions & 0 deletions tests/functional/Document/UpdateDocumentCest.php
Original file line number Diff line number Diff line change
@@ -90,4 +90,24 @@ public function testAddFields(FunctionalTester $I): void

$I->assertSame($documentUniqueId, $documentEntity->getId());
}

/**
* @param FunctionalTester $I
*
* @return void
* @throws EntityManagerException
* @throws ReflectionException
*/
public function testUpdateDocumentName(FunctionalTester $I): void
{
$document = new Document($this->auth);

$documentUniqueId = $I->createUniqueId();

$I->mockUpdateDocumentRequest($documentUniqueId);

$documentEntity = $document->modifyName($documentUniqueId, 'Updated Cool Name');

$I->assertSame($documentUniqueId, $documentEntity->getId());
}
}

0 comments on commit 0241221

Please sign in to comment.