echosign 1.0.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +14 -0
- data/.rubocop_todo.yml +241 -0
- data/.simplecov +2 -0
- data/.travis.yml +9 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +74 -48
- data/README.md +43 -8
- data/Rakefile +2 -2
- data/doc/Echosign.html +135 -0
- data/doc/Echosign/Agreement.html +545 -0
- data/doc/Echosign/Client.html +5365 -0
- data/doc/Echosign/CounterSignerInfo.html +267 -0
- data/doc/Echosign/Credentials.html +1053 -0
- data/doc/Echosign/Fileinfo.html +305 -0
- data/doc/Echosign/FormFieldLocation.html +264 -0
- data/doc/Echosign/MegaSign.html +533 -0
- data/doc/Echosign/ParameterError.html +124 -0
- data/doc/Echosign/PhoneInfo.html +281 -0
- data/doc/Echosign/Recipient.html +311 -0
- data/doc/Echosign/RecipientSecurityOption.html +296 -0
- data/doc/Echosign/Refresh.html +288 -0
- data/doc/Echosign/Reminder.html +279 -0
- data/doc/Echosign/Request.html +5289 -0
- data/doc/Echosign/Request/EndpointHash.html +328 -0
- data/doc/Echosign/Request/Failure.html +290 -0
- data/doc/Echosign/RequestFormField.html +244 -0
- data/doc/Echosign/RequiredParameterError.html +124 -0
- data/doc/Echosign/UrlFileInfo.html +297 -0
- data/doc/Echosign/User.html +422 -0
- data/doc/Echosign/Validatable.html +355 -0
- data/doc/Echosign/Widget.html +924 -0
- data/doc/Echosign/WidgetCompletionInfo.html +323 -0
- data/doc/Echosign/WidgetPersonalization.html +330 -0
- data/doc/Echosign/WidgetSecurityOption.html +361 -0
- data/doc/Echosign/WidgetSignerSecurityOption.html +298 -0
- data/doc/Echosign/WidgetStatus.html +316 -0
- data/doc/Echosign/WidgetVaultingInfo.html +267 -0
- data/doc/_index.html +378 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +191 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +191 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1035 -0
- data/doc/top-level-namespace.html +110 -0
- data/echosign.gemspec +18 -20
- data/features/support/env.rb +8 -8
- data/fixtures/vcr_cassettes/agreement_combined_pdf.yml +2 -2
- data/fixtures/vcr_cassettes/agreement_document_file.yml +1 -1
- data/fixtures/vcr_cassettes/agreement_documents.yml +2 -2
- data/fixtures/vcr_cassettes/agreement_form_data.yml +1 -1
- data/fixtures/vcr_cassettes/agreement_info.yml +1 -1
- data/fixtures/vcr_cassettes/agreement_signing_urls.yml +1 -1
- data/fixtures/vcr_cassettes/audit_trail_pdf.yml +1 -1
- data/fixtures/vcr_cassettes/cancel_agreement.yml +1 -1
- data/fixtures/vcr_cassettes/create_agreement.yml +1 -1
- data/fixtures/vcr_cassettes/create_reminder.yml +1 -1
- data/fixtures/vcr_cassettes/create_transient_document.yml +1 -1
- data/fixtures/vcr_cassettes/create_user.yml +1 -1
- data/fixtures/vcr_cassettes/create_widget.yml +1 -1
- data/fixtures/vcr_cassettes/get_agreements.yml +1 -1
- data/fixtures/vcr_cassettes/get_library_document.yml +1 -1
- data/fixtures/vcr_cassettes/get_library_document_data.yml +1 -1
- data/fixtures/vcr_cassettes/get_library_document_file.yml +1 -1
- data/fixtures/vcr_cassettes/get_library_documents.yml +1 -1
- data/fixtures/vcr_cassettes/get_token.yml +22 -20
- data/fixtures/vcr_cassettes/get_user.yml +1 -1
- data/fixtures/vcr_cassettes/get_users.yml +2 -2
- data/fixtures/vcr_cassettes/get_widget.yml +1 -1
- data/fixtures/vcr_cassettes/get_widget_document_file.yml +1 -1
- data/fixtures/vcr_cassettes/get_widget_documents.yml +1 -1
- data/fixtures/vcr_cassettes/get_widgets.yml +1 -1
- data/fixtures/vcr_cassettes/library_combined_document.yml +2 -2
- data/fixtures/vcr_cassettes/library_document_audit_trail.yml +1 -1
- data/fixtures/vcr_cassettes/personalize_widget.yml +1 -1
- data/fixtures/vcr_cassettes/refresh_token.yml +46 -0
- data/fixtures/vcr_cassettes/revoke_token.yml +44 -0
- data/fixtures/vcr_cassettes/update_widget_status.yml +1 -1
- data/lib/echosign.rb +11 -11
- data/lib/echosign/agreement.rb +26 -10
- data/lib/echosign/agreement/client.rb +111 -104
- data/lib/echosign/agreement/fileinfo.rb +1 -3
- data/lib/echosign/agreement/form_field_location.rb +2 -3
- data/lib/echosign/agreement/phone_info.rb +5 -5
- data/lib/echosign/agreement/recipient.rb +9 -8
- data/lib/echosign/agreement/recipient_security_option.rb +5 -4
- data/lib/echosign/agreement/request.rb +33 -43
- data/lib/echosign/agreement/request_form_field.rb +2 -3
- data/lib/echosign/agreement/url_file_info.rb +8 -6
- data/lib/echosign/client.rb +33 -24
- data/lib/echosign/credentials.rb +95 -24
- data/lib/echosign/library_documents/client.rb +18 -23
- data/lib/echosign/library_documents/request.rb +19 -20
- data/lib/echosign/mega_sign.rb +20 -10
- data/lib/echosign/mega_sign/client.rb +109 -104
- data/lib/echosign/mega_sign/request.rb +32 -43
- data/lib/echosign/refresh.rb +6 -10
- data/lib/echosign/reminder.rb +2 -2
- data/lib/echosign/request.rb +85 -75
- data/lib/echosign/user.rb +13 -7
- data/lib/echosign/validatable.rb +6 -10
- data/lib/echosign/version.rb +1 -1
- data/lib/echosign/widget.rb +53 -27
- data/lib/echosign/widget/client.rb +33 -36
- data/lib/echosign/widget/counter_signer_info.rb +4 -5
- data/lib/echosign/widget/request.rb +28 -52
- data/lib/echosign/widget/widget_completion_info.rb +22 -12
- data/lib/echosign/widget/widget_personalization.rb +9 -7
- data/lib/echosign/widget/widget_security_option.rb +21 -11
- data/lib/echosign/widget/widget_signer_security_option.rb +8 -6
- data/lib/echosign/widget/widget_status.rb +10 -8
- data/lib/echosign/widget/widget_vaulting_info.rb +4 -5
- data/spec/lib/agreement/client_spec.rb +25 -31
- data/spec/lib/client_spec.rb +15 -18
- data/spec/lib/credentials_spec.rb +48 -0
- data/spec/lib/library_documents/client_spec.rb +11 -15
- data/spec/lib/shared_client.rb +9 -16
- data/spec/lib/user_spec.rb +0 -2
- data/spec/lib/validatable_spec.rb +12 -18
- data/spec/lib/version_spec.rb +1 -1
- data/spec/lib/widget/client_spec.rb +46 -49
- data/spec/spec_helper.rb +12 -5
- metadata +125 -60
- data/spec/lib/request_spec.rb +0 -18
@@ -1,9 +1,8 @@
|
|
1
1
|
module Echosign
|
2
2
|
class Fileinfo < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
|
-
# Validates Fileinfo params
|
5
|
+
# Validates Fileinfo params
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash containing exactly one of the following:
|
9
8
|
# @option params [String] :transientDocumentId A transient document ID available to the sender
|
@@ -17,4 +16,3 @@ module Echosign
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Echosign
|
2
2
|
class FormFieldLocation < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
|
-
# Validates FormFieldLocation params
|
5
|
+
# Validates FormFieldLocation params
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash containing exactly one of the following:
|
9
8
|
# @option param [Integer] height (double): Height of the form field in pixels,
|
@@ -17,4 +16,4 @@ module Echosign
|
|
17
16
|
merge!(params)
|
18
17
|
end
|
19
18
|
end
|
20
|
-
end
|
19
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module Echosign
|
2
2
|
class PhoneInfo < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
|
-
# PhoneInfo
|
5
|
+
# PhoneInfo
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash.
|
9
|
-
# @option params [String] :phone The phone number required for the recipient to view and sign the document
|
10
|
-
#
|
8
|
+
# @option params [String] :phone The phone number required for the recipient to view and sign the document
|
9
|
+
# (REQUIRED)
|
10
|
+
# @option params [String] :countryCode The phoneInfo country code required for the recipient to view and sign
|
11
|
+
# the document if authentication type is PHONE
|
11
12
|
# @return [Echosign::PhoneInfo]
|
12
13
|
|
13
14
|
def initialize(params)
|
14
15
|
require_keys([:phone], params)
|
15
16
|
merge!(params)
|
16
17
|
end
|
17
|
-
|
18
18
|
end
|
19
19
|
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
module Echosign
|
2
2
|
class Recipient < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
|
-
# Creates an Echosign::Recipient object
|
5
|
+
# Creates an Echosign::Recipient object
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash. Role, and either fax or email is required.
|
9
8
|
# @option params [String] :role ['SIGNER' or 'APPROVER']: Specify the role of recipient (REQUIRED)
|
10
|
-
# @option params [String] :email Email of the recipient. This is required if fax is not provided. Both fax and
|
11
|
-
#
|
12
|
-
# @option params [
|
9
|
+
# @option params [String] :email Email of the recipient. This is required if fax is not provided. Both fax and
|
10
|
+
# email can not be provided (email or fax REQUIRED)
|
11
|
+
# @option params [String] :fax Fax of the recipient. This is required if email is not provided. Both fax and
|
12
|
+
# email can not be provided (email or fax REQUIRED)
|
13
|
+
# @option params [Array] :securityOptions Security options that apply to the recipient. Populate the array with
|
14
|
+
# instances of {Echosign::RecipientSecurityOption Echosign::RecipientSecurityOption}
|
13
15
|
# @return [Echosign::Recipient]
|
14
16
|
|
15
17
|
def initialize(params)
|
16
18
|
require_exactly_one([:email, :fax], params)
|
17
|
-
|
19
|
+
email_or_fax = params[:email] ? { email: params[:email] } : { fax: params[:fax] }
|
20
|
+
merge!(recipientSetMemberInfos: email_or_fax, recipientSetRole: params[:role])
|
18
21
|
end
|
19
|
-
|
20
22
|
end
|
21
23
|
end
|
22
|
-
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Echosign
|
2
2
|
class RecipientSecurityOption < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
5
|
# Validates RecipientSecurityOption parameters
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash.
|
9
|
-
# @option params [String] :authenticationMethod ['INHERITED_FROM_DOCUMENT' or 'KBA' or 'PASSWORD' or
|
10
|
-
#
|
8
|
+
# @option params [String] :authenticationMethod ['INHERITED_FROM_DOCUMENT' or 'KBA' or 'PASSWORD' or
|
9
|
+
# 'WEB_IDENTITY' or 'PHONE' or 'NONE']: The authentication method for the recipients to have access to view
|
10
|
+
# and sign the document. (REQUIRED)
|
11
|
+
# @option params [Array] :phoneInfos The phoneInfo required for the recipient to view and sign the document.
|
12
|
+
# Populate with instances of {Echosign::PhoneInfo Echosign::PhoneInfo}
|
11
13
|
# @option params [String] :password The password required for the recipient to view and sign the document.
|
12
14
|
# @return [Echosign::RecipientSecurityOption]
|
13
15
|
|
@@ -15,6 +17,5 @@ module Echosign
|
|
15
17
|
require_keys([:authenticationMethod], params)
|
16
18
|
merge! params
|
17
19
|
end
|
18
|
-
|
19
20
|
end
|
20
21
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Echosign::Request
|
2
|
-
|
3
2
|
# Performs REST create_agreement operation
|
4
3
|
#
|
5
4
|
# @param body [Hash] Request body (REQUIRED)
|
@@ -7,13 +6,11 @@ module Echosign::Request
|
|
7
6
|
# @param user_id [String] Echosign user ID (REQUIRED)
|
8
7
|
# @param user_email [String] Echosign user email
|
9
8
|
# @return [Hash] Agreement response body
|
10
|
-
def self.create_agreement(
|
9
|
+
def self.create_agreement(token, base_uri, body, user_id = nil, user_email = nil)
|
11
10
|
headers = { 'Access-Token' => token }
|
12
|
-
headers
|
13
|
-
headers
|
14
|
-
|
15
|
-
response = HTTParty.post(ENDPOINT.fetch(:agreement), :body => body.to_json,
|
16
|
-
:headers => headers)
|
11
|
+
headers['X-User-Id'] = user_id unless user_id.nil?
|
12
|
+
headers['X-User-Email'] = user_email unless user_email.nil?
|
13
|
+
response = post(ENDPOINT.fetch(:agreement, base_uri), body, headers, json: true)
|
17
14
|
JSON.parse(response.body)
|
18
15
|
end
|
19
16
|
|
@@ -21,9 +18,9 @@ module Echosign::Request
|
|
21
18
|
#
|
22
19
|
# @param token [String] Auth Token
|
23
20
|
# @return [Hash] Agreements response body
|
24
|
-
def self.get_agreements(token)
|
21
|
+
def self.get_agreements(token, base_uri)
|
25
22
|
headers = { 'Access-Token' => token }
|
26
|
-
response = get(ENDPOINT.fetch(:agreement), headers)
|
23
|
+
response = get(ENDPOINT.fetch(:agreement, base_uri), headers)
|
27
24
|
JSON.parse(response.body)
|
28
25
|
end
|
29
26
|
|
@@ -32,9 +29,9 @@ module Echosign::Request
|
|
32
29
|
# @param token [String] Auth Token
|
33
30
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
34
31
|
# @return [Hash] Agreement info response body
|
35
|
-
def self.agreement_info(token, agreement_id)
|
32
|
+
def self.agreement_info(token, base_uri, agreement_id)
|
36
33
|
headers = { 'Access-Token' => token }
|
37
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}"
|
34
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}"
|
38
35
|
response = get(endpoint, headers)
|
39
36
|
JSON.parse(response.body)
|
40
37
|
end
|
@@ -44,36 +41,38 @@ module Echosign::Request
|
|
44
41
|
# @param token [String] Auth Token
|
45
42
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
46
43
|
# @return [Hash] URL information for the eSign page of the agreement
|
47
|
-
def self.agreement_signing_urls(token, agreement_id)
|
44
|
+
def self.agreement_signing_urls(token, base_uri, agreement_id)
|
48
45
|
headers = { 'Access-Token' => token }
|
49
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/signingUrls"
|
46
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/signingUrls"
|
50
47
|
response = get(endpoint, headers)
|
51
48
|
JSON.parse(response.body)
|
52
49
|
end
|
53
50
|
|
54
51
|
# Gets a single combined PDF document for the documents associated with an agreement.
|
55
|
-
#
|
52
|
+
#
|
56
53
|
# @param token [String] Auth Token
|
57
54
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
58
55
|
# @return [String] Raw bytes from document file
|
59
|
-
def self.agreement_combined_pdf(token, agreement_id, versionId, participantEmail,
|
56
|
+
def self.agreement_combined_pdf(token, base_uri, agreement_id, versionId, participantEmail,
|
57
|
+
attachSupportingDocuments, auditReport)
|
60
58
|
headers = { 'Access-Token' => token }
|
61
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/combinedDocument"
|
59
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/combinedDocument"
|
62
60
|
endpoint << add_query(endpoint, "versionId=#{versionId}") unless versionId.nil?
|
63
61
|
endpoint << add_query(endpoint, "participantEmail=#{participantEmail}") unless participantEmail.nil?
|
64
62
|
endpoint << add_query(endpoint, "attachSupportingDocuments=#{attachSupportingDocuments}")
|
65
63
|
endpoint << add_query(endpoint, "auditReport=#{auditReport}")
|
66
64
|
response = get(endpoint, headers)
|
65
|
+
response.body
|
67
66
|
end
|
68
67
|
|
69
68
|
# Retrieves data entered by the user into interactive form fields at the time they signed the agreement
|
70
|
-
#
|
69
|
+
#
|
71
70
|
# @param token [String] Auth Token
|
72
71
|
# @param agreement_id [String] (REQUIRED)
|
73
72
|
# @return [String] Raw bytes representing CSV file
|
74
|
-
def self.agreement_form_data(token, agreement_id)
|
73
|
+
def self.agreement_form_data(token, base_uri, agreement_id)
|
75
74
|
headers = { 'Access-Token' => token }
|
76
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/formData"
|
75
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/formData"
|
77
76
|
response = get(endpoint, headers)
|
78
77
|
end
|
79
78
|
|
@@ -82,10 +81,11 @@ module Echosign::Request
|
|
82
81
|
# @param token [String] Auth Token
|
83
82
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
84
83
|
# @return [String] Raw bytes from document file
|
85
|
-
def self.agreement_document_file(token, agreement_id, document_id)
|
84
|
+
def self.agreement_document_file(token, base_uri, agreement_id, document_id)
|
86
85
|
headers = { 'Access-Token' => token }
|
87
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/documents/#{document_id}"
|
86
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/documents/#{document_id}"
|
88
87
|
response = get(endpoint, headers)
|
88
|
+
response.body
|
89
89
|
end
|
90
90
|
|
91
91
|
# Performs REST GET /agreement/:id/auditTrail operation
|
@@ -93,22 +93,25 @@ module Echosign::Request
|
|
93
93
|
# @param token [String] Auth Token
|
94
94
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
95
95
|
# @return [String] Raw bytes from audit pdf file
|
96
|
-
def self.audit_trail_pdf(token, agreement_id)
|
96
|
+
def self.audit_trail_pdf(token, base_uri, agreement_id)
|
97
97
|
headers = { 'Access-Token' => token }
|
98
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/auditTrail"
|
98
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/auditTrail"
|
99
99
|
response = get(endpoint, headers)
|
100
|
+
response.body
|
100
101
|
end
|
101
102
|
|
102
103
|
# Performs REST GET /agreement/:id/documents
|
103
104
|
#
|
104
105
|
# @param agreement_id [String] (REQUIRED)
|
105
106
|
# @param recipient_email [String] The email address of the participant to be used to retrieve documents. (REQUIRED)
|
106
|
-
# @param format [String] Content format of the supported documents. It can have two possible values ORIGINAL or
|
107
|
-
#
|
107
|
+
# @param format [String] Content format of the supported documents. It can have two possible values ORIGINAL or
|
108
|
+
# CONVERTED_PDF. (REQUIRED)
|
109
|
+
# @param version_id [String] Version of the agreement as provided by {agreement_info agreement_info}. If not
|
110
|
+
# provided, the latest version of the agreement is used.
|
108
111
|
# @return [Hash] Agreement documents response body
|
109
|
-
def self.agreement_documents(token, agreement_id, recipient_email=nil, format=nil, version_id=nil)
|
112
|
+
def self.agreement_documents(token, base_uri, agreement_id, recipient_email = nil, format = nil, version_id = nil)
|
110
113
|
headers = { 'Access-Token' => token }
|
111
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/documents"
|
114
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/documents"
|
112
115
|
endpoint << add_query(endpoint, "versionId=#{version_id}") unless version_id.nil?
|
113
116
|
endpoint << add_query(endpoint, "participantEmail=#{recipient_email}") unless version_id.nil?
|
114
117
|
endpoint << add_query(endpoint, "supportingDocumentContentFormat=#{format}") unless format.nil?
|
@@ -116,29 +119,16 @@ module Echosign::Request
|
|
116
119
|
JSON.parse(response.body)
|
117
120
|
end
|
118
121
|
|
119
|
-
|
120
122
|
# Performs REST PUT /agreement/:id operation
|
121
123
|
#
|
122
124
|
# @param token [String] Auth Token
|
123
125
|
# @param agreement_id [String] ID of agreement to retrieve info on.
|
124
126
|
# @param request_body [Hash] Hash for Agreement status update
|
125
127
|
# @return [Hash] Agreements response body
|
126
|
-
def self.update_agreement_status(token, agreement_id, request_body)
|
128
|
+
def self.update_agreement_status(token, base_uri, agreement_id, request_body)
|
127
129
|
headers = { 'Access-Token' => token }
|
128
|
-
endpoint = "#{ENDPOINT.fetch(:agreement)}/#{agreement_id}/status"
|
129
|
-
|
130
|
-
begin
|
131
|
-
response = HTTParty.put(
|
132
|
-
endpoint,
|
133
|
-
request_body.to_json,
|
134
|
-
headers
|
135
|
-
)
|
136
|
-
rescue Exception => error
|
137
|
-
raise_error(error)
|
138
|
-
end
|
139
|
-
|
130
|
+
endpoint = "#{ENDPOINT.fetch(:agreement, base_uri)}/#{agreement_id}/status"
|
131
|
+
response = put(endpoint, request_body.to_json, headers)
|
140
132
|
JSON.parse(response.body)
|
141
133
|
end
|
142
|
-
|
143
|
-
|
144
134
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Echosign
|
2
2
|
class RequestFormField < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
|
-
# Validates RequestFormField params
|
5
|
+
# Validates RequestFormField params
|
7
6
|
#
|
8
7
|
# @param [Hash] params SYMBOL-referenced Hash containing exactly one of the following:
|
9
8
|
# @return [Echosign::RequestFormField]
|
@@ -12,4 +11,4 @@ module Echosign
|
|
12
11
|
merge!(params)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
end
|
14
|
+
end
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module Echosign
|
2
2
|
class UrlFileInfo < Hash
|
3
|
-
|
4
3
|
include Validatable
|
5
4
|
|
6
5
|
# Validates UrlFileInfo parameters
|
7
6
|
#
|
8
|
-
# @param [Hash] params SYMBOL-referenced Hash
|
9
|
-
# @option params [String] :url A publicly accessible URL for retrieving the raw file content. HTTP
|
10
|
-
#
|
11
|
-
#
|
7
|
+
# @param [Hash] params SYMBOL-referenced Hash
|
8
|
+
# @option params [String] :url A publicly accessible URL for retrieving the raw file content. HTTP
|
9
|
+
# authentication is supported using standard embedded syntax - i.e.
|
10
|
+
# http://username:password@your.server.com/path/to/file (REQUIRED)
|
11
|
+
# @option params [String] :mimeType The mime type of the referenced file, used to determine if the file can be
|
12
|
+
# accepted and the necessary conversion steps can be performed.
|
13
|
+
# @option params [String] :name The original system file name of the document being sent - used to name
|
14
|
+
# attachments, and to infer the mime type if one is not explicitly specified
|
12
15
|
def initialize(params)
|
13
16
|
require_keys([:url], params)
|
14
17
|
merge! params
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
data/lib/echosign/client.rb
CHANGED
@@ -2,18 +2,17 @@ require 'echosign/agreement/client'
|
|
2
2
|
require 'echosign/library_documents/client'
|
3
3
|
require 'echosign/widget/client'
|
4
4
|
|
5
|
-
|
6
5
|
module Echosign
|
7
|
-
|
8
|
-
class Client
|
9
|
-
|
6
|
+
class Client
|
10
7
|
attr_reader :token
|
8
|
+
|
11
9
|
# Initializes the Client object
|
12
10
|
#
|
13
|
-
# @param
|
14
|
-
# @return [
|
15
|
-
def initialize(
|
16
|
-
@token =
|
11
|
+
# @param token [String] Access token or integration key
|
12
|
+
# @return [Echochamber::Client] Initialized Echochamber::Client
|
13
|
+
def initialize(token)
|
14
|
+
@token = token
|
15
|
+
@base_uri = nil
|
17
16
|
end
|
18
17
|
|
19
18
|
# Creates a user for the current application
|
@@ -21,26 +20,26 @@ module Echosign
|
|
21
20
|
# @param user [Echosign::User]
|
22
21
|
# @return [String] User ID of new Echosign user
|
23
22
|
def create_user(user)
|
24
|
-
user_response
|
23
|
+
user_response = request(:create_user, user)
|
25
24
|
user_response.fetch("userId")
|
26
25
|
end
|
27
26
|
|
28
|
-
# Creates a reminder
|
27
|
+
# Creates a reminder
|
29
28
|
#
|
30
29
|
# @param reminder [Echosign::Reminder]
|
31
30
|
# @return [String] Reminder ID
|
32
31
|
def create_reminder(reminder)
|
33
|
-
reminder_response =
|
32
|
+
reminder_response = request(:create_reminder, reminder)
|
34
33
|
end
|
35
34
|
|
36
35
|
# Creates a transient document for later referral
|
37
36
|
#
|
38
|
-
# @param file_name [String]
|
39
|
-
# @param mime_type [String]
|
40
|
-
# @param file_handle [File]
|
37
|
+
# @param file_name [String]
|
38
|
+
# @param mime_type [String]
|
39
|
+
# @param file_handle [File]
|
41
40
|
# @return [String] Transient document ID
|
42
41
|
def create_transient_document(file_name, mime_type, file_handle)
|
43
|
-
transient_document_response =
|
42
|
+
transient_document_response = request(:create_transient_document, file_name, file_handle, mime_type)
|
44
43
|
transient_document_response.fetch("transientDocumentId")
|
45
44
|
end
|
46
45
|
|
@@ -49,8 +48,8 @@ module Echosign
|
|
49
48
|
# @param agreement_id [String] (REQUIRED)
|
50
49
|
# @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
|
51
50
|
# @return [String] Raw bytes from document file
|
52
|
-
def audit_trail_pdf(agreement_id, file_path=nil)
|
53
|
-
response =
|
51
|
+
def audit_trail_pdf(agreement_id, file_path = nil)
|
52
|
+
response = request(:audit_trail_pdf, agreement_id)
|
54
53
|
unless file_path.nil?
|
55
54
|
file = File.new(file_path, 'wb')
|
56
55
|
file.write(response)
|
@@ -59,24 +58,34 @@ module Echosign
|
|
59
58
|
response
|
60
59
|
end
|
61
60
|
|
62
|
-
|
63
61
|
# Gets all the users in an account that the caller has permissions to access.
|
64
|
-
#
|
62
|
+
#
|
65
63
|
# @param user_email [String] The email address of the user whose details are being requested (REQUIRED)
|
66
64
|
# @return [Hash] User info hash
|
67
65
|
def get_users(user_email)
|
68
|
-
|
66
|
+
request(:get_users, user_email)
|
69
67
|
end
|
70
68
|
|
71
69
|
# Gets all the users in an account that the caller has permissions to access.
|
72
|
-
#
|
70
|
+
#
|
73
71
|
# @param user_id [String]
|
74
72
|
# @return [Hash] User info hash
|
75
73
|
def get_user(user_id)
|
76
|
-
|
74
|
+
request(:get_user, user_id)
|
77
75
|
end
|
78
76
|
|
77
|
+
private
|
79
78
|
|
80
|
-
|
81
|
-
|
79
|
+
# Call an Echosign::Request method with this client's token and base_uri
|
80
|
+
#
|
81
|
+
# @param method [Symbol] The name of the ultimate method to call
|
82
|
+
# @param params Any number of parameters to be passed to the ultimate method
|
83
|
+
# @return Returns the result of the ultimate method
|
84
|
+
#
|
85
|
+
# Note: params will be prepended with token and base_uri before calling the ultimate method
|
86
|
+
def request(method, *params)
|
87
|
+
@base_uri ||= Echosign::Request.get_base_uris(@token).fetch('api_access_point')
|
88
|
+
Echosign::Request.send(method, @token, @base_uri, *params)
|
89
|
+
end
|
90
|
+
end # class Client
|
82
91
|
end # module Echosign
|
data/lib/echosign/credentials.rb
CHANGED
@@ -1,33 +1,104 @@
|
|
1
1
|
module Echosign
|
2
|
-
class Credentials
|
2
|
+
class Credentials
|
3
|
+
require 'oauth2'
|
3
4
|
|
4
5
|
include Validatable
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
7
|
+
OAUTH_SITE = 'https://secure.echosign.com'
|
8
|
+
AUTHORIZE_PATH = '/public/oauth'
|
9
|
+
TOKEN_PATH = '/oauth/token'
|
10
|
+
REFRESH_PATH = '/oauth/refresh'
|
11
|
+
REVOKE_PATH = '/oauth/revoke'
|
12
|
+
|
13
|
+
attr_reader :access_token, :refresh_token, :expires_at
|
14
|
+
|
15
|
+
# Builds an Credentials object
|
16
|
+
#
|
17
|
+
# @param client_id [String] Client ID
|
18
|
+
# @param client_secret [String] Client secret
|
19
|
+
#
|
20
|
+
# @return [Echosign::Credentials] Echosign OAuth2 wrapper object
|
21
|
+
def initialize(client_id, client_secret)
|
22
|
+
@client = OAuth2::Client.new(
|
23
|
+
client_id,
|
24
|
+
client_secret,
|
25
|
+
site: OAUTH_SITE,
|
26
|
+
authorize_url: AUTHORIZE_PATH,
|
27
|
+
token_url: TOKEN_PATH
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
|
+
# Build an authorization endpoint URL for EchoSign's OAuth2 provider
|
32
|
+
#
|
33
|
+
# @param redirect_uri [String] A secure URL to redirect the user afterward
|
34
|
+
# @param scope [String] Space delimited set of permissions to approve
|
35
|
+
# @param state [String] Any value; will be returned to the client afterward
|
36
|
+
#
|
37
|
+
# @return [Echosign::Credentials] Echosign OAuth2 wrapper object
|
38
|
+
#
|
39
|
+
# The redirect_uri must be specified on the app's OAuth Configuration page.
|
40
|
+
# @see https://secure.na1.echosign.com/public/static/oauthDoc.jsp#authorizationRequest
|
41
|
+
def authorize_url(redirect_uri, scope, state = nil)
|
42
|
+
return @client.auth_code.authorize_url(
|
43
|
+
redirect_uri: redirect_uri,
|
44
|
+
scope: scope,
|
45
|
+
state: state
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Make a request to the token endpoint and return an access token
|
50
|
+
#
|
51
|
+
# @param code [String] The authorization code obtained after #authorize_url
|
52
|
+
# @param redirect_uri [String] The redirect_url used during #authorize_url
|
53
|
+
#
|
54
|
+
# @return [String] An access token that can be used in the EchoSign API
|
55
|
+
def get_token(code, redirect_uri)
|
56
|
+
@client.options[:token_url] = TOKEN_PATH
|
57
|
+
oauth_token = @client.get_token(code: code,
|
58
|
+
redirect_uri: redirect_uri,
|
59
|
+
grant_type: :authorization_code)
|
60
|
+
|
61
|
+
@access_token = oauth_token.token
|
62
|
+
@refresh_token = oauth_token.refresh_token
|
63
|
+
@expires_at = oauth_token.expires_at
|
64
|
+
|
65
|
+
return @access_token
|
66
|
+
end
|
67
|
+
|
68
|
+
# Update (refresh) an access token
|
69
|
+
#
|
70
|
+
# @param current_refresh_token [String] A previously obtained refresh_token from a get_token request
|
71
|
+
#
|
72
|
+
# @return [String] A new access token to be used in the EchoSign API
|
73
|
+
#
|
74
|
+
# This method should only be called after #get_token
|
75
|
+
def refresh_access_token(current_refresh_token = nil)
|
76
|
+
@refresh_token = current_refresh_token if current_refresh_token != nil
|
77
|
+
|
78
|
+
@client.options[:token_url] = REFRESH_PATH
|
79
|
+
oauth_token = @client.get_token(grant_type: :refresh_token, refresh_token: @refresh_token)
|
80
|
+
|
81
|
+
@access_token = oauth_token.token
|
82
|
+
@expires_at = oauth_token.expires_at
|
83
|
+
|
84
|
+
return @access_token
|
85
|
+
end
|
86
|
+
|
87
|
+
# Revoke an access or refresh token, and any corresponding tokens
|
88
|
+
#
|
89
|
+
# @param which [Symbol] The token to revoke, either :access or :refresh
|
90
|
+
#
|
91
|
+
# @return [void]
|
92
|
+
def revoke_token(which = :access)
|
93
|
+
if which == :access
|
94
|
+
@client.request(:post, REVOKE_PATH, body: { token: @access_token })
|
95
|
+
else
|
96
|
+
@client.request(:post, REVOKE_PATH, body: { token: @refresh_token })
|
97
|
+
@refresh_token = nil
|
98
|
+
end
|
99
|
+
|
100
|
+
@access_token = nil
|
101
|
+
@expires_at = nil
|
102
|
+
end
|
31
103
|
end
|
32
104
|
end
|
33
|
-
|