@@ -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}
0 commit comments