Skip to content

Commit 6b71374

Browse files
Merge branch 'master' of github.com:docusign/code-examples-ruby-private
2 parents bf401e7 + 75b2159 commit 6b71374

File tree

4 files changed

+61
-48
lines changed

4 files changed

+61
-48
lines changed

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ group :test do
6666
gem 'chromedriver-helper', '~> 2.1.1'
6767
end
6868

69-
gem 'docusign_esign', '~> 3.10.0.rc1'
69+
gem 'docusign_esign', '~> 3.13.0.rc1'
7070
gem 'docusign_monitor', '~> 1.0.0'
71-
gem 'docusign_rooms', '~> 1.1.0.rc1'
71+
gem 'docusign_rooms', '~> 1.2.0.rc1'
7272
gem 'docusign_click', '~> 1.0.0'
73-
gem 'docusign_admin', '~> 1.0.0.beta'
73+
gem 'docusign_admin', '~> 1.0.0'
7474
gem 'omniauth-oauth2', '~> 1.7.1'
7575
gem 'omniauth-rails_csrf_protection'
7676

Gemfile.lock

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ GEM
8787
coffee-script-source (1.12.2)
8888
concurrent-ruby (1.1.9)
8989
crass (1.0.6)
90-
docusign_admin (1.0.0.beta)
90+
docusign_admin (1.0.0)
91+
addressable (~> 2.7, >= 2.7.0)
9192
json (~> 2.1, >= 2.1.0)
9293
jwt (~> 2.2, >= 2.2.1)
9394
typhoeus (~> 1.0, >= 1.0.1)
@@ -96,7 +97,8 @@ GEM
9697
json (~> 2.1, >= 2.1.0)
9798
jwt (~> 2.2, >= 2.2.1)
9899
typhoeus (~> 1.0, >= 1.0.1)
99-
docusign_esign (3.10.0)
100+
docusign_esign (3.13.0.rc1)
101+
addressable (~> 2.7, >= 2.7.0)
100102
json (~> 2.1, >= 2.1.0)
101103
jwt (~> 2.2, >= 2.2.1)
102104
typhoeus (~> 1.0, >= 1.0.1)
@@ -105,7 +107,8 @@ GEM
105107
json (~> 2.1, >= 2.1.0)
106108
jwt (~> 2.2, >= 2.2.1)
107109
typhoeus (~> 1.0, >= 1.0.1)
108-
docusign_rooms (1.1.0)
110+
docusign_rooms (1.2.0.rc1)
111+
addressable (~> 2.7, >= 2.7.0)
109112
json (~> 2.1, >= 2.1.0)
110113
jwt (~> 2.2, >= 2.2.1)
111114
typhoeus (~> 1.0, >= 1.0.1)
@@ -288,11 +291,11 @@ DEPENDENCIES
288291
capybara (~> 3.31.0)
289292
chromedriver-helper (~> 2.1.1)
290293
coffee-rails (~> 5.0.0)
291-
docusign_admin (~> 1.0.0.beta)
294+
docusign_admin (~> 1.0.0)
292295
docusign_click (~> 1.0.0)
293-
docusign_esign (~> 3.10.0.rc1)
296+
docusign_esign (~> 3.13.0.rc1)
294297
docusign_monitor (~> 1.0.0)
295-
docusign_rooms (~> 1.1.0.rc1)
298+
docusign_rooms (~> 1.2.0.rc1)
296299
jbuilder (~> 2.10.0)
297300
listen (~> 3.2.1)
298301
omniauth-oauth2 (~> 1.7.1)

app/services/e_sign/eg031_bulk_sending_envelopes_service.rb

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

238250
end

app/views/e_sign/eg031_bulk_sending_envelopes/get.html.erb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<h4>31. Bulk sending envelopes to multiple recipients</h4>
22

33
<p>
4-
Method BulkSend:createBulkSendList creates a bulk list that you can to use an envelope to up
4+
Method BulkSend:createBulkSendList creates a bulk list that you can to use an envelope to up
55
to 1,000 recipients at once.
66
</p>
77

88
<p>API method used:
99
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipients/create/">EnvelopeRecipients::create</a>,
10-
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>,
10+
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>,
1111
<a target='_blank' href="https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkEnvelopes/get">BulkEnvelopes::get</a>,
1212
<a target='_blank' href="https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeCustomFields/create">EnvelopeCustomFields::create</a>,
1313
<a target='_blank' href="https://support.docusign.com/en/guides/ndse-user-guide-create-a-bulk-send-recipient-list">BulkSend::createBulkSendList</a>,
@@ -24,13 +24,12 @@
2424
<div class="form-group">
2525
<label for="signerEmail">Signer Email</label>
2626
<input type="email" class="form-control" id="signerEmail" name="signerEmail"
27-
aria-describedby="emailHelp" placeholder="pat@example.com" required
28-
value="<%= @config.signer_email %>">
27+
aria-describedby="emailHelp" placeholder="pat@example.com" required>
2928
</div>
3029
<div class="form-group">
3130
<label for="signerName">Signer Name</label>
3231
<input type="text" class="form-control" id="signerName" placeholder="Pat Johnson" name="signerName"
33-
value="<%= @config.signer_name %>" required>
32+
required>
3433
</div>
3534
</div>
3635
<div class="your-class">
@@ -51,13 +50,12 @@
5150
<div class="form-group">
5251
<label for="signerEmail1">Signer Email</label>
5352
<input type="email" class="form-control" id="signerEmail1" name="signerEmail1"
54-
aria-describedby="emailHelp" placeholder="pat@example.com" required
55-
value="<%= @config.signer_email %>">
53+
aria-describedby="emailHelp" placeholder="pat@example.com" required>
5654
</div>
5755
<div class="form-group">
5856
<label for="signerName1">Signer Name</label>
5957
<input type="text" class="form-control" id="signerName1" placeholder="Pat Johnson" name="signerName1"
60-
value="<%= @config.signer_name %>" required>
58+
required>
6159
</div>
6260
</div>
6361
<div class="your-class">
@@ -73,4 +71,4 @@
7371
</div>
7472
</div>
7573
<button type="submit" class="btn btn-docu">Submit</button>
76-
</form>
74+
</form>

0 commit comments

Comments
 (0)