Skip to content

Commit 5e5a36e

Browse files
committed
gist snippet markers
1 parent ad5cace commit 5e5a36e

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/Services/Examples/eSignature/DocumentGenerationService.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,59 @@ class DocumentGenerationService
2222
{
2323
public static function worker(array $args, $clientService, $documentPath): string
2424
{
25+
26+
// Step 2a start
2527
$templatesApi = $clientService->getTemplatesApi();
2628

2729
$envelopeTemplate = DocumentGenerationService::makeTemplate();
2830
$templatesListResponse = $templatesApi->createTemplate($args['account_id'], $envelopeTemplate);
2931
$templateId = $templatesListResponse['template_id'];
32+
// Step 2a end
3033

34+
// Step 3a start
3135
$templatesApi->updateDocument($args['account_id'], "1", $templateId, self::addDocumentTemplate($documentPath));
36+
// Step 3a end
37+
38+
// Step 4a start
3239
$templatesApi->createTabs($args['account_id'], "1", $templateId, self::prepareTabs());
40+
// Step 4a end
3341

42+
// Step 5a start
3443
$envelopeApi = $clientService->getEnvelopeApi();
3544
$envelopeResponse = $envelopeApi->createEnvelope(
3645
$args['account_id'],
3746
DocumentGenerationService::makeEnvelope($args["form_data"], $templateId)
3847
);
3948
$envelopeId = $envelopeResponse["envelope_id"];
49+
// Step 5a end
4050

51+
// Step 6 start
4152
$documents = $envelopeApi->getEnvelopeDocGenFormFields($args['account_id'], $envelopeId);
4253
$documentId = $documents["doc_gen_form_fields"][0]["document_id"];
43-
54+
// Step 6 end
55+
56+
// Step 7a start
4457
$formFields = DocumentGenerationService::formFields($args["form_data"], $documentId);
4558
$envelopeApi->updateEnvelopeDocGenFormFields(
4659
$args['account_id'],
4760
$envelopeId,
4861
$formFields
4962
);
63+
// Step 7a end
5064

65+
// Step 8 start
5166
$envelopeResponse = $envelopeApi->update(
5267
$args['account_id'],
5368
$envelopeId,
5469
new Envelope([
5570
'status' => 'sent'
5671
])
5772
);
73+
// Step 8 end
5874

5975
return $envelopeResponse->getEnvelopeId();
6076
}
61-
77+
// Step 2b start
6278
public static function makeTemplate(): EnvelopeTemplate
6379
{
6480
$signer = new Signer([
@@ -80,7 +96,10 @@ public static function makeTemplate(): EnvelopeTemplate
8096
]
8197
);
8298
}
99+
// Step 2b end
83100

101+
102+
// Step 4b start
84103
public static function prepareTabs(): TemplateTabs
85104
{
86105
$signHere = new SignHere([
@@ -102,7 +121,9 @@ public static function prepareTabs(): TemplateTabs
102121
'date_signed_tabs' => [$dateSigned],
103122
]);
104123
}
124+
// Step4b end
105125

126+
// Step 3b start
106127
public static function addDocumentTemplate(string $documentPath): EnvelopeDefinition
107128
{
108129
$documentFile = $GLOBALS['DS_CONFIG']['offer_doc_docx'];
@@ -122,7 +143,9 @@ public static function addDocumentTemplate(string $documentPath): EnvelopeDefini
122143
'documents' => [$document],
123144
]);
124145
}
125-
146+
// Step 3b end
147+
148+
// Step 5b start
126149
public static function makeEnvelope(array $args, $templateId): EnvelopeDefinition
127150
{
128151
$signer = new TemplateRole([
@@ -139,7 +162,8 @@ public static function makeEnvelope(array $args, $templateId): EnvelopeDefinitio
139162
]
140163
);
141164
}
142-
165+
// Step 5b end
166+
// Step 7b start
143167
public static function formFields(array $args, $documentId): DocGenFormFieldRequest
144168
{
145169
return new DocGenFormFieldRequest(
@@ -174,4 +198,5 @@ public static function formFields(array $args, $documentId): DocGenFormFieldRequ
174198
]
175199
);
176200
}
201+
// Step 7b end
177202
}

0 commit comments

Comments
 (0)