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
@@ -1,13 +1,11 @@
1
1
  module Echosign
2
-
3
2
  class RequiredParameterError < StandardError; end
4
3
  class ParameterError < StandardError; end
5
4
 
6
5
  module Validatable
7
-
8
6
  def require_keys(required_fields, params)
9
7
  required_fields.each do |field|
10
- validate_field(field, params)
8
+ validate_field(field, params)
11
9
  end
12
10
  end
13
11
 
@@ -15,18 +13,18 @@ module Echosign
15
13
  set_fields = 0
16
14
  field_group.each do |field|
17
15
  begin
18
- validate_field(field, params)
16
+ validate_field(field, params)
19
17
  rescue RequiredParameterError
20
18
  next
21
19
  else
22
20
  set_fields += 1
23
21
  end
24
22
  end
25
- raise ParameterError, "Exactly one of #{field_group.to_s} should be present" if set_fields != 1
23
+ raise ParameterError, "Exactly one of #{field_group} should be present" if set_fields != 1
26
24
  end
27
25
 
28
26
  # TODO (bernardworthy) A validator accepting a block for conditional execution
29
- # might be useful.
27
+ # might be useful.
30
28
  # Maybe require_keys should accept a block. Figure out later.
31
29
 
32
30
  def validate_field(field, params)
@@ -41,14 +39,12 @@ module Echosign
41
39
  private
42
40
 
43
41
  def required_error(field)
44
- raise RequiredParameterError, "Nil, empty or missing required parameter: #{field.to_s}"
42
+ raise RequiredParameterError, "Nil, empty or missing required parameter: #{field}"
45
43
  end
46
44
 
47
45
  # If blank? did not exist, we would need to invent it.
48
46
  def blank?(field)
49
- field.nil? || field.empty?
47
+ field.nil? || field.empty?
50
48
  end
51
-
52
49
  end
53
-
54
50
  end
@@ -1,3 +1,3 @@
1
1
  module Echosign
2
- VERSION = "1.0.2"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -7,31 +7,58 @@ require 'echosign/widget/widget_status'
7
7
 
8
8
  module Echosign
9
9
  class Widget < Hash
10
-
11
10
  include Validatable
12
11
 
13
12
  attr_reader :user_id, :user_email
14
13
 
15
14
  # Widget initialization object
16
- #
15
+ #
17
16
  # @param user_id [String] The ID of the user on whose behalf widget is being created.
18
- # @param user_email [String] The email address of the user on whose behalf widget is being created. If both X-User-Id and X-User-Email are provided then X-User-Id is given preference. If neither is specified then the user is inferred from the access token.
17
+ # @param user_email [String] The email address of the user on whose behalf widget is being created. If both
18
+ # X-User-Id and X-User-Email are provided then X-User-Id is given preference. If neither is specified then the
19
+ # user is inferred from the access token.
19
20
  # @param [Hash] params SYMBOL-referenced Hash containing: (REQUIRED)
20
- # @option params [String] :name The name of the widget that will be used to identify it, in emails and on the website (REQUIRED)
21
- # @option params [Array] :fileInfos Populate with instances of {Echosign::Fileinfo Echosign::Fileinfo}. A list of one or more files (or references to files) that will be used to create the widget. If more than one file is provided, they will be combined before the widget is created. Library documents are not permitted. Note: Only one of the four parameters in every Fileinfo object must be specified (REQUIRED)
22
- # @option param [String] :signatureFlow ['SENDER_SIGNATURE_NOT_REQUIRED' or 'SENDER_SIGNS_LAST']: 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 or SENDER_SIGNS_LAST (REQUIRED)
23
- # @option params [Array] :formFieldLayerTemplates Populate with instances of {Echosign::Fileinfo Echosign::Fileinfo}. Specifies the form field layer template or source of form fields to apply on the files in this transaction. If specified, the FileInfo for this parameter must refer to a form field layer template via libraryDocumentId or libraryDocumentName, or if specified via transientDocumentId or documentURL, it must be of a supported file type. Note: Only one of the four parameters in every FileInfo object must be specified.
24
- # @option params [Echosign::WidgetCompletionInfo] :widgetCompletionInfo URL and associated properties for the success page the user will be taken to after filling out the widget
25
- # @option params [String] :callbackInfo A publicly accessible url to which EchoSign will perform an HTTP PUT operation with the final signed PDF file. HTTP authentication is supported using standard embedded syntax - i.e. http://username:password@your.server.com/path/to/file. EchoSign can also communicate with your system using HTTP GET, every time there is a new agreement event. Please contact support@echosign.com if you wish to use this option.
26
- # @option params [Echosign::WidgetSecurityOption] :securityOptions Sets optional secondary security parameters for your widget
27
- # @option params [String] :locale The locale associated with this widget - specifies the language for the signing page and emails, for example en_US or fr_FR. If none specified, defaults to the language configured for the widget creator
21
+ # @option params [String] :name The name of the widget that will be used to identify it, in emails and on the
22
+ # website (REQUIRED)
23
+ # @option params [Array] :fileInfos Populate with instances of {Echosign::Fileinfo Echosign::Fileinfo}. A list
24
+ # of one or more files (or references to files) that will be used to create the widget. If more than one file
25
+ # is provided, they will be combined before the widget is created. Library documents are not permitted. Note:
26
+ # Only one of the four parameters in every Fileinfo object must be specified (REQUIRED)
27
+ # @option param [String] :signatureFlow ['SENDER_SIGNATURE_NOT_REQUIRED' or 'SENDER_SIGNS_LAST']: Selects the
28
+ # workflow you would like to use - whether the sender needs to sign before the recipient, after the recipient,
29
+ # or not at all. The possible values for this variable are SENDER_SIGNATURE_NOT_REQUIRED or SENDER_SIGNS_LAST
30
+ # (REQUIRED)
31
+ # @option params [Array] :formFieldLayerTemplates Populate with instances of {Echosign::Fileinfo
32
+ # Echosign::Fileinfo}. Specifies the form field layer template or source of form fields to apply on the files
33
+ # in this transaction. If specified, the FileInfo for this parameter must refer to a form field layer template
34
+ # via libraryDocumentId or libraryDocumentName, or if specified via transientDocumentId or documentURL, it
35
+ # must be of a supported file type. Note: Only one of the four parameters in every FileInfo object must be
36
+ # specified.
37
+ # @option params [Echosign::WidgetCompletionInfo] :widgetCompletionInfo URL and associated properties for the
38
+ # success page the user will be taken to after filling out the widget
39
+ # @option params [String] :callbackInfo A publicly accessible url to which EchoSign will perform an HTTP PUT
40
+ # operation with the final signed PDF file. HTTP authentication is supported using standard embedded syntax -
41
+ # i.e. http://username:password@your.server.com/path/to/file. EchoSign can also communicate with your system
42
+ # using HTTP GET, every time there is a new agreement event. Please contact support@echosign.com if you wish
43
+ # to use this option.
44
+ # @option params [Echosign::WidgetSecurityOption] :securityOptions Sets optional secondary security parameters
45
+ # for your widget
46
+ # @option params [String] :locale The locale associated with this widget - specifies the language for the
47
+ # signing page and emails, for example en_US or fr_FR. If none specified, defaults to the language configured
48
+ # for the widget creator
28
49
  # @option params [Echosign::CounterSignerInfo] :counterSigners A list of one or more counter signers
29
- # @option params [Echosign::WidgetVaultingInfo] :vaultingInfo Sets the vaulting properties that allows EchoSign to securely store documents with a vault provider
30
- # @option params [Echosign::WidgetMergefieldInfo] :mergeFieldInfo Optional default values for fields to merge into the document. The values will be presented to the signers for editable fields; for read-only fields the provided values will not be editable during the signing process. Merging data into fields is currently not supported when used with libraryDocumentId or libraryDocumentName. Only file and url are curently supported
31
- # @option params [Echosign::WidgetCompletionInfo] :widgetAuthFailureInfo URL and associated properties for the error page the user will be taken after failing to authenticate
32
- # @option params [Echosign::WidgetSignerSecurityOption] :widgetSignerSecurityOptions Security options that apply to widget signers
33
- def initialize(user_id=nil, user_email=nil, name, fileInfos, signatureFlow, widget_completion_info)
34
- # require_keys([:name, :fileInfos, :signatureFlow], params)
50
+ # @option params [Echosign::WidgetVaultingInfo] :vaultingInfo Sets the vaulting properties that allows EchoSign
51
+ # to securely store documents with a vault provider
52
+ # @option params [Echosign::WidgetMergefieldInfo] :mergeFieldInfo Optional default values for fields to merge
53
+ # into the document. The values will be presented to the signers for editable fields; for read-only fields the
54
+ # provided values will not be editable during the signing process. Merging data into fields is currently not
55
+ # supported when used with libraryDocumentId or libraryDocumentName. Only file and url are curently supported
56
+ # @option params [Echosign::WidgetCompletionInfo] :widgetAuthFailureInfo URL and associated properties for the
57
+ # error page the user will be taken after failing to authenticate
58
+ # @option params [Echosign::WidgetSignerSecurityOption] :widgetSignerSecurityOptions Security options that apply
59
+ # to widget signers
60
+ def initialize(user_id = nil, user_email = nil, params)
61
+ require_keys([:name, :fileInfos, :signatureFlow], params)
35
62
  @user_id = user_id
36
63
  @user_email = user_email
37
64
 
@@ -161,16 +188,15 @@ module Echosign
161
188
  # "signatureFlow": ""
162
189
  # }
163
190
  # }
164
-
165
- merge!({
166
- widgetCreationInfo: {
167
- name: name,
168
- fileInfos: fileInfos,
169
- signatureFlow: signatureFlow,
170
- widgetCompletion_Info: widget_completion_info
171
- }
172
- })
173
- end
174
191
 
192
+ merge!({
193
+ widgetCreationInfo: {
194
+ name: params[:name],
195
+ fileInfos: params[:fileInfos],
196
+ signatureFlow: params[:signatureFlow],
197
+ widgetCompletion_Info: params[:widget_completion_info]
198
+ }
199
+ })
200
+ end
175
201
  end
176
202
  end
@@ -1,68 +1,70 @@
1
1
  module Echosign
2
-
3
2
  class Client
4
-
5
- # Creates a widget and returns the Javascript snippet and URL to access the widget and widgetID in response to the client
6
- #
3
+ # Creates a widget and returns the Javascript snippet and URL to access the widget and widgetID in response to
4
+ # the client
5
+ #
7
6
  # @param widget [Echosign::Widget]
8
7
  # @return [Hash]
9
8
  def create_widget(widget)
10
- Echosign::Request.create_widget(token, widget)
9
+ request(:create_widget, widget)
11
10
  end
12
11
 
13
12
  # Personalize the widget to a signable document for a specific known user
14
- #
13
+ #
15
14
  # @param widget_id
16
15
  # @param personalization [Echosign::WidgetPersonalization]
17
16
  # @return [Hash] Operation result
18
17
  def personalize_widget(widget_id, personalization)
19
- Echosign::Request.personalize_widget(token, widget_id, personalization)
18
+ request(:personalize_widget, widget_id, personalization)
20
19
  end
21
20
 
22
21
  # Enables or Disables a widget
23
- #
22
+ #
24
23
  # @param widget_id
25
24
  # @param status [Echosign::WidgetStatus]
26
25
  # @return [Hash] Widget status
27
26
  def update_widget_status(widget_id, status)
28
- Echosign::Request.update_widget_status(token, widget_id, status)
27
+ request(:update_widget_status, widget_id, status)
29
28
  end
30
29
 
31
30
  # Retrieves widgets for a user
32
- #
31
+ #
33
32
  # @param user_id [String] The ID of the user whose widgets are being requested
34
- # @param user_email [String] The email address of the user whose widgets 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
33
+ # @param user_email [String] The email address of the user whose widgets are being requested. If both user_id
34
+ # and user_email are provided then user_id is given preference. If neither is specified then the user is
35
+ # inferred from the access token
35
36
  # @return [Hash] Widgets info
36
- def get_widgets(user_id=nil, user_email=nil)
37
- Echosign::Request.get_widgets(token, user_id, user_email)
37
+ def get_widgets(user_id = nil, user_email = nil)
38
+ request(:get_widgets, user_id, user_email)
38
39
  end
39
40
 
40
41
  # Retrieves the details of a widget
41
- #
42
+ #
42
43
  # @param widget_id
43
44
  # @return [Hash] Detailed widget info
44
45
  def get_widget(widget_id)
45
- Echosign::Request.get_widget(token, widget_id)
46
+ request(:get_widget, widget_id)
46
47
  end
47
48
 
48
49
  # Retrieves the IDs of the documents associated with widget.
49
- #
50
+ #
50
51
  # @param widget_id [String]
51
- # @param version_id [String] The version identifier of widget as provided by get_widget. If not provided then latest version will be used.
52
+ # @param version_id [String] The version identifier of widget as provided by get_widget. If not provided then
53
+ # latest version will be used.
52
54
  # @param participant_email [String] The email address of the participant to be used to retrieve documents
53
55
  # @return [Hash] Info about widget documents
54
- def get_widget_documents(widget_id, version_id=nil, participant_email=nil)
55
- Echosign::Request.get_widget_documents(token, widget_id, version_id, participant_email)
56
+ def get_widget_documents(widget_id, version_id = nil, participant_email = nil)
57
+ request(:get_widget_documents, widget_id, version_id, participant_email)
56
58
  end
57
59
 
58
60
  # Retrieves the file stream of a document of a widget
59
- #
61
+ #
60
62
  # @param widget_id [String]
61
63
  # @param document_id [String]
62
64
  # @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
63
65
  # @return [String] Raw file stream
64
- def get_widget_document_file(widget_id, document_id, file_path=nil)
65
- response = Echosign::Request.get_widget_document_file(token, widget_id, document_id)
66
+ def get_widget_document_file(widget_id, document_id, file_path = nil)
67
+ response = request(:get_widget_document_file, widget_id, document_id)
66
68
  unless file_path.nil?
67
69
  file = File.new(file_path, 'wb')
68
70
  file.write(response)
@@ -72,13 +74,13 @@ module Echosign
72
74
  end
73
75
 
74
76
  # Retrieves the audit trail of a widget identified by widgetId
75
- #
77
+ #
76
78
  # @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
77
79
  # @param widget_id [String]
78
80
  # @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
79
81
  # @return [String] Raw file stream
80
- def get_widget_audit_trail(widget_id, file_path=nil)
81
- response = Echosign::Request.get_widget_audit_trail(token, widget_id)
82
+ def get_widget_audit_trail(widget_id, file_path = nil)
83
+ response = request(:get_widget_audit_trail, widget_id)
82
84
  unless file_path.nil?
83
85
  file = File.new(file_path, 'wb')
84
86
  file.write(response)
@@ -88,13 +90,13 @@ module Echosign
88
90
  end
89
91
 
90
92
  # Gets a single combined PDF document for the documents associated with a widget.
91
- #
93
+ #
92
94
  # @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
93
95
  # @param widget_id [String]
94
96
  # @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
95
97
  # @return [String] Raw file stream
96
- def get_widget_combined_pdf(widget_id, file_path=nil)
97
- response = Echosign::Request.get_widget_combined_pdf(token, widget_id)
98
+ def get_widget_combined_pdf(widget_id, file_path = nil)
99
+ response = request(:get_widget_combined_pdf, widget_id)
98
100
  unless file_path.nil?
99
101
  file = File.new(file_path, 'wb')
100
102
  file.write(response)
@@ -104,13 +106,13 @@ module Echosign
104
106
  end
105
107
 
106
108
  # Retrieves data entered by the user into interactive form fields at the time they signed the widget
107
- #
109
+ #
108
110
  # @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
109
111
  # @param widget_id [String]
110
112
  # @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
111
113
  # @return [String] Raw file stream
112
- def get_widget_form_data(widget_id, file_path=nil)
113
- response = Echosign::Request.get_widget_form_data(token, widget_id)
114
+ def get_widget_form_data(widget_id, file_path = nil)
115
+ response = request(:get_widget_form_data, widget_id)
114
116
  unless file_path.nil?
115
117
  file = File.new(file_path, 'wb')
116
118
  file.write(response)
@@ -118,10 +120,5 @@ module Echosign
118
120
  end
119
121
  response
120
122
  end
121
-
122
-
123
-
124
-
125
123
  end
126
124
  end
127
-
@@ -1,19 +1,18 @@
1
1
  module Echosign
2
2
  class CounterSignerInfo < Hash
3
-
4
3
  include Validatable
5
4
 
6
5
  # Initialization object
7
- #
8
- # @param [Hash] params SYMBOL-referenced Hash containing:
6
+ #
7
+ # @param [Hash] params SYMBOL-referenced Hash containing:
9
8
  # @option params [String] :email Email of the recipient (REQUIRED)
10
9
  # @option params [String] :role ['SIGNER' or 'APPROVER']: Specify the role of recipient (REQUIRED)
11
10
 
12
- # @option params [Array] :securityOptions Populate with instances of {Echosign::WidgetSignerSecurityOption Echosign::WidgetSignerSecurityOption} Security options that apply to the counter signers
11
+ # @option params [Array] :securityOptions Populate with instances of {Echosign::WidgetSignerSecurityOption
12
+ # Echosign::WidgetSignerSecurityOption} Security options that apply to the counter signers
13
13
  def initialize(params)
14
14
  require_keys([:email, :role], params)
15
15
  merge!(params)
16
16
  end
17
-
18
17
  end
19
18
  end
@@ -1,15 +1,15 @@
1
1
  module Echosign::Request
2
-
3
- # Creates a widget and returns the Javascript snippet and URL to access the widget and widgetID in response to the client
4
- #
2
+ # Creates a widget and returns the Javascript snippet and URL to access the widget and widgetID in response to
3
+ # the client
4
+ #
5
5
  # @param token [String] Auth token
6
6
  # @param widget [Echosign::Widget]
7
7
  # @return [Hash]
8
- def self.create_widget(token, widget)
9
- endpoint = ENDPOINT.fetch(:widget)
10
- headers = { 'Access-Token' => token}
11
- headers.merge!('X-User-Id' => widget.user_id) unless widget.user_id.nil?
12
- headers.merge!('X-User-Email' => widget.user_email) unless widget.user_email.nil?
8
+ def self.create_widget(token, base_uri, widget)
9
+ endpoint = ENDPOINT.fetch(:widget, base_uri)
10
+ headers = { 'Access-Token' => token }
11
+ headers['X-User-Id'] = widget.user_id unless widget.user_id.nil?
12
+ headers['X-User-Email'] = widget.user_email unless widget.user_email.nil?
13
13
  response = post(endpoint, widget, headers)
14
14
  JSON.parse(response.body)
15
15
  end
@@ -20,20 +20,10 @@ module Echosign::Request
20
20
  # @param widget_id [String]
21
21
  # @param personalization [Echosign::WidgetPersonalization]
22
22
  # @return [Hash] Response body
23
- def self.personalize_widget(token, widget_id, personalization)
23
+ def self.personalize_widget(token, base_uri, widget_id, personalization)
24
24
  headers = { 'Access-Token' => token }
25
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/personalize"
26
-
27
- begin
28
- response = HTTParty.put(
29
- endpoint,
30
- personalization.to_json,
31
- headers
32
- )
33
- rescue Exception => error
34
- raise_error(error)
35
- end
36
-
25
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/personalize"
26
+ response = put(endpoint, personalization.to_json, headers)
37
27
  JSON.parse(response.body)
38
28
  end
39
29
 
@@ -43,20 +33,10 @@ module Echosign::Request
43
33
  # @param widget_id [String]
44
34
  # @param status [Echosign::WidgetStatus]
45
35
  # @return [Hash] Response body
46
- def self.update_widget_status(token, widget_id, status)
36
+ def self.update_widget_status(token, base_uri, widget_id, status)
47
37
  headers = { 'Access-Token' => token }
48
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/status"
49
-
50
- begin
51
- response = HTTParty.put(
52
- endpoint,
53
- status.to_json,
54
- headers
55
- )
56
- rescue Exception => error
57
- raise_error(error)
58
- end
59
-
38
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/status"
39
+ response = put(endpoint, status.to_json, headers)
60
40
  JSON.parse(response.body)
61
41
  end
62
42
 
@@ -66,11 +46,11 @@ module Echosign::Request
66
46
  # @param user_id [String]
67
47
  # @param user_email [String]
68
48
  # @return [Hash] Response body
69
- def self.get_widgets(token, user_id=nil, user_email=nil)
49
+ def self.get_widgets(token, base_uri, user_id = nil, user_email = nil)
70
50
  headers = { 'Access-Token' => token }
71
- headers.merge!('X-User-Id' => user_id) unless user_id.nil?
72
- headers.merge!('X-User-Email' => user_email) unless user_email.nil?
73
- endpoint = "#{ENDPOINT.fetch(:widget)}"
51
+ headers['X-User-Id'] = user_id unless user_id.nil?
52
+ headers['X-User-Email'] = user_email unless user_email.nil?
53
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}"
74
54
  response = get(endpoint, headers)
75
55
  JSON.parse(response.body)
76
56
  end
@@ -79,9 +59,9 @@ module Echosign::Request
79
59
  #
80
60
  # @param widget_id [String]
81
61
  # @return [Hash] Response body
82
- def self.get_widget(token, widget_id)
62
+ def self.get_widget(token, base_uri, widget_id)
83
63
  headers = { 'Access-Token' => token }
84
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}"
64
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}"
85
65
  response = get(endpoint, headers)
86
66
  JSON.parse(response.body)
87
67
  end
@@ -90,9 +70,9 @@ module Echosign::Request
90
70
  #
91
71
  # @param widget_id [String]
92
72
  # @return [Hash] Response body
93
- def self.get_widget_documents(token, widget_id, version_id=nil, participant_email=nil)
73
+ def self.get_widget_documents(token, base_uri, widget_id, version_id = nil, participant_email = nil)
94
74
  headers = { 'Access-Token' => token }
95
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/documents"
75
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/documents"
96
76
  endpoint << add_query(endpoint, "versionId=#{version_id}") unless version_id.nil?
97
77
  endpoint << add_query(endpoint, "participantEmail=#{participant_email}") unless participant_email.nil?
98
78
  response = get(endpoint, headers)
@@ -103,9 +83,9 @@ module Echosign::Request
103
83
  #
104
84
  # @param widget_id [String]
105
85
  # @return [Hash] Response body
106
- def self.get_widget_document_file(token, widget_id, document_id)
86
+ def self.get_widget_document_file(token, base_uri, widget_id, document_id)
107
87
  headers = { 'Access-Token' => token }
108
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/documents/#{document_id}"
88
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/documents/#{document_id}"
109
89
  response = get(endpoint, headers)
110
90
  end
111
91
 
@@ -113,9 +93,9 @@ module Echosign::Request
113
93
  #
114
94
  # @param widget_id [String]
115
95
  # @return [Hash] Response body
116
- def self.get_widget_audit_trail(token, widget_id)
96
+ def self.get_widget_audit_trail(token, base_uri, widget_id)
117
97
  headers = { 'Access-Token' => token }
118
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/auditTrail"
98
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/auditTrail"
119
99
  response = get(endpoint, headers)
120
100
  end
121
101
 
@@ -123,13 +103,9 @@ module Echosign::Request
123
103
  #
124
104
  # @param widget_id [String]
125
105
  # @return [Hash] Response body
126
- def self.get_widget_form_data(token, widget_id)
106
+ def self.get_widget_form_data(token, base_uri, widget_id)
127
107
  headers = { 'Access-Token' => token }
128
- endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/formData"
108
+ endpoint = "#{ENDPOINT.fetch(:widget, base_uri)}/#{widget_id}/formData"
129
109
  response = get(endpoint, headers)
130
110
  end
131
-
132
-
133
-
134
-
135
111
  end