echochamber 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +79 -0
  6. data/LICENSE +21 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +87 -0
  9. data/Rakefile +12 -0
  10. data/doc/Echochamber.html +131 -0
  11. data/doc/Echochamber/Agreement.html +529 -0
  12. data/doc/Echochamber/Agreement/UrlFileInfo.html +263 -0
  13. data/doc/Echochamber/Client.html +4161 -0
  14. data/doc/Echochamber/CounterSignerInfo.html +265 -0
  15. data/doc/Echochamber/Credentials.html +330 -0
  16. data/doc/Echochamber/Credentials/CredentialsError.html +123 -0
  17. data/doc/Echochamber/Fileinfo.html +303 -0
  18. data/doc/Echochamber/InvalidParameterError.html +123 -0
  19. data/doc/Echochamber/ParameterError.html +123 -0
  20. data/doc/Echochamber/PhoneInfo.html +279 -0
  21. data/doc/Echochamber/Recipient.html +309 -0
  22. data/doc/Echochamber/RecipientSecurityOption.html +294 -0
  23. data/doc/Echochamber/Reminder.html +277 -0
  24. data/doc/Echochamber/Request.html +4167 -0
  25. data/doc/Echochamber/Request/Failure.html +123 -0
  26. data/doc/Echochamber/RequiredParameterError.html +123 -0
  27. data/doc/Echochamber/UrlFileInfo.html +295 -0
  28. data/doc/Echochamber/User.html +420 -0
  29. data/doc/Echochamber/Validatable.html +355 -0
  30. data/doc/Echochamber/Validator.html +180 -0
  31. data/doc/Echochamber/Widget.html +654 -0
  32. data/doc/Echochamber/WidgetCompletionInfo.html +309 -0
  33. data/doc/Echochamber/WidgetPersonalization.html +326 -0
  34. data/doc/Echochamber/WidgetSecurityOption.html +359 -0
  35. data/doc/Echochamber/WidgetSignerSecurityOption.html +296 -0
  36. data/doc/Echochamber/WidgetStatus.html +314 -0
  37. data/doc/Echochamber/WidgetVaultingInfo.html +265 -0
  38. data/doc/_index.html +338 -0
  39. data/doc/class_list.html +54 -0
  40. data/doc/css/common.css +1 -0
  41. data/doc/css/full_list.css +57 -0
  42. data/doc/css/style.css +339 -0
  43. data/doc/file.README.html +157 -0
  44. data/doc/file_list.html +56 -0
  45. data/doc/frames.html +26 -0
  46. data/doc/index.html +157 -0
  47. data/doc/js/app.js +219 -0
  48. data/doc/js/full_list.js +178 -0
  49. data/doc/js/jquery.js +4 -0
  50. data/doc/method_list.html +581 -0
  51. data/doc/top-level-namespace.html +112 -0
  52. data/echochamber.gemspec +35 -0
  53. data/features/support/env.rb +8 -0
  54. data/fixtures/agreement.pdf +0 -0
  55. data/fixtures/vcr_cassettes/agreement_combined_pdf.yml +1465 -0
  56. data/fixtures/vcr_cassettes/agreement_document_file.yml +1465 -0
  57. data/fixtures/vcr_cassettes/agreement_documents.yml +42 -0
  58. data/fixtures/vcr_cassettes/agreement_form_data.yml +44 -0
  59. data/fixtures/vcr_cassettes/agreement_info.yml +50 -0
  60. data/fixtures/vcr_cassettes/agreement_signing_urls.yml +42 -0
  61. data/fixtures/vcr_cassettes/audit_trail_pdf.yml +1643 -0
  62. data/fixtures/vcr_cassettes/cancel_agreement.yml +46 -0
  63. data/fixtures/vcr_cassettes/create_agreement.yml +50 -0
  64. data/fixtures/vcr_cassettes/create_reminder.yml +47 -0
  65. data/fixtures/vcr_cassettes/create_transient_document.yml +716 -0
  66. data/fixtures/vcr_cassettes/create_user.yml +50 -0
  67. data/fixtures/vcr_cassettes/create_widget.yml +48 -0
  68. data/fixtures/vcr_cassettes/get_agreements.yml +46 -0
  69. data/fixtures/vcr_cassettes/get_library_document.yml +45 -0
  70. data/fixtures/vcr_cassettes/get_library_document_data.yml +1191 -0
  71. data/fixtures/vcr_cassettes/get_library_document_file.yml +42 -0
  72. data/fixtures/vcr_cassettes/get_library_documents.yml +47 -0
  73. data/fixtures/vcr_cassettes/get_token.yml +44 -0
  74. data/fixtures/vcr_cassettes/get_user.yml +46 -0
  75. data/fixtures/vcr_cassettes/get_users.yml +43 -0
  76. data/fixtures/vcr_cassettes/get_widget.yml +49 -0
  77. data/fixtures/vcr_cassettes/get_widget_document_file.yml +2682 -0
  78. data/fixtures/vcr_cassettes/get_widget_documents.yml +44 -0
  79. data/fixtures/vcr_cassettes/get_widgets.yml +50 -0
  80. data/fixtures/vcr_cassettes/library_combined_document.yml +2197 -0
  81. data/fixtures/vcr_cassettes/library_document_audit_trail.yml +1570 -0
  82. data/fixtures/vcr_cassettes/personalize_widget.yml +47 -0
  83. data/fixtures/vcr_cassettes/update_widget_status.yml +46 -0
  84. data/lib/echochamber.rb +10 -0
  85. data/lib/echochamber/agreement.rb +32 -0
  86. data/lib/echochamber/agreement/client.rb +118 -0
  87. data/lib/echochamber/agreement/fileinfo.rb +20 -0
  88. data/lib/echochamber/agreement/phone_info.rb +19 -0
  89. data/lib/echochamber/agreement/recipient.rb +23 -0
  90. data/lib/echochamber/agreement/recipient_security_option.rb +20 -0
  91. data/lib/echochamber/agreement/request.rb +142 -0
  92. data/lib/echochamber/agreement/url_file_info.rb +18 -0
  93. data/lib/echochamber/client.rb +82 -0
  94. data/lib/echochamber/credentials.rb +33 -0
  95. data/lib/echochamber/library_documents/client.rb +83 -0
  96. data/lib/echochamber/library_documents/request.rb +78 -0
  97. data/lib/echochamber/reminder.rb +17 -0
  98. data/lib/echochamber/request.rb +141 -0
  99. data/lib/echochamber/user.rb +29 -0
  100. data/lib/echochamber/validatable.rb +54 -0
  101. data/lib/echochamber/version.rb +3 -0
  102. data/lib/echochamber/widget.rb +42 -0
  103. data/lib/echochamber/widget/client.rb +127 -0
  104. data/lib/echochamber/widget/counter_signer_info.rb +19 -0
  105. data/lib/echochamber/widget/request.rb +135 -0
  106. data/lib/echochamber/widget/widget_completion_info.rb +19 -0
  107. data/lib/echochamber/widget/widget_personalization.rb +21 -0
  108. data/lib/echochamber/widget/widget_security_option.rb +22 -0
  109. data/lib/echochamber/widget/widget_signer_security_option.rb +18 -0
  110. data/lib/echochamber/widget/widget_status.rb +20 -0
  111. data/lib/echochamber/widget/widget_vaulting_info.rb +16 -0
  112. data/spec/lib/agreement/client_spec.rb +157 -0
  113. data/spec/lib/client_spec.rb +78 -0
  114. data/spec/lib/library_documents/client_spec.rb +71 -0
  115. data/spec/lib/request_spec.rb +18 -0
  116. data/spec/lib/shared_client.rb +22 -0
  117. data/spec/lib/user_spec.rb +6 -0
  118. data/spec/lib/validatable_spec.rb +110 -0
  119. data/spec/lib/version_spec.rb +7 -0
  120. data/spec/lib/widget/client_spec.rb +154 -0
  121. data/spec/spec_helper.rb +21 -0
  122. metadata +344 -0
@@ -0,0 +1,18 @@
1
+ module Echochamber
2
+ class UrlFileInfo < Hash
3
+
4
+ include Validatable
5
+
6
+ # Validates UrlFileInfo parameters
7
+ #
8
+ # @param [Hash] params SYMBOL-referenced Hash
9
+ # @option params [String] :url A publicly accessible URL for retrieving the raw file content. HTTP authentication is supported using standard embedded syntax - i.e. http://username:password@your.server.com/path/to/file (REQUIRED)
10
+ # @option params [String] :mimeType The mime type of the referenced file, used to determine if the file can be accepted and the necessary conversion steps can be performed.
11
+ # @option params [String] :name The original system file name of the document being sent - used to name attachments, and to infer the mime type if one is not explicitly specified
12
+ def initialize(params)
13
+ require_keys([:url], params)
14
+ merge! params
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,82 @@
1
+ require 'echochamber/agreement/client'
2
+ require 'echochamber/library_documents/client'
3
+ require 'echochamber/widget/client'
4
+
5
+
6
+ module Echochamber
7
+
8
+ class Client
9
+
10
+ attr_reader :token
11
+ # Initializes the Client object
12
+ #
13
+ # @param credentials [Echochamber::Credentials] Initialized Echochamber::Credentials
14
+ # @return [Echochamber::Client] Initialized Echochamber::Client
15
+ def initialize(credentials)
16
+ @token = Echochamber::Request.get_token(credentials)
17
+ end
18
+
19
+ # Creates a user for the current application
20
+ #
21
+ # @param user [Echochamber::User]
22
+ # @return [String] User ID of new Echosign user
23
+ def create_user(user)
24
+ user_response = Echochamber::Request.create_user(user, token)
25
+ user_response.fetch("userId")
26
+ end
27
+
28
+ # Creates a reminder
29
+ #
30
+ # @param reminder [Echochamber::Reminder]
31
+ # @return [String] Reminder ID
32
+ def create_reminder(reminder)
33
+ reminder_response = Echochamber::Request.create_reminder(token, reminder)
34
+ end
35
+
36
+ # Creates a transient document for later referral
37
+ #
38
+ # @param file_name [String]
39
+ # @param mime_type [String]
40
+ # @param file_handle [File]
41
+ # @return [String] Transient document ID
42
+ def create_transient_document(file_name, mime_type, file_handle)
43
+ transient_document_response = Echochamber::Request.create_transient_document(token, file_name, file_handle, mime_type)
44
+ transient_document_response.fetch("transientDocumentId")
45
+ end
46
+
47
+ # Retrieve a PDF audit file for an agreement
48
+ #
49
+ # @param agreement_id [String] (REQUIRED)
50
+ # @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
51
+ # @return [String] Raw bytes from document file
52
+ def audit_trail_pdf(agreement_id, file_path=nil)
53
+ response = Echochamber::Request.audit_trail_pdf(token, agreement_id)
54
+ unless file_path.nil?
55
+ file = File.new(file_path, 'wb')
56
+ file.write(response)
57
+ file.close
58
+ end
59
+ response
60
+ end
61
+
62
+
63
+ # Gets all the users in an account that the caller has permissions to access.
64
+ #
65
+ # @param user_email [String] The email address of the user whose details are being requested (REQUIRED)
66
+ # @return [Hash] User info hash
67
+ def get_users(user_email)
68
+ Echochamber::Request.get_users(token, user_email)
69
+ end
70
+
71
+ # Gets all the users in an account that the caller has permissions to access.
72
+ #
73
+ # @param user_id [String]
74
+ # @return [Hash] User info hash
75
+ def get_user(user_id)
76
+ Echochamber::Request.get_user(token, user_id)
77
+ end
78
+
79
+
80
+ end # class Client
81
+
82
+ end # module Echochamber
@@ -0,0 +1,33 @@
1
+ module Echochamber
2
+ class Credentials < Hash
3
+
4
+ include Validatable
5
+
6
+ # Builds a Credentials object
7
+ #
8
+ # @param app_id [String] Application key
9
+ # @param app_secret [String] Application secret
10
+ # @param api_key [String] API Key
11
+ # @param email [String] User email
12
+ # @param password [String] User password
13
+ # @return [Echochamber::Credentials] Echosign credentials
14
+ def initialize(app_id, app_secret, api_key, email, password)
15
+
16
+ merge!(
17
+ {
18
+ applicationCredentials: {
19
+ applicationId: app_id,
20
+ applicationSecret: app_secret
21
+ },
22
+ userCredentials: {
23
+ apiKey: api_key,
24
+ email: email,
25
+ password: password
26
+ }
27
+ }
28
+ )
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,83 @@
1
+ module Echochamber
2
+
3
+ class Client
4
+
5
+ # Retrieves library documents metadata for a user.
6
+ #
7
+ # @param user_id [String] The ID of the user whose library documents are being requested.
8
+ # @param user_email [String] The email address of the user whose library documents are being requested. If both user_id and user_email are provided then user_id is given preference. If neither is specified then the user is inferred from the access token.
9
+ # @return [Hash] Library documents metadata
10
+ def get_library_documents(user_id=nil, user_email=nil)
11
+ Echochamber::Request.get_library_documents(token, user_id, user_email)
12
+ end
13
+
14
+ # Retrieves library document metadata
15
+ #
16
+ # @param library_document_id [String] (REQUIRED)
17
+ # @return [Hash] Library document metadata
18
+ def get_library_document(library_document_id)
19
+ Echochamber::Request.get_library_document(token, library_document_id)
20
+ end
21
+
22
+ # Retrieves library document files metadata
23
+ #
24
+ # @param library_document_id [String] (REQUIRED)
25
+ # @return [Hash] Library document files metadata
26
+ def get_library_document_files(library_document_id)
27
+ Echochamber::Request.get_library_document_files(token, library_document_id)
28
+ end
29
+
30
+ # Retrieves library document file data
31
+ #
32
+ # @param library_document_id (REQUIRED)
33
+ # @param file_id [String] (REQUIRED)
34
+ # @param file_path [String] File path for saving the document. If none is given, nothing will be saved to disk.
35
+ # @return [String] Raw library document file data
36
+ def get_library_document_file(library_document_id, file_id, file_path=nil)
37
+ response = Echochamber::Request.get_library_document_file(token, library_document_id, file_id)
38
+ unless file_path.nil?
39
+ file = File.new(file_path, 'wb')
40
+ file.write(response)
41
+ file.close
42
+ end
43
+ response
44
+ end
45
+
46
+ # Retrieves library document audit trail file
47
+ #
48
+ # @param library_document_id (REQUIRED)
49
+ # @param file_path [String] File path for saving the document. If none is given, nothing will be saved to disk.
50
+ # @return [String] Raw library document file data
51
+ def library_document_audit_trail(library_document_id, file_path=nil)
52
+ response = Echochamber::Request.library_document_audit_trail(token, library_document_id)
53
+ unless file_path.nil?
54
+ file = File.new(file_path, 'wb')
55
+ file.write(response)
56
+ file.close
57
+ end
58
+ response
59
+ end
60
+
61
+ # Retrieves library combined document file
62
+ #
63
+ # @param library_document_id (REQUIRED)
64
+ # @param file_path [String] File path for saving the document. If none is given, nothing will be saved to disk.
65
+ # @param auditReport [Boolean] When set to YES attach an audit report to the library document PDF. Default value will be false.
66
+ # @return [String] Raw library combined document file data
67
+ def library_combined_document(library_document_id, file_path=nil, auditReport=false)
68
+ response = Echochamber::Request.library_combined_document(token, library_document_id, auditReport)
69
+ unless file_path.nil?
70
+ file = File.new(file_path, 'wb')
71
+ file.write(response)
72
+ file.close
73
+ end
74
+ response
75
+ end
76
+
77
+
78
+
79
+
80
+ end
81
+ end
82
+
83
+
@@ -0,0 +1,78 @@
1
+ module Echochamber::Request
2
+
3
+ # Retrieves library documents for a user.
4
+ #
5
+ # @param token [String] Auth Token
6
+ # @param user_id [String] The ID of the user whose library documents are being requested.
7
+ # @param user_email [String] The email address of the user whose library documents are being requested. If both user_id and user_email are provided then user_id is given preference. If neither is specified then the user is inferred from the access token.
8
+ # @return [Hash] Library documents metadata
9
+ def self.get_library_documents(token, user_id=nil, user_email=nil)
10
+ headers = { 'Access-Token' => token }
11
+ headers.merge!('X-User-Id' => user_id) unless user_id.nil?
12
+ headers.merge!('X-User-Email' => user_email) unless user_email.nil?
13
+ endpoint = ENDPOINT.fetch(:libraryDocument)
14
+ response = get(endpoint, headers)
15
+ JSON.parse(response)
16
+ end
17
+
18
+ # Retrieves library document metadata for a user.
19
+ #
20
+ # @param token [String] Auth Token
21
+ # @param library_document_id [String]
22
+ # @return [Hash] Library document metadata
23
+ def self.get_library_document(token, library_document_id)
24
+ headers = { 'Access-Token' => token }
25
+ endpoint = "#{ENDPOINT.fetch(:libraryDocument)}/#{library_document_id}"
26
+ response = get(endpoint, headers)
27
+ JSON.parse(response)
28
+ end
29
+
30
+ # Retrieves library document file
31
+ #
32
+ # @param token [String] Auth Token
33
+ # @param library_document_id [String] (REQUIRED)
34
+ # @return [Hash] Library document files metadata
35
+ def self.get_library_document_files(token, library_document_id)
36
+ headers = { 'Access-Token' => token }
37
+ endpoint = "#{ENDPOINT.fetch(:libraryDocument)}/#{library_document_id}/documents"
38
+ response = get(endpoint, headers)
39
+ JSON.parse(response)
40
+ end
41
+
42
+ # Retrieves library document file data
43
+ #
44
+ # @param token [String] Auth Token
45
+ # @param library_document_id [String] (REQUIRED)
46
+ # @param file_id [String] (REQUIRED)
47
+ # @return [String] Library document file data
48
+ def self.get_library_document_file(token, library_document_id, file_id)
49
+ headers = { 'Access-Token' => token }
50
+ endpoint = "#{ENDPOINT.fetch(:libraryDocument)}/#{library_document_id}/documents/#{file_id}"
51
+ response = get(endpoint, headers)
52
+ end
53
+
54
+ # Retrieves library document file data
55
+ #
56
+ # @param token [String] Auth Token
57
+ # @param library_document_id [String] (REQUIRED)
58
+ # @return [String] Library document file data
59
+ def self.library_document_audit_trail(token, library_document_id)
60
+ headers = { 'Access-Token' => token }
61
+ endpoint = "#{ENDPOINT.fetch(:libraryDocument)}/#{library_document_id}/auditTrail"
62
+ response = get(endpoint, headers)
63
+ end
64
+
65
+ # Retrieves library combined document file
66
+ #
67
+ # @param token [String] Auth Token
68
+ # @param library_document_id [String] (REQUIRED)
69
+ # @return [String] Raw library combined document file data
70
+ def self.library_combined_document(token, library_document_id, auditReport)
71
+ headers = { 'Access-Token' => token }
72
+ endpoint = "#{ENDPOINT.fetch(:libraryDocument)}/#{library_document_id}/combinedDocument"
73
+ endpoint << add_query(endpoint, "auditReport=#{auditReport}")
74
+ response = get(endpoint, headers)
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,17 @@
1
+ module Echochamber
2
+ class Reminder < Hash
3
+
4
+ include Validatable
5
+
6
+ # Reminder options
7
+ #
8
+ # @param [Hash] params SYMBOL-referenced Hash containing exactly one of the following:
9
+ # @option params [String] :agreementId (REQUIRED)
10
+ # @option params [String] :comment An Optional message sent to the recipients, describing what is being sent and why their signatures are required.
11
+ # @return [Echochamber::Reminder]
12
+ def initialize(params)
13
+ require_keys([:agreementId], params)
14
+ merge!(params)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,141 @@
1
+ require 'rest-client'
2
+ require 'echochamber/agreement/request'
3
+ require 'echochamber/library_documents/request'
4
+ require 'echochamber/widget/request'
5
+
6
+ module Echochamber::Request
7
+ class Failure < StandardError; end
8
+
9
+ BASE_URL = 'https://secure.echosign.com/api/rest/v2'
10
+
11
+ ENDPOINT = {
12
+ token: BASE_URL + '/auth/tokens',
13
+ user: BASE_URL + '/users',
14
+ agreement: BASE_URL + '/agreements',
15
+ reminder: BASE_URL + '/reminders',
16
+ transientDocument: BASE_URL + '/transientDocuments',
17
+ libraryDocument: BASE_URL + '/libraryDocuments',
18
+ widget: BASE_URL + '/widgets'
19
+ }
20
+
21
+ # Retrieves the authentication token
22
+ #
23
+ # @param credentials [Echochamber::Credentials] Initialized Echochamber::Credentials
24
+ # @return [String] Valid authentication token
25
+ def self.get_token(credentials)
26
+ headers = { :content_type => :json, :accept => :json }
27
+ response = post(ENDPOINT.fetch(:token), credentials, headers)
28
+ response_body = JSON.parse(response.body)
29
+ response_body.fetch("accessToken")
30
+ end
31
+
32
+ # Performs REST create_user operation
33
+ #
34
+ # @param body [Hash] Valid request body
35
+ # @param token [String] Auth Token
36
+ # @return [Hash] New user response body
37
+ def self.create_user(body, token)
38
+ endpoint = ENDPOINT.fetch(:user)
39
+ headers = { :content_type => :json, :accept => :json, 'Access-Token' => token}
40
+ response = post(endpoint, body, headers)
41
+ JSON.parse(response.body)
42
+ end
43
+
44
+ # Sends a reminder for an agreement.
45
+ #
46
+ # @param body [Hash] Valid request body
47
+ # @param token [String] Auth Token
48
+ # @return [Hash] Response body
49
+ def self.create_reminder(token, body)
50
+ endpoint = ENDPOINT.fetch(:reminder)
51
+ headers = { :content_type => :json, :accept => :json, 'Access-Token' => token}
52
+ response = post(endpoint, body, headers)
53
+ JSON.parse(response.body)
54
+ end
55
+
56
+ # Performs REST create_transient_document operation
57
+ #
58
+ # @param token [String] Auth token (REQUIRED)
59
+ # @param file_name [String] File name (REQUIRED)
60
+ # @param file_handle [File] File handle (REQUIRED)
61
+ # @param mime_type [String] Mime type
62
+ # @return [Hash] Transient Document Response Body
63
+ def self.create_transient_document(token, file_name, file_handle, mime_type=nil)
64
+ headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
65
+
66
+ begin
67
+ response = RestClient.post(
68
+ ENDPOINT.fetch(:transientDocument),
69
+ { 'File-Name' => file_name,
70
+ 'Mime-Type' => mime_type,
71
+ 'File' => file_handle,
72
+ :multipart => true},
73
+ headers
74
+ )
75
+ rescue Exception => error
76
+ raise_error(error)
77
+ end
78
+
79
+ JSON.parse(response.body)
80
+ end
81
+
82
+ # Gets all the users in an account that the caller has permissions to access.
83
+ #
84
+ # @param token [String] Auth Token
85
+ # @param user_email [String] The email address of the user whose details are being requested.
86
+ # @return [Hash] User info hash
87
+ def self.get_users(token, user_email)
88
+ headers = { 'Access-Token' => token }
89
+ endpoint = "#{ENDPOINT.fetch(:user)}?x-user-email=#{user_email}"
90
+ response = get(endpoint, headers)
91
+ JSON.parse(response)
92
+ end
93
+
94
+ # Gets all the users in an account that the caller has permissions to access.
95
+ #
96
+ # @param token [String] Auth Token
97
+ # @param user_id [String]
98
+ # @return [Hash] User info hash
99
+ def self.get_user(token, user_id)
100
+ headers = { 'Access-Token' => token }
101
+ endpoint = "#{ENDPOINT.fetch(:user)}/#{user_id}"
102
+ response = get(endpoint, headers)
103
+ JSON.parse(response)
104
+ end
105
+
106
+
107
+ private
108
+
109
+ def self.get(endpoint, headers)
110
+ begin
111
+ RestClient.get(
112
+ endpoint,
113
+ headers
114
+ )
115
+ rescue Exception => error
116
+ raise_error(error)
117
+ end
118
+ end
119
+
120
+ def self.post(endpoint, body, headers)
121
+ begin
122
+ RestClient.post(
123
+ endpoint,
124
+ body.to_json,
125
+ headers
126
+ )
127
+ rescue Exception => error
128
+ raise_error(error)
129
+ end
130
+ end
131
+
132
+ def self.add_query(url, query)
133
+ (url.include?('?') ? '&' : '?') + query
134
+ end
135
+
136
+ def self.raise_error(error)
137
+ raise Failure, "#{error.inspect}. \nSee Adobe Echosign REST API documentation for Error code meanings: https://secure.echosign.com/public/docs/restapi/v2"
138
+ end
139
+
140
+ end
141
+