docusign_rest 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +10 -0
- data/Rakefile +2 -0
- data/docusign_rest.gemspec +1 -0
- data/lib/docusign_rest/client.rb +293 -9
- data/lib/docusign_rest/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00bf2b5a6cfc048ecc6b0d597a35a572f47d99ad
|
4
|
+
data.tar.gz: 1cf63dc00aba24cbb32dd6fcf3413e849dc471c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bcfc024ec427a3316064a9d4f9acf2c16f53e1958fd7e6130090739e3a01f4adf457f6095cad3d9b81315dfcb3069c7194d7ea82d3f43887a420fc5dead59f4
|
7
|
+
data.tar.gz: c868fa3f68ac8c580a4133853b7ca86c4db3acaaaf4da563d72c98f7686e3193d5d8a54e21643e17f66ccbf2daa62babbb6d50ca4dda1f8afc8c4676c1895321
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.3.2 July 27 2017
|
4
|
+
|
5
|
+
* Implement DocusignRest::Client#update_signing_group_users (Pramod Chavan)
|
6
|
+
* Add support for signer id_check_information_input (Pramod Chavan)
|
7
|
+
* Add support for signer phone authentication (Pramod Chavan)
|
8
|
+
* Implement DocusignRest::Client#add_envelope_recipients (Pramod Chavan)
|
9
|
+
* Implement DocusignRest::Client#update_envelope_recipients (Pramod Chavan)
|
10
|
+
* Implement DocusignRest::Client#get_signing_groups (Pramod Chavan)
|
11
|
+
* Implement DocusignRest::Client#delete_signing_groups (Pramod Chavan)
|
12
|
+
* Implement DocusignRest::Client#create_signing_group (Lakshmi Narayana Chitturi)
|
13
|
+
* Fix parameter name type in DocusignRest::Client#void_envelope (Ryan Wood)
|
14
|
+
* Implement DocusignRest::Client#get_page_image (Tom Copeland)
|
15
|
+
|
3
16
|
## v0.3.1 May 16 2017
|
4
17
|
|
5
18
|
### Features:
|
data/README.md
CHANGED
@@ -344,6 +344,16 @@ client.get_document_from_envelope(
|
|
344
344
|
)
|
345
345
|
```
|
346
346
|
|
347
|
+
**Void an envelope**
|
348
|
+
|
349
|
+
```ruby
|
350
|
+
client = DocusignRest::Client.new
|
351
|
+
client.void_envelope(
|
352
|
+
envelope_id: @envelope_response["envelopeId"],
|
353
|
+
voided_reason: 'Reason provided by the user'
|
354
|
+
)
|
355
|
+
```
|
356
|
+
|
347
357
|
## Breaking out of the iframe after signing
|
348
358
|
|
349
359
|
In order to return to your application after the signing process is complete it's important to have a way to evaluate whether or not the signing was successful and then do something about each case. The way I set this up was to render the embedded signing iframe for a controller action called 'embedded_signing' and specify the return_url of the `client.get_recipient_view` API call to be something like: http://myapp.com/docusign_response. Then in the same controller as the embedded_signing method, define the docusign_response method. This is where the signing process will redirect to after the user is done interacting with the DocuSign iframe. DocuSign passes a query string parameter in the return_url named 'event' and you can check like so: `if params[:event] == "signing_complete"` then you'll want to redirect to another spot in your app, not in the iframe. To do so, we need to use JavaScript to access the iframe's parent and set it's location to the path of our choosing. To do this, instantiate the `DocusignRest::Utility` class and call the breakout_path method like this:
|
data/Rakefile
CHANGED
data/docusign_rest.gemspec
CHANGED
data/lib/docusign_rest/client.rb
CHANGED
@@ -330,24 +330,42 @@ module DocusignRest
|
|
330
330
|
|
331
331
|
signers.each_with_index do |signer, index|
|
332
332
|
doc_signer = {
|
333
|
-
email: signer[:email],
|
334
|
-
name: signer[:name],
|
335
333
|
accessCode: '',
|
336
334
|
addAccessCodeToEmail: false,
|
337
335
|
customFields: signer[:custom_fields],
|
338
|
-
|
339
|
-
|
336
|
+
idCheckConfigurationName: signer[:id_check_configuration_name],
|
337
|
+
idCheckInformationInput: nil,
|
340
338
|
inheritEmailNotificationConfiguration: false,
|
341
|
-
note:
|
339
|
+
note: signer[:note],
|
342
340
|
phoneAuthentication: nil,
|
343
341
|
recipientAttachment: nil,
|
344
|
-
|
345
|
-
requireIdLookup: false,
|
342
|
+
requireIdLookup: signer[:require_id_lookup],
|
346
343
|
roleName: signer[:role_name],
|
347
344
|
routingOrder: signer[:routing_order] || index + 1,
|
348
345
|
socialAuthentications: nil
|
349
346
|
}
|
350
347
|
|
348
|
+
recipient_id = signer[:recipient_id] || index + 1
|
349
|
+
doc_signer[:recipientId] = recipient_id
|
350
|
+
doc_signer[:clientUserId] = recipient_id if signer[:embedded_signing]
|
351
|
+
|
352
|
+
if signer[:id_check_information_input]
|
353
|
+
doc_signer[:idCheckInformationInput] =
|
354
|
+
get_id_check_information_input(signer[:id_check_information_input])
|
355
|
+
end
|
356
|
+
|
357
|
+
if signer[:phone_authentication]
|
358
|
+
doc_signer[:phoneAuthentication] =
|
359
|
+
get_phone_authentication(signer[:phone_authentication])
|
360
|
+
end
|
361
|
+
|
362
|
+
if signer[:signing_group_id]
|
363
|
+
doc_signer[:signingGroupId] = signer[:signing_group_id]
|
364
|
+
else
|
365
|
+
doc_signer[:email] = signer[:email]
|
366
|
+
doc_signer[:name] = signer[:name]
|
367
|
+
end
|
368
|
+
|
351
369
|
if signer[:email_notification]
|
352
370
|
doc_signer[:emailNotification] = signer[:email_notification]
|
353
371
|
end
|
@@ -729,6 +747,12 @@ module DocusignRest
|
|
729
747
|
def create_envelope_from_document(options={})
|
730
748
|
ios = create_file_ios(options[:files])
|
731
749
|
file_params = create_file_params(ios)
|
750
|
+
recipients = if options[:certified_deliveries].nil? || options[:certified_deliveries].empty?
|
751
|
+
{ signers: get_signers(options[:signers]) }
|
752
|
+
else
|
753
|
+
{ certifiedDeliveries: get_signers(options[:certified_deliveries]) }
|
754
|
+
end
|
755
|
+
|
732
756
|
|
733
757
|
post_hash = {
|
734
758
|
emailBlurb: "#{options[:email][:body] if options[:email]}",
|
@@ -1159,6 +1183,27 @@ module DocusignRest
|
|
1159
1183
|
end
|
1160
1184
|
|
1161
1185
|
|
1186
|
+
# Public retrieves a png of a page of a document in an envelope
|
1187
|
+
#
|
1188
|
+
# envelope_id - ID of the envelope from which the doc will be retrieved
|
1189
|
+
# document_id - ID of the document to retrieve
|
1190
|
+
# page_number - page number to retrieve
|
1191
|
+
#
|
1192
|
+
# Returns the png as a bytestream
|
1193
|
+
def get_page_image(options={})
|
1194
|
+
envelope_id = options[:envelope_id]
|
1195
|
+
document_id = options[:document_id]
|
1196
|
+
page_number = options[:page_number]
|
1197
|
+
|
1198
|
+
uri = build_uri("/accounts/#{acct_id}/envelopes/#{envelope_id}/documents/#{document_id}/pages/#{page_number}/page_image")
|
1199
|
+
|
1200
|
+
http = initialize_net_http_ssl(uri)
|
1201
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
1202
|
+
response = http.request(request)
|
1203
|
+
generate_log(request, response, uri)
|
1204
|
+
response.body
|
1205
|
+
end
|
1206
|
+
|
1162
1207
|
# Public retrieves the attached file from a given envelope
|
1163
1208
|
#
|
1164
1209
|
# envelope_id - ID of the envelope from which the doc will be retrieved
|
@@ -1518,7 +1563,7 @@ module DocusignRest
|
|
1518
1563
|
"voidedReason" => options[:voided_reason] || "No reason provided."
|
1519
1564
|
}.to_json
|
1520
1565
|
|
1521
|
-
uri = build_uri("/accounts/#{acct_id}/envelopes/#{options[:
|
1566
|
+
uri = build_uri("/accounts/#{acct_id}/envelopes/#{options[:envelope_id]}")
|
1522
1567
|
|
1523
1568
|
http = initialize_net_http_ssl(uri)
|
1524
1569
|
request = Net::HTTP::Put.new(uri.request_uri, headers(content_type))
|
@@ -1656,7 +1701,31 @@ module DocusignRest
|
|
1656
1701
|
content_type.merge(options[:headers]) if options[:headers]
|
1657
1702
|
|
1658
1703
|
uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients/#{options[:recipient_id]}/tabs")
|
1659
|
-
|
1704
|
+
tabs = options[:tabs]
|
1705
|
+
index = options[:recipient_id] - 1
|
1706
|
+
|
1707
|
+
post_body = {
|
1708
|
+
approveTabs: nil,
|
1709
|
+
checkboxTabs: nil,
|
1710
|
+
companyTabs: nil,
|
1711
|
+
dateSignedTabs: get_tabs(tabs[:date_signed_tabs], options, index),
|
1712
|
+
dateTabs: nil,
|
1713
|
+
declineTabs: nil,
|
1714
|
+
emailTabs: nil,
|
1715
|
+
envelopeIdTabs: nil,
|
1716
|
+
fullNameTabs: nil,
|
1717
|
+
listTabs: nil,
|
1718
|
+
noteTabs: nil,
|
1719
|
+
numberTabs: nil,
|
1720
|
+
radioGroupTabs: nil,
|
1721
|
+
initialHereTabs: get_tabs(tabs[:initial_here_tabs], options.merge!(initial_here_tab: true), index),
|
1722
|
+
signHereTabs: get_tabs(tabs[:sign_here_tabs], options.merge!(sign_here_tab: true), index),
|
1723
|
+
signerAttachmentTabs: nil,
|
1724
|
+
ssnTabs: nil,
|
1725
|
+
textTabs: nil,
|
1726
|
+
titleTabs: nil,
|
1727
|
+
zipTabs: nil
|
1728
|
+
}.to_json
|
1660
1729
|
|
1661
1730
|
http = initialize_net_http_ssl(uri)
|
1662
1731
|
request = Net::HTTP::Post.new(uri.request_uri, headers(content_type))
|
@@ -1667,6 +1736,169 @@ module DocusignRest
|
|
1667
1736
|
JSON.parse(response.body)
|
1668
1737
|
end
|
1669
1738
|
|
1739
|
+
# Public method - Creates Signing group
|
1740
|
+
# group_name: The display name for the signing group. This can be a maximum of 100 characters.
|
1741
|
+
# users: An array of group members for the signing group. (see example below)
|
1742
|
+
# It is composed of two elements:
|
1743
|
+
# name – The name for the group member. This can be a maximum of 100 characters.
|
1744
|
+
# email – The email address for the group member. This can be a maximum of 100 characters.
|
1745
|
+
# [
|
1746
|
+
# {name: 'test1', email: 'test1@ygrene.us'}
|
1747
|
+
# {name: 'test2', email: 'test2@ygrene.us'}
|
1748
|
+
# ]
|
1749
|
+
#
|
1750
|
+
#
|
1751
|
+
# The response returns a success or failure with any error messages.
|
1752
|
+
# For successes DocuSign generates a signingGroupId for each group, which is included in the response.
|
1753
|
+
# The response also includes information about when the group was created and modified,
|
1754
|
+
# including the account user that created and modified the group.
|
1755
|
+
def create_signing_group(options={})
|
1756
|
+
content_type = { 'Content-Type' => 'application/json' }
|
1757
|
+
content_type.merge(options[:headers]) if options[:headers]
|
1758
|
+
|
1759
|
+
group_users = []
|
1760
|
+
if options[:users]
|
1761
|
+
options[:users].each do |user|
|
1762
|
+
group_users << {
|
1763
|
+
userName: user[:name],
|
1764
|
+
email: user[:email]
|
1765
|
+
}
|
1766
|
+
end
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
post_body = {
|
1770
|
+
groups: [
|
1771
|
+
{
|
1772
|
+
groupName: options[:group_name],
|
1773
|
+
groupType: 'sharedSigningGroup',
|
1774
|
+
users: group_users
|
1775
|
+
}
|
1776
|
+
]
|
1777
|
+
}.to_json
|
1778
|
+
|
1779
|
+
uri = build_uri("/accounts/#{@acct_id}/signing_groups")
|
1780
|
+
|
1781
|
+
http = initialize_net_http_ssl(uri)
|
1782
|
+
|
1783
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers(content_type))
|
1784
|
+
request.body = post_body
|
1785
|
+
|
1786
|
+
response = http.request(request)
|
1787
|
+
|
1788
|
+
JSON.parse(response.body)
|
1789
|
+
end
|
1790
|
+
|
1791
|
+
# Public method - deletes a signing group
|
1792
|
+
# See https://docs.docusign.com/esign/restapi/SigningGroups/SigningGroups/delete/
|
1793
|
+
#
|
1794
|
+
# signingGroupId - ID of the signing group to delete
|
1795
|
+
#
|
1796
|
+
# Returns the success or failure of each group being deleted. Failed operations on array elements will add the "errorDetails"
|
1797
|
+
# structure containing an error code and message. If "errorDetails" is null, then
|
1798
|
+
# the operation was successful for that item.
|
1799
|
+
def delete_signing_groups(options={})
|
1800
|
+
content_type = {'Content-Type' => 'application/json'}
|
1801
|
+
content_type.merge!(options[:headers]) if options[:headers]
|
1802
|
+
|
1803
|
+
uri = build_uri("/accounts/#{@acct_id}/signing_groups")
|
1804
|
+
|
1805
|
+
groups = options[:groups]
|
1806
|
+
groups.each{|h| h[:signingGroupId] = h.delete(:signing_group_id) if h.key?(:signing_group_id)}
|
1807
|
+
post_body = {
|
1808
|
+
groups: groups
|
1809
|
+
}.to_json
|
1810
|
+
|
1811
|
+
http = initialize_net_http_ssl(uri)
|
1812
|
+
request = Net::HTTP::Delete.new(uri.request_uri, headers(content_type))
|
1813
|
+
request.body = post_body
|
1814
|
+
|
1815
|
+
response = http.request(request)
|
1816
|
+
JSON.parse(response.body)
|
1817
|
+
end
|
1818
|
+
|
1819
|
+
# Public method - updates signing group users
|
1820
|
+
# See https://docs.docusign.com/esign/restapi/SigningGroups/SigningGroupUsers/update/
|
1821
|
+
#
|
1822
|
+
# signingGroupId - ID of the signing group to update
|
1823
|
+
#
|
1824
|
+
# Returns the success or failure of each user being updated. Failed operations on array elements will add the "errorDetails"
|
1825
|
+
# structure containing an error code and message. If "errorDetails" is null, then
|
1826
|
+
# the operation was successful for that item.
|
1827
|
+
def update_signing_group_users(options={})
|
1828
|
+
content_type = {'Content-Type' => 'application/json'}
|
1829
|
+
content_type.merge!(options[:headers]) if options[:headers]
|
1830
|
+
|
1831
|
+
uri = build_uri("/accounts/#{@acct_id}/signing_groups/#{options[:signing_group_id]}/users")
|
1832
|
+
|
1833
|
+
users = options[:users]
|
1834
|
+
users.each do |user|
|
1835
|
+
user[:userName] = user.delete(:user_name) if user.key?(:user_name)
|
1836
|
+
end
|
1837
|
+
post_body = {
|
1838
|
+
users: users
|
1839
|
+
}.to_json
|
1840
|
+
|
1841
|
+
http = initialize_net_http_ssl(uri)
|
1842
|
+
request = Net::HTTP::Put.new(uri.request_uri, headers(content_type))
|
1843
|
+
request.body = post_body
|
1844
|
+
|
1845
|
+
response = http.request(request)
|
1846
|
+
JSON.parse(response.body)
|
1847
|
+
end
|
1848
|
+
|
1849
|
+
# Public: Retrieves a list of available signing groups
|
1850
|
+
def get_signing_groups
|
1851
|
+
uri = build_uri("/accounts/#{@acct_id}/signing_groups")
|
1852
|
+
|
1853
|
+
http = initialize_net_http_ssl(uri)
|
1854
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers({ 'Content-Type' => 'application/json' }))
|
1855
|
+
JSON.parse(http.request(request).body)
|
1856
|
+
end
|
1857
|
+
|
1858
|
+
# Public: Update envelope recipients
|
1859
|
+
def update_envelope_recipients(options={})
|
1860
|
+
content_type = {'Content-Type' => 'application/json'}
|
1861
|
+
content_type.merge(options[:headers]) if options[:headers]
|
1862
|
+
|
1863
|
+
resend = options[:resend].present?
|
1864
|
+
uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients?resend_envelope=#{resend}")
|
1865
|
+
|
1866
|
+
signers = options[:signers]
|
1867
|
+
signers.each do |signer|
|
1868
|
+
signer[:recipientId] = signer.delete(:recipient_id) if signer.key?(:recipient_id)
|
1869
|
+
signer[:clientUserId] = signer.delete(:client_user_id) if signer.key?(:client_user_id)
|
1870
|
+
end
|
1871
|
+
post_body = {
|
1872
|
+
signers: signers
|
1873
|
+
}.to_json
|
1874
|
+
|
1875
|
+
http = initialize_net_http_ssl(uri)
|
1876
|
+
request = Net::HTTP::Put.new(uri.request_uri, headers(content_type))
|
1877
|
+
request.body = post_body
|
1878
|
+
|
1879
|
+
response = http.request(request)
|
1880
|
+
JSON.parse(response.body)
|
1881
|
+
end
|
1882
|
+
|
1883
|
+
# Public: Add recipients to envelope
|
1884
|
+
def add_envelope_recipients(options={})
|
1885
|
+
content_type = {'Content-Type' => 'application/json'}
|
1886
|
+
content_type.merge(options[:headers]) if options[:headers]
|
1887
|
+
|
1888
|
+
uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients?resend_envelope=true")
|
1889
|
+
|
1890
|
+
post_body = {
|
1891
|
+
signers: get_signers(options[:signers])
|
1892
|
+
}.to_json
|
1893
|
+
|
1894
|
+
http = initialize_net_http_ssl(uri)
|
1895
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers(content_type))
|
1896
|
+
request.body = post_body
|
1897
|
+
|
1898
|
+
response = http.request(request)
|
1899
|
+
JSON.parse(response.body)
|
1900
|
+
end
|
1901
|
+
|
1670
1902
|
private
|
1671
1903
|
|
1672
1904
|
# Private: Generates a standardized log of the request and response pair
|
@@ -1690,5 +1922,57 @@ module DocusignRest
|
|
1690
1922
|
log << "Body: #{response.body}"
|
1691
1923
|
@previous_call_log = log
|
1692
1924
|
end
|
1925
|
+
|
1926
|
+
def get_id_check_information_input(input)
|
1927
|
+
{
|
1928
|
+
addressInformationInput: get_address_information_input(
|
1929
|
+
input.dig(:address_information_input, :address_information)),
|
1930
|
+
ssn4InformationInput: get_ssn4_information_input(input[:ssn4_information_input]),
|
1931
|
+
dobInformationInput: get_dob_information_input(input[:dob_information_input])
|
1932
|
+
}
|
1933
|
+
end
|
1934
|
+
|
1935
|
+
def get_address_information_input(input)
|
1936
|
+
return {} unless input
|
1937
|
+
{
|
1938
|
+
addressInformation:{
|
1939
|
+
street1: input[:street1],
|
1940
|
+
city: input[:city],
|
1941
|
+
state: input[:state],
|
1942
|
+
zip: input[:zip],
|
1943
|
+
zipPlus4: input[:zip_plus4],
|
1944
|
+
},
|
1945
|
+
displayLevelCode: 'DoNotDisplay',
|
1946
|
+
receiveInResponse: true,
|
1947
|
+
}
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
def get_phone_authentication(input)
|
1951
|
+
return {} unless input
|
1952
|
+
{
|
1953
|
+
recipMayProvideNumber: true,
|
1954
|
+
validateRecipProvidedNumber: true,
|
1955
|
+
recordVoicePrint: true,
|
1956
|
+
senderProvidedNumbers: input[:sender_provided_numbers],
|
1957
|
+
}
|
1958
|
+
end
|
1959
|
+
|
1960
|
+
def get_ssn4_information_input(input)
|
1961
|
+
return {} unless input
|
1962
|
+
{
|
1963
|
+
ssn4: input[:ssn4],
|
1964
|
+
displayLevelCode: 'DoNotDisplay',
|
1965
|
+
receiveInResponse: true,
|
1966
|
+
}
|
1967
|
+
end
|
1968
|
+
|
1969
|
+
def get_dob_information_input(input)
|
1970
|
+
return {} unless input
|
1971
|
+
{
|
1972
|
+
dateOfBirth: input[:date_of_birth],
|
1973
|
+
displayLevelCode: 'DoNotDisplay',
|
1974
|
+
receiveInResponse: true,
|
1975
|
+
}
|
1976
|
+
end
|
1693
1977
|
end
|
1694
1978
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docusign_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Kinney
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multipart-post
|
@@ -151,6 +151,20 @@ dependencies:
|
|
151
151
|
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: safe_yaml
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
154
168
|
description: Hooks a Rails app up to the DocuSign service through the DocuSign REST
|
155
169
|
API
|
156
170
|
email:
|