Skip to content

Commit 0cce4e1

Browse files
committed
code linter and gist snippet markers
1 parent a13b9b0 commit 0cce4e1

File tree

3 files changed

+86
-56
lines changed

3 files changed

+86
-56
lines changed

src/Services/Examples/eSignature/InPersonSigningService.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ class InPersonSigningService
2222
* @return string
2323
*/
2424
public static function worker(
25-
string $accountId,
26-
string $hostName,
27-
SignatureClientService $clientService,
25+
string $accountId,
26+
string $hostName,
27+
SignatureClientService $clientService,
2828
string $demoPath
2929
): string {
30+
31+
# Step 3 Start
3032
$envelopeDefinition = InPersonSigningService::_prepareEnvelope($hostName, $demoPath);
3133
$envelopeApi = $clientService->getEnvelopeApi();
3234

@@ -37,8 +39,10 @@ public static function worker(
3739
exit;
3840
}
3941

42+
# Step 3 end
43+
4044
$authentication_method = 'None';
41-
45+
4246
$envelopeArguments = [
4347
'signer_email' => $GLOBALS['DS_CONFIG']['signer_email'],
4448
'signer_name' => $GLOBALS['DS_CONFIG']['signer_name'],
@@ -62,6 +66,8 @@ public static function worker(
6266
* @param $args array
6367
* @return EnvelopeDefinition -- returns an envelope definition
6468
*/
69+
70+
# Step 2 start
6571
private static function _prepareEnvelope(string $hostName, string $demoPath): EnvelopeDefinition
6672
{
6773
$file_content_in_bytes = file_get_contents($demoPath . $GLOBALS['DS_CONFIG']['doc_pdf']);
@@ -104,4 +110,6 @@ private static function _prepareEnvelope(string $hostName, string $demoPath): En
104110
]
105111
);
106112
}
113+
114+
#Step 2 end
107115
}

src/Services/Examples/eSignature/SetDocumentsVisibilityService.php

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,52 @@ class SetDocumentsVisibilityService
1616
{
1717
const CASE_FOR_INSTRUCTIONS = "ACCOUNT_LACKS_PERMISSIONS";
1818
const FIXING_INSTRUCTIONS_FOR_PERMISSIONS = "See " .
19-
"<a href=\"https://developers.docusign.com/docs/esign-rest-api/how-to/set-document-visibility\">" .
20-
"How to set document visibility for envelope recipients</a> in the DocuSign Developer Center " .
21-
"for instructions on how to enable document visibility in your developer account.";
22-
23-
public static function worker(string $signer1Email, string $signer1Name,
24-
string $signer2Email, string $signer2Name, string $ccEmail, string $ccName,
25-
string $docPdf, string $docDocx, string $docHTML, string $accountId,
26-
SignatureClientService $clientService, string $demoPath
19+
"<a href=\"https://developers.docusign.com/docs/esign-rest-api/how-to/set-document-visibility\">" .
20+
"How to set document visibility for envelope recipients</a> in the DocuSign Developer Center " .
21+
"for instructions on how to enable document visibility in your developer account.";
22+
23+
public static function worker(
24+
string $signer1Email,
25+
string $signer1Name,
26+
string $signer2Email,
27+
string $signer2Name,
28+
string $ccEmail,
29+
string $ccName,
30+
string $docPdf,
31+
string $docDocx,
32+
string $docHTML,
33+
string $accountId,
34+
SignatureClientService $clientService,
35+
string $demoPath
2736
): string {
2837
$envelope_definition = SetDocumentsVisibilityService::make_envelope(
29-
$signer1Email,
30-
$signer1Name,
38+
$signer1Email,
39+
$signer1Name,
3140
$signer2Email,
32-
$signer2Name,
33-
$ccEmail,
34-
$ccName,
35-
$docPdf,
36-
$docDocx,
37-
$docHTML,
41+
$signer2Name,
42+
$ccEmail,
43+
$ccName,
44+
$docPdf,
45+
$docDocx,
46+
$docHTML,
3847
$demoPath
3948
);
4049
$envelope_api = $clientService->getEnvelopeApi();
4150

4251
try {
52+
53+
# Step 4 start
4354
$envelopeSummary = $envelope_api->createEnvelope(
44-
$accountId,
55+
$accountId,
4556
$envelope_definition
4657
);
58+
# Step 4 end
4759
} catch (ApiException $e) {
4860
$error_code = $e->getResponseBody()->errorCode;
4961

5062
if (strpos($error_code, self::CASE_FOR_INSTRUCTIONS) !== false) {
5163
$clientService->showErrorTemplate(
52-
$e,
64+
$e,
5365
self::FIXING_INSTRUCTIONS_FOR_PERMISSIONS
5466
);
5567
exit;
@@ -61,10 +73,18 @@ public static function worker(string $signer1Email, string $signer1Name,
6173

6274
return $envelopeSummary->getEnvelopeId();
6375
}
64-
65-
private static function make_envelope(string $signer1Email, string $signer1Name,
66-
string $signer2Email, string $signer2Name, string $ccEmail, string $ccName,
67-
string $docPdf, string $docDocx, string $docHTML, string $demoPath
76+
# Step 3 start
77+
private static function make_envelope(
78+
string $signer1Email,
79+
string $signer1Name,
80+
string $signer2Email,
81+
string $signer2Name,
82+
string $ccEmail,
83+
string $ccName,
84+
string $docPdf,
85+
string $docDocx,
86+
string $docHTML,
87+
string $demoPath
6888
): EnvelopeDefinition {
6989
$carbonCopy = new CarbonCopy(
7090
[
@@ -79,17 +99,17 @@ private static function make_envelope(string $signer1Email, string $signer1Name,
7999
[
80100
'email_subject' => "Please sign this document set",
81101
'documents' => SetDocumentsVisibilityService::_prepareDocuments(
82-
$docPdf,
83-
$docDocx,
84-
$docHTML,
102+
$docPdf,
103+
$docDocx,
104+
$docHTML,
85105
$demoPath
86106
),
87107
'recipients' => new Recipients(
88108
[
89109
'signers' => SetDocumentsVisibilityService::_prepareSigners(
90-
$signer1Email,
91-
$signer1Name,
92-
$signer2Email,
110+
$signer1Email,
111+
$signer1Name,
112+
$signer2Email,
93113
$signer2Name
94114
),
95115
'carbon_copies' => [$carbonCopy]
@@ -103,9 +123,9 @@ private static function make_envelope(string $signer1Email, string $signer1Name,
103123
}
104124

105125
private static function _prepareSigners(
106-
string $signer1Email,
107-
string $signer1Name,
108-
string $signer2Email,
126+
string $signer1Email,
127+
string $signer1Name,
128+
string $signer2Email,
109129
string $signer2Name
110130
): array {
111131
$signer1 = new Signer(
@@ -117,7 +137,7 @@ private static function _prepareSigners(
117137
'excluded_documents' => ["2", "3"],
118138
'tabs' => new Tabs(
119139
[
120-
'sign_here_tabs' => [
140+
'sign_here_tabs' => [
121141
new SignHere(
122142
[
123143
'anchor_string' => '**signature_1**',
@@ -126,7 +146,7 @@ private static function _prepareSigners(
126146
'anchor_x_offset' => '20'
127147
]
128148
)
129-
]
149+
]
130150
]
131151
)
132152
]
@@ -141,16 +161,16 @@ private static function _prepareSigners(
141161
'excluded_documents' => ["1"],
142162
'tabs' => new Tabs(
143163
[
144-
'sign_here_tabs' => [
145-
new SignHere(
146-
[
147-
'anchor_string' => '/sn1/',
148-
'anchor_units' => 'pixels',
149-
'anchor_y_offset' => '10',
150-
'anchor_x_offset' => '20'
151-
]
152-
)
153-
]
164+
'sign_here_tabs' => [
165+
new SignHere(
166+
[
167+
'anchor_string' => '/sn1/',
168+
'anchor_units' => 'pixels',
169+
'anchor_y_offset' => '10',
170+
'anchor_x_offset' => '20'
171+
]
172+
)
173+
]
154174
]
155175
)
156176
]
@@ -160,9 +180,9 @@ private static function _prepareSigners(
160180
}
161181

162182
private static function _prepareDocuments(
163-
string $docPdf,
164-
string $docDocx,
165-
string $docHTML,
183+
string $docPdf,
184+
string $docDocx,
185+
string $docHTML,
166186
string $demoPath
167187
): array {
168188
$contentBytesPdf = file_get_contents($demoPath . $docPdf);
@@ -198,4 +218,5 @@ private static function _prepareDocuments(
198218

199219
return [$documentHTML, $documentDOCX, $documentPDF];
200220
}
221+
# Step 3 end
201222
}

src/Services/SignatureClientService.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($args)
4242
$config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
4343
$this->apiClient = new ApiClient($config);
4444
# Step 2 end
45-
$this->routerService = $GLOBALS['DS_CONFIG']['quickACG'] === "true" ? new QuickRouterService(): new RouterService();
45+
$this->routerService = $GLOBALS['DS_CONFIG']['quickACG'] === "true" ? new QuickRouterService() : new RouterService();
4646
}
4747

4848
/**
@@ -86,6 +86,8 @@ public function getRecipientViewRequest($authentication_method, $envelope_args):
8686
* @param $recipient_view_request RecipientViewRequest
8787
* @return \DocuSign\eSign\Model\ViewUrl - the list of Recipient Views
8888
*/
89+
90+
# Step 4 Start (inPersonSigning)
8991
public function getRecipientView(string $account_id, string $envelope_id, RecipientViewRequest $recipient_view_request): \DocuSign\eSign\Model\ViewUrl
9092
{
9193
try {
@@ -117,6 +119,8 @@ public function getRecipientView(string $account_id, string $envelope_id, Recipi
117119
return $viewUrl;
118120
}
119121

122+
# Step 4 end
123+
120124
/**
121125
* Getter for the EnvelopesApi
122126
*/
@@ -228,7 +232,7 @@ public function getAccountsApi(): AccountsApi
228232
public function showErrorTemplate(ApiException $e, string $fixingInstructions = null): void
229233
{
230234
$body = $e->getResponseBody($fixingInstructions);
231-
235+
232236
$GLOBALS['twig']->display(
233237
'error.html',
234238
[
@@ -291,7 +295,6 @@ public function getAuthenticatedUserEmail(string $accessToken): string
291295
$info = $this->apiClient->getUserInfo($accessToken);
292296

293297
return $info[0]['email'];
294-
295298
}
296299

297300
/**
@@ -304,10 +307,8 @@ public function getAuthenticatedUserName(string $accessToken): string
304307
{
305308
$this->apiClient->getOAuth()->setOAuthBasePath($GLOBALS['JWT_CONFIG']['authorization_server']);
306309
$info = $this->apiClient->getUserInfo($accessToken);
307-
308-
return $info[0]['accounts'][0]['account_name'];
309-
310310

311+
return $info[0]['accounts'][0]['account_name'];
311312
}
312313

313314
/**

0 commit comments

Comments
 (0)