@@ -25,40 +25,53 @@ def initialize(request, session)
2525 end
2626
2727 def call
28- # Step 1. Obtain your OAuth token
28+ # Construct your API headers
29+ # Step 2 start
2930 configuration = DocuSign_eSign ::Configuration . new
3031 configuration . host = args [ :base_path ]
3132 api_client = DocuSign_eSign ::ApiClient . new configuration
32-
33- # Step 2. Construct your API headers
3433 construct_api_headers ( api_client )
34+ # Step end
3535
36- # Step 3. Create and submit the bulk sending list
36+ # Create and submit the bulk sending list
37+ # Step 3-1 start
3738 bulk_envelopes_api = DocuSign_eSign ::BulkEnvelopesApi . new api_client
3839 bulk_sending_list = create_bulk_sending_list
3940 bulk_list = bulk_envelopes_api . create_bulk_send_list ( args [ :account_id ] , bulk_sending_list )
4041 bulk_list_id = bulk_list . list_id
42+ # Step 3-1 end
4143
42- # Step 4. Create the draft envelope
44+ # Create the draft envelope
45+ # Step 4-1 start
4346 envelope_api = create_envelope_api ( args )
4447 envelope_definition = make_envelope
4548 envelope = envelope_api . create_envelope ( args [ :account_id ] , envelope_definition , options = DocuSign_eSign ::CreateEnvelopeOptions . default )
4649 envelope_id = envelope . envelope_id
50+ # Step 4-1 end
4751
48- # Step 5. Attach your bulk list ID to the envelope
52+ # Attach your bulk list ID to the envelope
53+ # Step 5-1 start
4954 envelope_api . create_custom_fields ( args [ :account_id ] , envelope_id , custom_fields ( bulk_list_id ) )
55+ # Step 5-1 end
5056
51- # Step 6. Add placeholder recipients
52- recipients = DocuSign_eSign ::Recipients . new ( signers : recipients_data )
57+ # Add placeholder recipients
58+ # Step 6-1 start
59+ recipients = recipients_data
60+ recipients = DocuSign_eSign ::Recipients . new ( signers : [ recipients [ 0 ] ] , cc : [ recipients [ 1 ] ] )
5361 envelope_api . create_recipient ( args [ :account_id ] , envelope_id , recipients , options = DocuSign_eSign ::CreateRecipientOptions . default )
62+ # Step 6-1 end
5463
55- # Step 7. Initiate bulk send
64+ # Initiate bulk send
65+ # Step 7 start
5666 bulk_send_request = DocuSign_eSign ::BulkSendRequest . new ( envelopeOrTemplateId : envelope_id )
5767 batch = bulk_envelopes_api . create_bulk_send_request ( args [ :account_id ] , bulk_list_id , bulk_send_request )
5868 batch_id = batch . batch_id
69+ # Step 7 end
5970
60- # Step 8. Confirm successful batch send
71+ # Confirm successful batch send
72+ # Step 8 start
6173 bulk_envelopes_api . get_bulk_send_batch_status ( args [ :account_id ] , batch_id )
74+ # Step 8 end
6275 end
6376
6477 private
@@ -71,6 +84,7 @@ def construct_api_headers(api_client)
7184 api_client . default_headers [ 'Accept-Language' ] = "en-US,en;q=0.9"
7285 end
7386
87+ # Step 3-2 start
7488 def create_bulk_sending_list
7589 bulk_copies = [ ]
7690 recipient1 = DocuSign_eSign ::BulkSendingCopyRecipient . new (
@@ -119,7 +133,9 @@ def create_bulk_sending_list
119133 )
120134 bulk_sending_list
121135 end
136+ # Step 3-2 end
122137
138+ # Step 5-2 start
123139 def custom_fields ( bulk_list_id )
124140 text_custom_fields = DocuSign_eSign ::TextCustomField . new (
125141 name :'mailingListId' ,
@@ -132,7 +148,9 @@ def custom_fields(bulk_list_id)
132148 textCustomFields : [ text_custom_fields ]
133149 )
134150 end
151+ # Step 5-2 end
135152
153+ # Step 6-2 start
136154 def recipients_data
137155 signer = DocuSign_eSign ::Signer . new (
138156 name : "Multi Bulk Recipient::signer" ,
@@ -147,33 +165,23 @@ def recipients_data
147165 recipientType : "signer"
148166 )
149167
150- cc = DocuSign_eSign ::Signer . new (
168+ cc = DocuSign_eSign ::CarbonCopy . new (
151169 name : "Multi Bulk Recipient::cc" ,
152170 email : "multiBulkRecipients-cc@docusign.com" ,
153171 roleName : "cc" ,
154172 note : "" ,
155173 routingOrder : 1 ,
156174 status : "created" ,
157- templateAccessCodeRequired : "null" ,
158175 deliveryMethod : "email" ,
159176 recipientId : "2" ,
160- recipientType : "signer "
177+ recipientType : "cc "
161178 )
162- # The DocuSign platform searches throughout your envelope's documents for matching
163- # anchor strings. So the sign_here_2 tab will be used in both document 2 and 3
164- # since they use the same anchor string for their "signer 1" tabs.
165- sign_here = DocuSign_eSign ::SignHere . new
166- sign_here . anchor_string = '/sn1/'
167- sign_here . anchor_units = 'pixels'
168- sign_here . anchor_x_offset = '20'
169- sign_here . anchor_y_offset = '10'
170- # Tabs are set per recipient/signer
171- tabs = DocuSign_eSign ::Tabs . new
172- tabs . sign_here_tabs = [ sign_here ]
173- signer . tabs = tabs
179+
174180 [ signer , cc ]
175181 end
182+ # Step 6-2 end
176183
184+ # Step 4-2 start
177185 def make_envelope
178186 # Create the envelope definition
179187 envelope_definition = DocuSign_eSign ::EnvelopeDefinition . new
@@ -199,18 +207,18 @@ def make_envelope
199207 recipientType : "signer"
200208 )
201209
202- cc = DocuSign_eSign ::Signer . new (
210+ cc = DocuSign_eSign ::CarbonCopy . new (
203211 name : "Multi Bulk Recipient::cc" ,
204212 email : "multiBulkRecipients-cc@docusign.com" ,
205213 roleName : "cc" ,
206214 note : "" ,
207215 routingOrder : 1 ,
208216 status : "created" ,
209- templateAccessCodeRequired : "null" ,
210217 deliveryMethod : "email" ,
211218 recipientId : "2" ,
212- recipientType : "signer "
219+ recipientType : "cc "
213220 )
221+
214222 # The DocuSign platform searches throughout your envelope's documents for matching
215223 # anchor strings. So the sign_here_2 tab will be used in both document 2 and 3
216224 # since they use the same anchor string for their "signer 1" tabs.
@@ -223,9 +231,12 @@ def make_envelope
223231 tabs = DocuSign_eSign ::Tabs . new
224232 tabs . sign_here_tabs = [ sign_here ]
225233 signer . tabs = tabs
234+
226235 # Add the recipients to the envelope object
227- recipients = DocuSign_eSign ::Recipients . new
228- recipients . signers = [ signer , cc ]
236+ recipients = DocuSign_eSign ::Recipients . new (
237+ signers : [ signer ] ,
238+ carbonCopies : [ cc ]
239+ )
229240
230241 envelope_definition . recipients = recipients
231242 # The order in the docs array determines the order in the envelope
@@ -234,5 +245,6 @@ def make_envelope
234245 envelope_definition . status = "created"
235246 envelope_definition
236247 end
248+ # Step 4-2 end
237249
238250end
0 commit comments