Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support carbon copies in create_envelope_from_composite_template #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions lib/docusign_rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def get_documents(ios)
# Takes an optional array of files, which consist of documents to be used instead of templates
#
# Returns an array of server template hashes
def get_composite_template(server_template_ids, signers, files)
def get_composite_template(server_template_ids, signers, files, carbon_copies)
composite_array = []
server_template_ids.each_with_index do |template_id, idx|
server_template_hash = {
Expand All @@ -643,7 +643,7 @@ def get_composite_template(server_template_ids, signers, files)
}
templates_hash = {
serverTemplates: [server_template_hash],
inlineTemplates: get_inline_signers(signers, (idx+1).to_s)
inlineTemplates: get_inline_signers(signers, (idx+1).to_s, carbon_copies)
}
if files
document_hash = {
Expand All @@ -662,10 +662,9 @@ def get_composite_template(server_template_ids, signers, files)
# and sets up the inline template
#
# Returns an array of signers
def get_inline_signers(signers, sequence)
signers_array = []
signers.each do |signer|
signers_hash = {
def get_inline_signers(signers, sequence, carbon_copies)
signers_array = signers.map do |signer|
{
email: signer[:email],
name: signer[:name],
recipientId: signer[:recipient_id],
Expand All @@ -682,9 +681,14 @@ def get_inline_signers(signers, sequence)
signHereTabs: get_sign_here_tabs(signer[:sign_here_tabs])
}
}
signers_array << signers_hash
end
template_hash = {sequence: sequence, recipients: { signers: signers_array }}
template_hash = {
sequence: sequence,
recipients: {
signers: signers_array,
carbonCopies: get_carbon_copies(carbon_copies, signers.size)
}
}
[template_hash]
end

Expand Down Expand Up @@ -961,7 +965,7 @@ def create_envelope_from_composite_template(options={})
brandId: options[:brand_id],
eventNotification: get_event_notification(options[:event_notification]),
allowReassign: options[:allow_reassign],
compositeTemplates: get_composite_template(options[:server_template_ids], options[:signers], options[:files])
compositeTemplates: get_composite_template(options[:server_template_ids], options[:signers], options[:files], options[:carbon_copies])
}

post_body = post_hash.to_json
Expand Down