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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.rubocop.yml +14 -0
  4. data/.rubocop_todo.yml +241 -0
  5. data/.simplecov +2 -0
  6. data/.travis.yml +9 -0
  7. data/Gemfile +3 -3
  8. data/Gemfile.lock +74 -48
  9. data/README.md +43 -8
  10. data/Rakefile +2 -2
  11. data/doc/Echosign.html +135 -0
  12. data/doc/Echosign/Agreement.html +545 -0
  13. data/doc/Echosign/Client.html +5365 -0
  14. data/doc/Echosign/CounterSignerInfo.html +267 -0
  15. data/doc/Echosign/Credentials.html +1053 -0
  16. data/doc/Echosign/Fileinfo.html +305 -0
  17. data/doc/Echosign/FormFieldLocation.html +264 -0
  18. data/doc/Echosign/MegaSign.html +533 -0
  19. data/doc/Echosign/ParameterError.html +124 -0
  20. data/doc/Echosign/PhoneInfo.html +281 -0
  21. data/doc/Echosign/Recipient.html +311 -0
  22. data/doc/Echosign/RecipientSecurityOption.html +296 -0
  23. data/doc/Echosign/Refresh.html +288 -0
  24. data/doc/Echosign/Reminder.html +279 -0
  25. data/doc/Echosign/Request.html +5289 -0
  26. data/doc/Echosign/Request/EndpointHash.html +328 -0
  27. data/doc/Echosign/Request/Failure.html +290 -0
  28. data/doc/Echosign/RequestFormField.html +244 -0
  29. data/doc/Echosign/RequiredParameterError.html +124 -0
  30. data/doc/Echosign/UrlFileInfo.html +297 -0
  31. data/doc/Echosign/User.html +422 -0
  32. data/doc/Echosign/Validatable.html +355 -0
  33. data/doc/Echosign/Widget.html +924 -0
  34. data/doc/Echosign/WidgetCompletionInfo.html +323 -0
  35. data/doc/Echosign/WidgetPersonalization.html +330 -0
  36. data/doc/Echosign/WidgetSecurityOption.html +361 -0
  37. data/doc/Echosign/WidgetSignerSecurityOption.html +298 -0
  38. data/doc/Echosign/WidgetStatus.html +316 -0
  39. data/doc/Echosign/WidgetVaultingInfo.html +267 -0
  40. data/doc/_index.html +378 -0
  41. data/doc/class_list.html +51 -0
  42. data/doc/css/common.css +1 -0
  43. data/doc/css/full_list.css +58 -0
  44. data/doc/css/style.css +496 -0
  45. data/doc/file.README.html +191 -0
  46. data/doc/file_list.html +56 -0
  47. data/doc/frames.html +17 -0
  48. data/doc/index.html +191 -0
  49. data/doc/js/app.js +292 -0
  50. data/doc/js/full_list.js +216 -0
  51. data/doc/js/jquery.js +4 -0
  52. data/doc/method_list.html +1035 -0
  53. data/doc/top-level-namespace.html +110 -0
  54. data/echosign.gemspec +18 -20
  55. data/features/support/env.rb +8 -8
  56. data/fixtures/vcr_cassettes/agreement_combined_pdf.yml +2 -2
  57. data/fixtures/vcr_cassettes/agreement_document_file.yml +1 -1
  58. data/fixtures/vcr_cassettes/agreement_documents.yml +2 -2
  59. data/fixtures/vcr_cassettes/agreement_form_data.yml +1 -1
  60. data/fixtures/vcr_cassettes/agreement_info.yml +1 -1
  61. data/fixtures/vcr_cassettes/agreement_signing_urls.yml +1 -1
  62. data/fixtures/vcr_cassettes/audit_trail_pdf.yml +1 -1
  63. data/fixtures/vcr_cassettes/cancel_agreement.yml +1 -1
  64. data/fixtures/vcr_cassettes/create_agreement.yml +1 -1
  65. data/fixtures/vcr_cassettes/create_reminder.yml +1 -1
  66. data/fixtures/vcr_cassettes/create_transient_document.yml +1 -1
  67. data/fixtures/vcr_cassettes/create_user.yml +1 -1
  68. data/fixtures/vcr_cassettes/create_widget.yml +1 -1
  69. data/fixtures/vcr_cassettes/get_agreements.yml +1 -1
  70. data/fixtures/vcr_cassettes/get_library_document.yml +1 -1
  71. data/fixtures/vcr_cassettes/get_library_document_data.yml +1 -1
  72. data/fixtures/vcr_cassettes/get_library_document_file.yml +1 -1
  73. data/fixtures/vcr_cassettes/get_library_documents.yml +1 -1
  74. data/fixtures/vcr_cassettes/get_token.yml +22 -20
  75. data/fixtures/vcr_cassettes/get_user.yml +1 -1
  76. data/fixtures/vcr_cassettes/get_users.yml +2 -2
  77. data/fixtures/vcr_cassettes/get_widget.yml +1 -1
  78. data/fixtures/vcr_cassettes/get_widget_document_file.yml +1 -1
  79. data/fixtures/vcr_cassettes/get_widget_documents.yml +1 -1
  80. data/fixtures/vcr_cassettes/get_widgets.yml +1 -1
  81. data/fixtures/vcr_cassettes/library_combined_document.yml +2 -2
  82. data/fixtures/vcr_cassettes/library_document_audit_trail.yml +1 -1
  83. data/fixtures/vcr_cassettes/personalize_widget.yml +1 -1
  84. data/fixtures/vcr_cassettes/refresh_token.yml +46 -0
  85. data/fixtures/vcr_cassettes/revoke_token.yml +44 -0
  86. data/fixtures/vcr_cassettes/update_widget_status.yml +1 -1
  87. data/lib/echosign.rb +11 -11
  88. data/lib/echosign/agreement.rb +26 -10
  89. data/lib/echosign/agreement/client.rb +111 -104
  90. data/lib/echosign/agreement/fileinfo.rb +1 -3
  91. data/lib/echosign/agreement/form_field_location.rb +2 -3
  92. data/lib/echosign/agreement/phone_info.rb +5 -5
  93. data/lib/echosign/agreement/recipient.rb +9 -8
  94. data/lib/echosign/agreement/recipient_security_option.rb +5 -4
  95. data/lib/echosign/agreement/request.rb +33 -43
  96. data/lib/echosign/agreement/request_form_field.rb +2 -3
  97. data/lib/echosign/agreement/url_file_info.rb +8 -6
  98. data/lib/echosign/client.rb +33 -24
  99. data/lib/echosign/credentials.rb +95 -24
  100. data/lib/echosign/library_documents/client.rb +18 -23
  101. data/lib/echosign/library_documents/request.rb +19 -20
  102. data/lib/echosign/mega_sign.rb +20 -10
  103. data/lib/echosign/mega_sign/client.rb +109 -104
  104. data/lib/echosign/mega_sign/request.rb +32 -43
  105. data/lib/echosign/refresh.rb +6 -10
  106. data/lib/echosign/reminder.rb +2 -2
  107. data/lib/echosign/request.rb +85 -75
  108. data/lib/echosign/user.rb +13 -7
  109. data/lib/echosign/validatable.rb +6 -10
  110. data/lib/echosign/version.rb +1 -1
  111. data/lib/echosign/widget.rb +53 -27
  112. data/lib/echosign/widget/client.rb +33 -36
  113. data/lib/echosign/widget/counter_signer_info.rb +4 -5
  114. data/lib/echosign/widget/request.rb +28 -52
  115. data/lib/echosign/widget/widget_completion_info.rb +22 -12
  116. data/lib/echosign/widget/widget_personalization.rb +9 -7
  117. data/lib/echosign/widget/widget_security_option.rb +21 -11
  118. data/lib/echosign/widget/widget_signer_security_option.rb +8 -6
  119. data/lib/echosign/widget/widget_status.rb +10 -8
  120. data/lib/echosign/widget/widget_vaulting_info.rb +4 -5
  121. data/spec/lib/agreement/client_spec.rb +25 -31
  122. data/spec/lib/client_spec.rb +15 -18
  123. data/spec/lib/credentials_spec.rb +48 -0
  124. data/spec/lib/library_documents/client_spec.rb +11 -15
  125. data/spec/lib/shared_client.rb +9 -16
  126. data/spec/lib/user_spec.rb +0 -2
  127. data/spec/lib/validatable_spec.rb +12 -18
  128. data/spec/lib/version_spec.rb +1 -1
  129. data/spec/lib/widget/client_spec.rb +46 -49
  130. data/spec/spec_helper.rb +12 -5
  131. metadata +125 -60
  132. data/spec/lib/request_spec.rb +0 -18
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/documents/2AAABLblqZhCGyGn1bpbXp-Kt-QXX8fsBWhjjO-bUKd0NQ184Xxm-mE6gg0DN0e-3k0Lwj6IPw9Q*
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/documents/2AAABLblqZhCGyGn1bpbXp-Kt-QXX8fsBWhjjO-bUKd0NQ184Xxm-mE6gg0DN0e-3k0Lwj6IPw9Q*
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/documents
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/documents
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/widgets
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,10 +2,10 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/libraryDocuments/2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*/combinedDocument?auditReport=true
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/libraryDocuments/2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*/combinedDocument
6
6
  body:
7
7
  encoding: US-ASCII
8
- string: ''
8
+ string: 'auditReport=true'
9
9
  headers:
10
10
  Accept:
11
11
  - '*/*; q=0.5, application/xml'
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://secure.echosign.com/api/rest/v5/libraryDocuments/2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*/auditTrail
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/libraryDocuments/2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*/auditTrail
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: put
5
- uri: https://secure.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/personalize
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/personalize
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"email":"cthomas@railjumper.com"}'
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://secure.echosign.com/oauth/refresh
6
+ body:
7
+ encoding: UTF-8
8
+ string: client_id=9Q444442AX82M&client_secret=390db09fc6672388b9457593a7&grant_type=refresh_token&refresh_token=3AAABLblqZhCNb-X2YXthBgBsEVpM1xC0EATrsDEo0yAmXOIlM58tuASRzYaMjhUGNbRQga8syqE%2A
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.12.2
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Tue, 11 Sep 2018 23:41:11 GMT
25
+ Server:
26
+ - Apache
27
+ Strict-Transport-Security:
28
+ - max-age=31536000;
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Robots-Tag:
34
+ - none
35
+ P3p:
36
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
37
+ Transfer-Encoding:
38
+ - chunked
39
+ Content-Type:
40
+ - application/json;charset=UTF-8
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"access_token":"3AAABLblqZhA9xhGH0gLPM8cKzF-pe_Uv_0_w72y8CqySA1kyRLveqY7fWZo_M3GC9u-ogYb3eAnD95YpnnlerKigV6IZHqFZ","token_type":"Bearer","expires_in":3600}'
44
+ http_version:
45
+ recorded_at: Tue, 11 Sep 2018 23:41:11 GMT
46
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://secure.echosign.com/oauth/revoke
6
+ body:
7
+ encoding: UTF-8
8
+ string: token=3AAABLblqZhAN-cxVlpFIUv3XdlgqlyWF8qVbIWnUmmvkAB4u6yPBE50XAqTqzLNCjbWS8QKAZPdgYOaqZHv6EE5LEJOc5NOK
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.12.2
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Wed, 12 Sep 2018 00:53:24 GMT
25
+ Server:
26
+ - Apache
27
+ Content-Length:
28
+ - '0'
29
+ Strict-Transport-Security:
30
+ - max-age=31536000;
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Robots-Tag:
36
+ - none
37
+ P3p:
38
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
39
+ body:
40
+ encoding: UTF-8
41
+ string: ''
42
+ http_version:
43
+ recorded_at: Wed, 12 Sep 2018 00:53:24 GMT
44
+ recorded_with: VCR 2.8.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: put
5
- uri: https://secure.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/status
5
+ uri: https://api.eu1.echosign.com/api/rest/v5/widgets/2AAABLblqZhD_6RpgbZh5ZVlLXz1H1kfVzw4vHB91MtmjNHBDorFqO0H3_cGzBudZxiWNzPXFzOc*/status
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{"value":"DISABLE","message":"Hey guys, hope you like this widget."}'
@@ -1,11 +1,11 @@
1
- require 'json'
2
- require "echosign/version"
3
- require 'echosign/client'
4
- require 'echosign/validatable'
5
- require 'echosign/credentials'
6
- require 'echosign/refresh'
7
- require 'echosign/request'
8
- require 'echosign/agreement'
9
- require 'echosign/user'
10
- require 'echosign/reminder'
11
- require 'echosign/widget'
1
+ require 'json'
2
+ require "echosign/version"
3
+ require 'echosign/client'
4
+ require 'echosign/validatable'
5
+ require 'echosign/credentials'
6
+ require 'echosign/refresh'
7
+ require 'echosign/request'
8
+ require 'echosign/agreement'
9
+ require 'echosign/user'
10
+ require 'echosign/reminder'
11
+ require 'echosign/widget'
@@ -6,7 +6,6 @@ require 'echosign/agreement/form_field_location'
6
6
 
7
7
  module Echosign
8
8
  class Agreement < Hash
9
-
10
9
  include Validatable
11
10
 
12
11
  attr_accessor :user_id, :user_email
@@ -16,19 +15,36 @@ module Echosign
16
15
  # @param [String] user_id ID of the user whom this agreement is made for
17
16
  # @param [String] user_email Email of the user whom this agreement is made for
18
17
  # @param [Hash] params SYMBOL-referenced Hash containing:
19
- # @option params [Array] :fileInfos A list of one or more files (or references to files) that will be sent out for signature. If more than one file is provided, they will be combined into one PDF before being sent out. Note: Only one of the four parameters in every FileInfo object must be specified. Populate the array with instances of {Echosign::Fileinfo Echosign::Fileinfo} (REQUIRED)
20
- # @option params [Array] :recipientSetInfos A list of one or more recipients. For regular (non-MegaSign) documents, there is no limit on the number of electronic signatures in a single document. Written signatures are limited to four per document. This limit includes the sender if the sender's signature is also required. Populate the array with instances of {Echosign::Recipient Echosign::Recipient} (REQUIRED)
21
- # @option params [String] :signatureFlow ['SENDER_SIGNATURE_NOT_REQUIRED' or 'SENDER_SIGNS_LAST' or 'SENDER_SIGNS_FIRST' or 'SEQUENTIAL' or 'PARALLEL']: Selects the workflow you would like to use - whether the sender needs to sign before the recipient, after the recipient, or not at all. The possible values for this variable are SENDER_SIGNATURE_NOT_REQUIRED, SENDER_SIGNS_LAST, SENDER_SIGNS_FIRST, SEQUENTIAL or PARALLEL. (REQUIRED)
22
- # @option params [String] :signatureType ['ESIGN' or 'WRITTEN']: Specifies the type of signature you would like to request - written or eSignature. The possible values are ESIGN or WRITTEN (REQUIRED)
23
- # @option params [String] :name The name of the agreement that will be used to identify it, in emails and on the website. (REQUIRED)
24
- # @return [Echosign::Agreement]
25
- def initialize(user_id=nil, user_email=nil, params)
18
+ # @option params [Array] :fileInfos A list of one or more files (or references to files) that will be sent out
19
+ # for signature. If more than one file is provided, they will be combined into one PDF before being sent out.
20
+ # Note: Only one of the four parameters in every FileInfo object must be specified. Populate the array with
21
+ # instances of {Echosign::Fileinfo Echosign::Fileinfo} (REQUIRED)
22
+ # @option params [Array] :recipientSetInfos A list of one or more recipients. For regular (non-MegaSign)
23
+ # documents, there is no limit on the number of electronic signatures in a single document. Written signatures
24
+ # are limited to four per document. This limit includes the sender if the sender's signature is also required.
25
+ # Populate the array with instances of {Echosign::Recipient Echosign::Recipient} (REQUIRED)
26
+ # @option params [String] :signatureFlow ['SENDER_SIGNATURE_NOT_REQUIRED' or 'SENDER_SIGNS_LAST' or
27
+ # 'SENDER_SIGNS_FIRST' or 'SEQUENTIAL' or 'PARALLEL']: Selects the workflow you would like to use - whether
28
+ # the sender needs to sign before the recipient, after the recipient, or not at all. The possible values for
29
+ # this variable are SENDER_SIGNATURE_NOT_REQUIRED, SENDER_SIGNS_LAST, SENDER_SIGNS_FIRST, SEQUENTIAL or
30
+ # PARALLEL. (REQUIRED)
31
+ # @option params [String] :signatureType ['ESIGN' or 'WRITTEN']: Specifies the type of signature you would like
32
+ # to request - written or eSignature. The possible values are ESIGN or WRITTEN (REQUIRED)
33
+ # @option params [String] :name The name of the agreement that will be used to identify it, in emails and on the
34
+ # website. (REQUIRED)
35
+ # @return [Echosign::Agreement]
36
+ def initialize(user_id = nil, user_email = nil, params)
26
37
  @user_id = user_id
27
38
  @user_email = user_email
28
- #TODO (cthomas) barf if user_id or user_email are blank
39
+ # TODO (cthomas) barf if user_id or user_email are blank
40
+ if params.has_key?(:recipients)
41
+ warn("NOTE: :recipients param in #{self.class}.new is deprecated; use :recipientSetInfos instead.\n" +
42
+ "#{self.class}.new called from #{Gem.location_of_caller.join(":")}")
43
+ params = params.dup
44
+ params[:recipientSetInfos] ||= params.delete :recipients
45
+ end
29
46
  require_keys([:signatureType, :recipientSetInfos, :signatureFlow, :fileInfos, :name], params)
30
47
  merge!({ documentCreationInfo: params })
31
48
  end
32
-
33
49
  end # class Agreement
34
50
  end # module Echosign
@@ -1,118 +1,125 @@
1
1
  module Echosign
2
-
3
2
  class Client
3
+ # Creates an agreement
4
+ #
5
+ # @param agreement [Echosign::Agreement]
6
+ # @return [String] Agreement ID
7
+ def create_agreement(agreement)
8
+ agreement_response = request(:create_agreement, agreement, agreement.user_id, agreement.user_email)
9
+ return agreement_response['agreementId'] if agreement_response.has_key?('agreementId')
4
10
 
5
- # Creates an agreement
6
- #
7
- # @param agreement [Echosign::Agreement]
8
- # @return [String] Agreement ID
9
- def create_agreement(agreement)
10
- agreement_response = Echosign::Request.create_agreement(agreement, token, agreement.user_id, agreement.user_email)
11
- agreement_response.fetch("agreementId")
12
- end
13
-
14
- # Gets list of agreements
15
- #
16
- # @param agreement [Echosign::Agreement]
17
- # @return [String] Agreement ID
18
- def get_agreements
19
- get_agreements_response = Echosign::Request.get_agreements(token)
20
- get_agreements_response.fetch("userAgreementList")
21
- end
11
+ raise "Error creating agreement - response was #{agreement_response}"
12
+ end
22
13
 
23
- # Gets detailed info on an agreement
24
- #
25
- # @param agreement_id [String] ID of agreement to retrieve info on.
26
- # @return [Hash] Detailed agreement info
27
- def agreement_info(agreement_id)
28
- Echosign::Request.agreement_info(token, agreement_id)
29
- end
14
+ # Gets list of agreements
15
+ #
16
+ # @return [Hash] An array of user agreement items
17
+ def get_agreements
18
+ get_agreements_response = request(:get_agreements)
19
+ get_agreements_response.fetch("userAgreementList")
20
+ end
30
21
 
31
- # Cancel agreement
32
- #
33
- # @param agreement_id [String] (REQUIRED)
34
- # @param notify_signer [Boolean] Whether to notify the signer by email of the cancellation. Default is false.
35
- # @param comment [String] Comment regarding this cancellation.
36
- # @return [String] Result of the operation
37
- def cancel_agreement(agreement_id, notify_signer=false, comment=nil)
38
- request_body = {
39
- "value" => "CANCEL",
40
- "notifySigner" => notify_signer
41
- }
42
- request_body.merge!(comment: comment) unless comment.nil?
22
+ # Gets detailed info on an agreement
23
+ #
24
+ # @param agreement_id [String] ID of agreement to retrieve info on.
25
+ # @return [Hash] Detailed agreement info
26
+ def agreement_info(agreement_id)
27
+ request(:agreement_info, agreement_id)
28
+ end
43
29
 
44
- agreement_status_response = Echosign::Request.update_agreement_status(token, agreement_id, request_body)
45
- agreement_status_response.fetch('result')
46
- end
30
+ # Cancel agreement
31
+ #
32
+ # @param agreement_id [String] (REQUIRED)
33
+ # @param notify_signer [Boolean] Whether to notify the signer by email of the cancellation. Default is false.
34
+ # @param comment [String] Comment regarding this cancellation.
35
+ # @return [String] Result of the operation
36
+ def cancel_agreement(agreement_id, notify_signer = false, comment = nil)
37
+ request_body = {
38
+ "value" => "CANCEL",
39
+ "notifySigner" => notify_signer
40
+ }
41
+ request_body[:comment] = comment unless comment.nil?
47
42
 
48
- # All documents relating to an agreement
49
- #
50
- # @param agreement_id [String] (REQUIRED)
51
- # @param recipient_email [String] The email address of the participant to be used to retrieve documents. (REQUIRED)
52
- # @param format [String] Content format of the supported documents. It can have two possible values ORIGINAL or CONVERTED_PDF. (REQUIRED)
53
- # @param version_id [String] Version of the agreement as provided by agreement_info(). If not provided, the latest version of the agreement is used.
54
- # @return [Array] Documents relating to agreement.
55
- def agreement_documents(agreement_id, recipient_email, format, version_id=nil)
56
- result = Echosign::Request.agreement_documents(token, agreement_id, recipient_email, format, version_id)
57
- end
43
+ agreement_status_response = request(:update_agreement_status, agreement_id, request_body)
44
+ agreement_status_response.fetch('result')
45
+ end
58
46
 
59
- # Retrieve a document file from an agreement
60
- #
61
- # @param agreement_id [String] (REQUIRED)
62
- # @param document_id [String] (REQUIRED)
63
- # @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
64
- # @return [String] Raw bytes from document file
65
- def agreement_document_file(agreement_id, document_id, file_path=nil)
66
- response = Echosign::Request.agreement_document_file(token, agreement_id, document_id)
67
- unless file_path.nil?
68
- file = File.new(file_path, 'wb')
69
- file.write(response)
70
- file.close
71
- end
72
- response
73
- end
47
+ # All documents relating to an agreement
48
+ #
49
+ # @param agreement_id [String] (REQUIRED)
50
+ # @param recipient_email [String] The email address of the participant to be used to retrieve documents. (REQUIRED)
51
+ # @param format [String] Content format of the supported documents. It can have two possible values ORIGINAL or
52
+ # CONVERTED_PDF. (REQUIRED)
53
+ # @param version_id [String] Version of the agreement as provided by agreement_info(). If not provided, the
54
+ # latest version of the agreement is used.
55
+ # @return [Array] Documents relating to agreement.
56
+ def agreement_documents(agreement_id, recipient_email, format, version_id = nil)
57
+ result = request(:agreement_documents, agreement_id, recipient_email, format, version_id)
58
+ end
74
59
 
75
- # Retrieves the URL for the eSign page for the current signer(s) of an agreement
76
- #
77
- # @param agreement_id [String] (REQUIRED)
78
- # @return [Hash] URL information for the eSign page of the agreement
79
- def agreement_signing_urls(agreement_id)
80
- response = Echosign::Request.agreement_signing_urls(token, agreement_id)
81
- end
60
+ # Retrieve a document file from an agreement
61
+ #
62
+ # @param agreement_id [String] (REQUIRED)
63
+ # @param document_id [String] (REQUIRED)
64
+ # @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
65
+ # @return [String] Raw bytes from document file
66
+ def agreement_document_file(agreement_id, document_id, file_path = nil)
67
+ response = request(:agreement_document_file, agreement_id, document_id)
68
+ unless file_path.nil?
69
+ file = File.new(file_path, 'wb')
70
+ file.write(response)
71
+ file.close
72
+ end
73
+ response
74
+ end
82
75
 
83
- # Gets a single combined PDF document for the documents associated with an agreement.
84
- #
85
- # @param agreement_id [String] (REQUIRED)
86
- # @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
87
- # @param versionId [String] The version identifier of agreement as provided by get_agreement. If not provided then latest version will be used
88
- # @param participantEmail [String] The email address of the participant to be used to retrieve documents. If none is given, the auth token will be used to determine the user
89
- # @param attachSupportingDocuments [Boolean] When set to YES, attach corresponding supporting documents to the signed agreement PDF. Default value of this parameter is true.
90
- # @param auditReport [Boolean] When set to YES, attach an audit report to the signed agreement PDF. Default value is false
91
- # @return [String] Raw bytes from document file
92
- def agreement_combined_pdf(agreement_id, file_path=nil, versionId=nil, participantEmail=nil, attachSupportingDocuments=true, auditReport=false)
93
- response = Echosign::Request.agreement_combined_pdf(token, agreement_id, versionId, participantEmail, attachSupportingDocuments, auditReport)
94
- unless file_path.nil?
95
- file = File.new(file_path, 'wb')
96
- file.write(response)
97
- file.close
98
- end
99
- response
100
- end
76
+ # Retrieves the URL for the eSign page for the current signer(s) of an agreement
77
+ #
78
+ # @param agreement_id [String] (REQUIRED)
79
+ # @return [Hash] URL information for the eSign page of the agreement
80
+ def agreement_signing_urls(agreement_id)
81
+ response = request(:agreement_signing_urls, agreement_id)
82
+ end
101
83
 
102
- # Retrieves library document audit trail file
103
- #
104
- # @param agreement_id [String] (REQUIRED)
105
- # @param file_path [String] File path where to save the CSV file. If no file path is given, nothing is saved to disk.
106
- # @return [String] Raw bytes representing CSV file
107
- def agreement_form_data(agreement_id, file_path=nil)
108
- response = Echosign::Request.agreement_form_data(token, agreement_id)
109
- unless file_path.nil?
110
- file = File.new(file_path, 'wb')
111
- file.write(response)
112
- file.close
113
- end
114
- response
115
- end
84
+ # Gets a single combined PDF document for the documents associated with an agreement.
85
+ #
86
+ # @param agreement_id [String] (REQUIRED)
87
+ # @param file_path [String] File path to save the document. If no file path is given, nothing is saved to disk.
88
+ # @param versionId [String] The version identifier of agreement as provided by get_agreement. If not provided
89
+ # then latest version will be used
90
+ # @param participantEmail [String] The email address of the participant to be used to retrieve documents. If
91
+ # none is given, the auth token will be used to determine the user
92
+ # @param attachSupportingDocuments [Boolean] When set to YES, attach corresponding supporting documents to the
93
+ # signed agreement PDF. Default value of this parameter is true.
94
+ # @param auditReport [Boolean] When set to YES, attach an audit report to the signed agreement PDF. Default
95
+ # value is false
96
+ # @return [String] Raw bytes from document file
97
+ def agreement_combined_pdf(agreement_id, file_path = nil, versionId = nil, participantEmail = nil,
98
+ attachSupportingDocuments = true, auditReport = false)
99
+ response = request(:agreement_combined_pdf, agreement_id, versionId, participantEmail, attachSupportingDocuments,
100
+ auditReport)
101
+ unless file_path.nil?
102
+ file = File.new(file_path, 'wb')
103
+ file.write(response)
104
+ file.close
105
+ end
106
+ response
107
+ end
116
108
 
109
+ # Retrieves library document audit trail file
110
+ #
111
+ # @param agreement_id [String] (REQUIRED)
112
+ # @param file_path [String] File path where to save the CSV file. If no file path is given, nothing is saved to
113
+ # disk.
114
+ # @return [String] Raw bytes representing CSV file
115
+ def agreement_form_data(agreement_id, file_path = nil)
116
+ response = request(:agreement_form_data, agreement_id)
117
+ unless file_path.nil?
118
+ file = File.new(file_path, 'wb')
119
+ file.write(response)
120
+ file.close
121
+ end
122
+ response
123
+ end
117
124
  end
118
125
  end