Skip to content

Commit 1e0b78a

Browse files
committed
added separate method to delete envelope
1 parent cd820e6 commit 1e0b78a

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/Controllers/Examples/eSignature/EG045DeleteEnvelope.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class EG045DeleteEnvelope extends eSignBaseController
1515
const EG = 'eg045'; # reference (and url) for this example
1616
const FILE = __FILE__;
1717

18-
const DELETE_FOLDER_ID = "recyclebin";
19-
2018
/**
2119
* Create a new controller instance.
2220
*
@@ -42,12 +40,10 @@ public function createController(): void
4240
try {
4341
$_SESSION["envelope_id"] = $this->args['envelope_id'];
4442

45-
DeleteRestoreEnvelopeService::moveEnvelopeToFolder(
43+
DeleteRestoreEnvelopeService::deleteEnvelope(
4644
$this->clientService,
4745
$this->args["account_id"],
48-
$this->args["envelope_id"],
49-
self::DELETE_FOLDER_ID,
50-
null
46+
$this->args["envelope_id"]
5147
);
5248

5349
$pageText = array_values(array_filter(

src/Services/Examples/eSignature/DeleteRestoreEnvelopeService.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99

1010
class DeleteRestoreEnvelopeService
1111
{
12+
const DELETE_FOLDER_ID = "recyclebin";
13+
1214
/**
1315
* Moves envelope to a different folder
1416
*
1517
* @param SignatureClientService $clientService The client service for eSignature
1618
* @param string $accountId The DocuSign Account ID (GUID or short version)
1719
* @param string $envelopeId Envelope ID
1820
* @param string $folderId Destination Folder ID
19-
* @param string|null $fromFolderId From Folder ID (optional)
21+
* @param string $fromFolderId From Folder ID
2022
*
2123
* @return \DocuSign\eSign\Model\FoldersResponse
2224
*/
@@ -25,7 +27,7 @@ public static function moveEnvelopeToFolder(
2527
string $accountId,
2628
string $envelopeId,
2729
string $folderId,
28-
string|null $fromFolderId
30+
string $fromFolderId
2931
): FoldersResponse {
3032
$foldersApi = $clientService->getFoldersApi();
3133

@@ -37,6 +39,29 @@ public static function moveEnvelopeToFolder(
3739
return $foldersApi->moveEnvelopes($accountId, $folderId, $foldersRequest);
3840
}
3941

42+
/**
43+
* Deletes envelope
44+
*
45+
* @param SignatureClientService $clientService The client service for eSignature
46+
* @param string $accountId The DocuSign Account ID (GUID or short version)
47+
* @param string $envelopeId Envelope ID
48+
*
49+
* @return \DocuSign\eSign\Model\FoldersResponse
50+
*/
51+
public static function deleteEnvelope(
52+
SignatureClientService $clientService,
53+
string $accountId,
54+
string $envelopeId,
55+
): FoldersResponse {
56+
$foldersApi = $clientService->getFoldersApi();
57+
58+
$foldersRequest = new FoldersRequest([
59+
'envelope_ids' => [$envelopeId],
60+
]);
61+
62+
return $foldersApi->moveEnvelopes($accountId, self::DELETE_FOLDER_ID, $foldersRequest);
63+
}
64+
4065
/**
4166
* Gets all folders in the account
4267
*

0 commit comments

Comments
 (0)