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

Allow to assign accessCode to signers #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/docusign_rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def get_template_roles(signers)
name: signer[:name],
email: signer[:email],
roleName: signer[:role_name],
accessCode: signer[:access_code],
tabs: {
textTabs: get_signer_tabs(signer[:text_tabs]),
checkboxTabs: get_signer_tabs(signer[:checkbox_tabs]),
Expand Down Expand Up @@ -343,7 +344,7 @@ def get_signers(signers, options={})

signers.each_with_index do |signer, index|
doc_signer = {
accessCode: '',
accessCode: signer[:access_code],
addAccessCodeToEmail: false,
customFields: signer[:custom_fields],
idCheckConfigurationName: signer[:id_check_configuration_name],
Expand Down
184 changes: 102 additions & 82 deletions test/docusign_rest/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,61 @@
@keys = DocusignRest::Configuration::VALID_CONFIG_KEYS
end

let(:embedded_signers) {
[
{
embedded: true,
name: 'Test Guy',
email: 'testguy@example.com',
role_name: 'Issuer',
sign_here_tabs: [
{
anchor_string: 'sign here',
anchor_x_offset: '125',
anchor_y_offset: '-12'
}
],
list_tabs: [
{
anchor_string: 'another test',
width: '180',
height: '14',
anchor_x_offset: '10',
anchor_y_offset: '-5',
label: 'another test',
selected: true,
list_items: [
{
selected: false,
text: 'Option 1',
value: 'option_1'
},
{
selected: true,
text: 'Option 2',
value: 'option_2'
}
]
}
],
},
{
embedded: true,
name: 'Test Girl',
email: 'testgirl@example.com',
role_name: 'Attorney',
access_code: '12345',
sign_here_tabs: [
{
anchor_string: 'sign here',
anchor_x_offset: '140',
anchor_y_offset: '-12'
}
]
}
]
}

describe 'with module configuration' do
before do
DocusignRest.configure do |config|
Expand Down Expand Up @@ -88,82 +143,54 @@
@client.get_account_id.must_equal @client.acct_id
end

it "should allow creating an envelope from a document" do
VCR.use_cassette("create_envelope/from_document") do
response = @client.create_envelope_from_document(
email: {
subject: "test email subject",
body: "this is the email body and it's large!"
},
# If embedded is set to true in the signers array below, emails
# don't go out and you can embed the signature page in an iFrame
# by using the get_recipient_view method. You can choose 'false' or
# simply omit the option as I show in the second signer hash.
signers: [
{
embedded: true,
name: 'Test Guy',
email: 'testguy@example.com',
role_name: 'Issuer',
sign_here_tabs: [
{
anchor_string: 'sign here',
anchor_x_offset: '125',
anchor_y_offset: '-12'
}
],
list_tabs: [
{
anchor_string: 'another test',
width: '180',
height: '14',
anchor_x_offset: '10',
anchor_y_offset: '-5',
label: 'another test',
selected: true,
list_items: [
{
selected: false,
text: 'Option 1',
value: 'option_1'
},
{
selected: true,
text: 'Option 2',
value: 'option_2'
}
]
}
],
describe "#get_signers" do
before do
@doc_signers = @client.get_signers(embedded_signers)
end

it "returns an array of signers" do
@doc_signers.length.must_equal embedded_signers.length
end

it "assigns accessCode" do
embedded_signers.each do |signer|
doc_signer = @doc_signers.select{ |s| s[:email] == signer[:email]}.first
doc_signer[:accessCode].must_equal signer[:access_code]
end
end
end

describe "#create_envelope_from_document" do
before do
VCR.use_cassette("create_envelope/from_document") do
@response = @client.create_envelope_from_document(
email: {
subject: "test email subject",
body: "this is the email body and it's large!"
},
{
embedded: true,
name: 'Test Girl',
email: 'testgirl@example.com',
role_name: 'Attorney',
sign_here_tabs: [
{
anchor_string: 'sign here',
anchor_x_offset: '140',
anchor_y_offset: '-12'
}
]
}
],
files: [
{path: 'test.pdf', name: 'test.pdf'},
{path: 'test2.pdf', name: 'test2.pdf'}
],
status: 'sent',
email_settings: {
bcc_emails: [
"test@example.com"
# If embedded is set to true in the signers array below, emails
# don't go out and you can embed the signature page in an iFrame
# by using the get_recipient_view method. You can choose 'false' or
# simply omit the option as I show in the second signer hash.
signers: embedded_signers,
files: [
{path: 'test.pdf', name: 'test.pdf'},
{path: 'test2.pdf', name: 'test2.pdf'}
],
reply_to_email: "test@example.com",
reply_to_name: "Tester"
}
)
response["status"].must_equal "sent"
status: 'sent',
email_settings: {
bcc_emails: [
"test@example.com"
],
reply_to_email: "test@example.com",
reply_to_name: "Tester"
}
)
end
end

it "should allow creating an envelope from a document" do
@response["status"].must_equal "sent"
end
end

Expand Down Expand Up @@ -331,14 +358,7 @@ def create_signing_group
body: "Envelope body content here"
},
template_id: @template_response["templateId"],
signers: [
{
embedded: true,
name: 'jon',
email: 'someone@example.com',
role_name: 'Issuer'
}
]
signers: embedded_signers
)
if ! @envelope_response["errorCode"].nil?
puts "[API ERROR] (create_envelope/from_template) errorCode: '#{@envelope_response["errorCode"]}', message: '#{@envelope_response["message"]}'"
Expand Down