echochamber 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +79 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +12 -0
- data/doc/Echochamber.html +131 -0
- data/doc/Echochamber/Agreement.html +529 -0
- data/doc/Echochamber/Agreement/UrlFileInfo.html +263 -0
- data/doc/Echochamber/Client.html +4161 -0
- data/doc/Echochamber/CounterSignerInfo.html +265 -0
- data/doc/Echochamber/Credentials.html +330 -0
- data/doc/Echochamber/Credentials/CredentialsError.html +123 -0
- data/doc/Echochamber/Fileinfo.html +303 -0
- data/doc/Echochamber/InvalidParameterError.html +123 -0
- data/doc/Echochamber/ParameterError.html +123 -0
- data/doc/Echochamber/PhoneInfo.html +279 -0
- data/doc/Echochamber/Recipient.html +309 -0
- data/doc/Echochamber/RecipientSecurityOption.html +294 -0
- data/doc/Echochamber/Reminder.html +277 -0
- data/doc/Echochamber/Request.html +4167 -0
- data/doc/Echochamber/Request/Failure.html +123 -0
- data/doc/Echochamber/RequiredParameterError.html +123 -0
- data/doc/Echochamber/UrlFileInfo.html +295 -0
- data/doc/Echochamber/User.html +420 -0
- data/doc/Echochamber/Validatable.html +355 -0
- data/doc/Echochamber/Validator.html +180 -0
- data/doc/Echochamber/Widget.html +654 -0
- data/doc/Echochamber/WidgetCompletionInfo.html +309 -0
- data/doc/Echochamber/WidgetPersonalization.html +326 -0
- data/doc/Echochamber/WidgetSecurityOption.html +359 -0
- data/doc/Echochamber/WidgetSignerSecurityOption.html +296 -0
- data/doc/Echochamber/WidgetStatus.html +314 -0
- data/doc/Echochamber/WidgetVaultingInfo.html +265 -0
- data/doc/_index.html +338 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +157 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +157 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +581 -0
- data/doc/top-level-namespace.html +112 -0
- data/echochamber.gemspec +35 -0
- data/features/support/env.rb +8 -0
- data/fixtures/agreement.pdf +0 -0
- data/fixtures/vcr_cassettes/agreement_combined_pdf.yml +1465 -0
- data/fixtures/vcr_cassettes/agreement_document_file.yml +1465 -0
- data/fixtures/vcr_cassettes/agreement_documents.yml +42 -0
- data/fixtures/vcr_cassettes/agreement_form_data.yml +44 -0
- data/fixtures/vcr_cassettes/agreement_info.yml +50 -0
- data/fixtures/vcr_cassettes/agreement_signing_urls.yml +42 -0
- data/fixtures/vcr_cassettes/audit_trail_pdf.yml +1643 -0
- data/fixtures/vcr_cassettes/cancel_agreement.yml +46 -0
- data/fixtures/vcr_cassettes/create_agreement.yml +50 -0
- data/fixtures/vcr_cassettes/create_reminder.yml +47 -0
- data/fixtures/vcr_cassettes/create_transient_document.yml +716 -0
- data/fixtures/vcr_cassettes/create_user.yml +50 -0
- data/fixtures/vcr_cassettes/create_widget.yml +48 -0
- data/fixtures/vcr_cassettes/get_agreements.yml +46 -0
- data/fixtures/vcr_cassettes/get_library_document.yml +45 -0
- data/fixtures/vcr_cassettes/get_library_document_data.yml +1191 -0
- data/fixtures/vcr_cassettes/get_library_document_file.yml +42 -0
- data/fixtures/vcr_cassettes/get_library_documents.yml +47 -0
- data/fixtures/vcr_cassettes/get_token.yml +44 -0
- data/fixtures/vcr_cassettes/get_user.yml +46 -0
- data/fixtures/vcr_cassettes/get_users.yml +43 -0
- data/fixtures/vcr_cassettes/get_widget.yml +49 -0
- data/fixtures/vcr_cassettes/get_widget_document_file.yml +2682 -0
- data/fixtures/vcr_cassettes/get_widget_documents.yml +44 -0
- data/fixtures/vcr_cassettes/get_widgets.yml +50 -0
- data/fixtures/vcr_cassettes/library_combined_document.yml +2197 -0
- data/fixtures/vcr_cassettes/library_document_audit_trail.yml +1570 -0
- data/fixtures/vcr_cassettes/personalize_widget.yml +47 -0
- data/fixtures/vcr_cassettes/update_widget_status.yml +46 -0
- data/lib/echochamber.rb +10 -0
- data/lib/echochamber/agreement.rb +32 -0
- data/lib/echochamber/agreement/client.rb +118 -0
- data/lib/echochamber/agreement/fileinfo.rb +20 -0
- data/lib/echochamber/agreement/phone_info.rb +19 -0
- data/lib/echochamber/agreement/recipient.rb +23 -0
- data/lib/echochamber/agreement/recipient_security_option.rb +20 -0
- data/lib/echochamber/agreement/request.rb +142 -0
- data/lib/echochamber/agreement/url_file_info.rb +18 -0
- data/lib/echochamber/client.rb +82 -0
- data/lib/echochamber/credentials.rb +33 -0
- data/lib/echochamber/library_documents/client.rb +83 -0
- data/lib/echochamber/library_documents/request.rb +78 -0
- data/lib/echochamber/reminder.rb +17 -0
- data/lib/echochamber/request.rb +141 -0
- data/lib/echochamber/user.rb +29 -0
- data/lib/echochamber/validatable.rb +54 -0
- data/lib/echochamber/version.rb +3 -0
- data/lib/echochamber/widget.rb +42 -0
- data/lib/echochamber/widget/client.rb +127 -0
- data/lib/echochamber/widget/counter_signer_info.rb +19 -0
- data/lib/echochamber/widget/request.rb +135 -0
- data/lib/echochamber/widget/widget_completion_info.rb +19 -0
- data/lib/echochamber/widget/widget_personalization.rb +21 -0
- data/lib/echochamber/widget/widget_security_option.rb +22 -0
- data/lib/echochamber/widget/widget_signer_security_option.rb +18 -0
- data/lib/echochamber/widget/widget_status.rb +20 -0
- data/lib/echochamber/widget/widget_vaulting_info.rb +16 -0
- data/spec/lib/agreement/client_spec.rb +157 -0
- data/spec/lib/client_spec.rb +78 -0
- data/spec/lib/library_documents/client_spec.rb +71 -0
- data/spec/lib/request_spec.rb +18 -0
- data/spec/lib/shared_client.rb +22 -0
- data/spec/lib/user_spec.rb +6 -0
- data/spec/lib/validatable_spec.rb +110 -0
- data/spec/lib/version_spec.rb +7 -0
- data/spec/lib/widget/client_spec.rb +154 -0
- data/spec/spec_helper.rb +21 -0
- metadata +344 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module Echochamber
|
2
|
+
class User < Hash
|
3
|
+
|
4
|
+
include Validatable
|
5
|
+
|
6
|
+
# Creates a user for the current application
|
7
|
+
#
|
8
|
+
# @param [Hash] params SYMBOL-referenced Hash containing:
|
9
|
+
# @option params [String] :email User's email address (REQUIRED)
|
10
|
+
# @option params [String] :password The new user's password (REQUIRED)
|
11
|
+
# @option params [String] :firstName The first name of the new user (REQUIRED)
|
12
|
+
# @option params [String] :lastName The last name of the new user (REQUIRED)
|
13
|
+
# @option params [String] :optIn 'YES' or 'NO' or 'UNKNOWN': Whether or not the user has opted in to recieve marketing information from EchoSign and its partners. Default value is UNKNOWN
|
14
|
+
# @option params [String] :groupId Group in which the new user should be added. It can be obtained through GET /users call. Default is Group of the user making this call. The user is inferred from the access_token header
|
15
|
+
# @option params [String] :title The new user's job title
|
16
|
+
# @option params [String] :phone The phone number of the new user
|
17
|
+
# @option params [String] :company The name of the new user's company
|
18
|
+
# @option params [String] :customField1 You can choose to use custom fields to record additional information about your new users. These fields are, however, available only with customized implementations - please contact EchoSign if you would like to make use of this functionality
|
19
|
+
# @option params [String] :customField2 You can choose to use custom fields to record additional information about your new users. These fields are, however, available only with customized implementations - please contact EchoSign if you would like to make use of this functionality
|
20
|
+
# @option params [String] :customField3 You can choose to use custom fields to record additional information about your new users. These fields are, however, available only with customized implementations - please contact EchoSign if you would like to make use of this functionality
|
21
|
+
# @return [String] User ID
|
22
|
+
|
23
|
+
def initialize(params)
|
24
|
+
require_keys([:firstName, :lastName, :email, :password], params)
|
25
|
+
merge!(params)
|
26
|
+
end
|
27
|
+
|
28
|
+
end # class User
|
29
|
+
end # module Echochamber
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Echochamber
|
2
|
+
|
3
|
+
class RequiredParameterError < StandardError; end
|
4
|
+
class ParameterError < StandardError; end
|
5
|
+
|
6
|
+
module Validatable
|
7
|
+
|
8
|
+
def require_keys(required_fields, params)
|
9
|
+
required_fields.each do |field|
|
10
|
+
validate_field(field, params)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def require_exactly_one(field_group, params)
|
15
|
+
set_fields = 0
|
16
|
+
field_group.each do |field|
|
17
|
+
begin
|
18
|
+
validate_field(field, params)
|
19
|
+
rescue RequiredParameterError
|
20
|
+
next
|
21
|
+
else
|
22
|
+
set_fields += 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
raise ParameterError, "Exactly one of #{field_group.to_s} should be present" if set_fields != 1
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO (kayagoban) A validator accepting a block for conditional execution
|
29
|
+
# might be useful.
|
30
|
+
# Maybe require_keys should accept a block. Figure out later.
|
31
|
+
|
32
|
+
def validate_field(field, params)
|
33
|
+
begin
|
34
|
+
value = params.fetch(field)
|
35
|
+
required_error(field) if value.nil? || value.empty?
|
36
|
+
rescue KeyError
|
37
|
+
required_error(field)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def required_error(field)
|
44
|
+
raise RequiredParameterError, "Nil, empty or missing required parameter: #{field.to_s}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# If blank? did not exist, we would need to invent it.
|
48
|
+
def blank?(field)
|
49
|
+
field.nil? || field.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'echochamber/widget/widget_completion_info'
|
2
|
+
require 'echochamber/widget/widget_security_option'
|
3
|
+
require 'echochamber/widget/widget_signer_security_option'
|
4
|
+
require 'echochamber/widget/widget_vaulting_info'
|
5
|
+
require 'echochamber/widget/widget_personalization'
|
6
|
+
require 'echochamber/widget/widget_status'
|
7
|
+
|
8
|
+
module Echochamber
|
9
|
+
class Widget < Hash
|
10
|
+
|
11
|
+
include Validatable
|
12
|
+
|
13
|
+
attr_reader :user_id, :user_email
|
14
|
+
|
15
|
+
# Widget initialization object
|
16
|
+
#
|
17
|
+
# @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.
|
19
|
+
# @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 {Echochamber::Fileinfo Echochamber::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 {Echochamber::Fileinfo Echochamber::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 [Echochamber::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 [Echochamber::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
|
28
|
+
# @option params [Echochamber::CounterSignerInfo] :counterSigners A list of one or more counter signers
|
29
|
+
# @option params [Echochamber::WidgetVaultingInfo] :vaultingInfo Sets the vaulting properties that allows EchoSign to securely store documents with a vault provider
|
30
|
+
# @option params [Echochamber::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 [Echochamber::WidgetCompletionInfo] :widgetAuthFailureInfo URL and associated properties for the error page the user will be taken after failing to authenticate
|
32
|
+
# @option params [Echochamber::WidgetSignerSecurityOption] :widgetSignerSecurityOptions Security options that apply to widget signers
|
33
|
+
def initialize(user_id=nil, user_email=nil, params)
|
34
|
+
require_keys([:name, :fileInfos, :signatureFlow], params)
|
35
|
+
@user_id = user_id
|
36
|
+
@user_email = user_email
|
37
|
+
|
38
|
+
merge!({ widgetCreationInfo: params })
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Echochamber
|
2
|
+
|
3
|
+
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
|
+
#
|
7
|
+
# @param widget [Echochamber::Widget]
|
8
|
+
# @return [Hash]
|
9
|
+
def create_widget(widget)
|
10
|
+
Echochamber::Request.create_widget(token, widget)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Personalize the widget to a signable document for a specific known user
|
14
|
+
#
|
15
|
+
# @param widget_id
|
16
|
+
# @param personalization [Echochamber::WidgetPersonalization]
|
17
|
+
# @return [Hash] Operation result
|
18
|
+
def personalize_widget(widget_id, personalization)
|
19
|
+
Echochamber::Request.personalize_widget(token, widget_id, personalization)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Enables or Disables a widget
|
23
|
+
#
|
24
|
+
# @param widget_id
|
25
|
+
# @param status [Echochamber::WidgetStatus]
|
26
|
+
# @return [Hash] Widget status
|
27
|
+
def update_widget_status(widget_id, status)
|
28
|
+
Echochamber::Request.update_widget_status(token, widget_id, status)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieves widgets for a user
|
32
|
+
#
|
33
|
+
# @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
|
35
|
+
# @return [Hash] Widgets info
|
36
|
+
def get_widgets(user_id=nil, user_email=nil)
|
37
|
+
Echochamber::Request.get_widgets(token, user_id, user_email)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retrieves the details of a widget
|
41
|
+
#
|
42
|
+
# @param widget_id
|
43
|
+
# @return [Hash] Detailed widget info
|
44
|
+
def get_widget(widget_id)
|
45
|
+
Echochamber::Request.get_widget(token, widget_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Retrieves the IDs of the documents associated with widget.
|
49
|
+
#
|
50
|
+
# @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 participant_email [String] The email address of the participant to be used to retrieve documents
|
53
|
+
# @return [Hash] Info about widget documents
|
54
|
+
def get_widget_documents(widget_id, version_id=nil, participant_email=nil)
|
55
|
+
Echochamber::Request.get_widget_documents(token, widget_id, version_id, participant_email)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Retrieves the file stream of a document of a widget
|
59
|
+
#
|
60
|
+
# @param widget_id [String]
|
61
|
+
# @param document_id [String]
|
62
|
+
# @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
|
63
|
+
# @return [String] Raw file stream
|
64
|
+
def get_widget_document_file(widget_id, document_id, file_path=nil)
|
65
|
+
response = Echochamber::Request.get_widget_document_file(token, widget_id, document_id)
|
66
|
+
unless file_path.nil?
|
67
|
+
file = File.new(file_path, 'wb')
|
68
|
+
file.write(response)
|
69
|
+
file.close
|
70
|
+
end
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieves the audit trail of a widget identified by widgetId
|
75
|
+
#
|
76
|
+
# @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
|
77
|
+
# @param widget_id [String]
|
78
|
+
# @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
|
79
|
+
# @return [String] Raw file stream
|
80
|
+
def get_widget_audit_trail(widget_id, file_path=nil)
|
81
|
+
response = Echochamber::Request.get_widget_audit_trail(token, widget_id)
|
82
|
+
unless file_path.nil?
|
83
|
+
file = File.new(file_path, 'wb')
|
84
|
+
file.write(response)
|
85
|
+
file.close
|
86
|
+
end
|
87
|
+
response
|
88
|
+
end
|
89
|
+
|
90
|
+
# Gets a single combined PDF document for the documents associated with a widget.
|
91
|
+
#
|
92
|
+
# @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
|
93
|
+
# @param widget_id [String]
|
94
|
+
# @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
|
95
|
+
# @return [String] Raw file stream
|
96
|
+
def get_widget_combined_pdf(widget_id, file_path=nil)
|
97
|
+
response = Echochamber::Request.get_widget_combined_pdf(token, widget_id)
|
98
|
+
unless file_path.nil?
|
99
|
+
file = File.new(file_path, 'wb')
|
100
|
+
file.write(response)
|
101
|
+
file.close
|
102
|
+
end
|
103
|
+
response
|
104
|
+
end
|
105
|
+
|
106
|
+
# Retrieves data entered by the user into interactive form fields at the time they signed the widget
|
107
|
+
#
|
108
|
+
# @note SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE
|
109
|
+
# @param widget_id [String]
|
110
|
+
# @param file_path [String] File path where to save the document. If none is given, nothing will be saved to file.
|
111
|
+
# @return [String] Raw file stream
|
112
|
+
def get_widget_form_data(widget_id, file_path=nil)
|
113
|
+
response = Echochamber::Request.get_widget_form_data(token, widget_id)
|
114
|
+
unless file_path.nil?
|
115
|
+
file = File.new(file_path, 'wb')
|
116
|
+
file.write(response)
|
117
|
+
file.close
|
118
|
+
end
|
119
|
+
response
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Echochamber
|
2
|
+
class CounterSignerInfo < Hash
|
3
|
+
|
4
|
+
include Validatable
|
5
|
+
|
6
|
+
# Initialization object
|
7
|
+
#
|
8
|
+
# @param [Hash] params SYMBOL-referenced Hash containing:
|
9
|
+
# @option params [String] :email Email of the recipient (REQUIRED)
|
10
|
+
# @option params [String] :role ['SIGNER' or 'APPROVER']: Specify the role of recipient (REQUIRED)
|
11
|
+
|
12
|
+
# @option params [Array] :securityOptions Populate with instances of {Echochamber::WidgetSignerSecurityOption Echochamber::WidgetSignerSecurityOption} Security options that apply to the counter signers
|
13
|
+
def initialize(params)
|
14
|
+
require_keys([:email, :role], params)
|
15
|
+
merge!(params)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module Echochamber::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
|
+
#
|
5
|
+
# @param token [String] Auth token
|
6
|
+
# @param widget [Echochamber::Widget]
|
7
|
+
# @return [Hash]
|
8
|
+
def self.create_widget(token, widget)
|
9
|
+
endpoint = ENDPOINT.fetch(:widget)
|
10
|
+
headers = { :content_type => :json, :accept => :json, '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?
|
13
|
+
response = post(endpoint, widget, headers)
|
14
|
+
JSON.parse(response.body)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Performs REST PUT /agreement/:id operation
|
18
|
+
#
|
19
|
+
# @param token [String] Auth Token
|
20
|
+
# @param widget_id [String]
|
21
|
+
# @param personalization [Echochamber::WidgetPersonalization]
|
22
|
+
# @return [Hash] Response body
|
23
|
+
def self.personalize_widget(token, widget_id, personalization)
|
24
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
25
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/personalize"
|
26
|
+
|
27
|
+
begin
|
28
|
+
response = RestClient.put(
|
29
|
+
endpoint,
|
30
|
+
personalization.to_json,
|
31
|
+
headers
|
32
|
+
)
|
33
|
+
rescue Exception => error
|
34
|
+
raise_error(error)
|
35
|
+
end
|
36
|
+
|
37
|
+
JSON.parse(response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Performs REST PUT /agreement/:id operation
|
41
|
+
#
|
42
|
+
# @param token [String] Auth Token
|
43
|
+
# @param widget_id [String]
|
44
|
+
# @param status [Echochamber::WidgetStatus]
|
45
|
+
# @return [Hash] Response body
|
46
|
+
def self.update_widget_status(token, widget_id, status)
|
47
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
48
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/status"
|
49
|
+
|
50
|
+
begin
|
51
|
+
response = RestClient.put(
|
52
|
+
endpoint,
|
53
|
+
status.to_json,
|
54
|
+
headers
|
55
|
+
)
|
56
|
+
rescue Exception => error
|
57
|
+
raise_error(error)
|
58
|
+
end
|
59
|
+
|
60
|
+
JSON.parse(response.body)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Performs GET /widgets operation
|
64
|
+
#
|
65
|
+
# @param token [String] Auth Token
|
66
|
+
# @param user_id [String]
|
67
|
+
# @param user_email [String]
|
68
|
+
# @return [Hash] Response body
|
69
|
+
def self.get_widgets(token, user_id=nil, user_email=nil)
|
70
|
+
headers = { :content_type => :json, :accept => :json, '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)}"
|
74
|
+
response = get(endpoint, headers)
|
75
|
+
JSON.parse(response.body)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Performs GET /widget operation
|
79
|
+
#
|
80
|
+
# @param widget_id [String]
|
81
|
+
# @return [Hash] Response body
|
82
|
+
def self.get_widget(token, widget_id)
|
83
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
84
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}"
|
85
|
+
response = get(endpoint, headers)
|
86
|
+
JSON.parse(response.body)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Performs GET /widget/:id/documents operation
|
90
|
+
#
|
91
|
+
# @param widget_id [String]
|
92
|
+
# @return [Hash] Response body
|
93
|
+
def self.get_widget_documents(token, widget_id, version_id=nil, participant_email=nil)
|
94
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
95
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/documents"
|
96
|
+
endpoint << add_query(endpoint, "versionId=#{version_id}") unless version_id.nil?
|
97
|
+
endpoint << add_query(endpoint, "participantEmail=#{participant_email}") unless participant_email.nil?
|
98
|
+
response = get(endpoint, headers)
|
99
|
+
JSON.parse(response.body)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Performs GET /widget/:id/documents/:id operation
|
103
|
+
#
|
104
|
+
# @param widget_id [String]
|
105
|
+
# @return [Hash] Response body
|
106
|
+
def self.get_widget_document_file(token, widget_id, document_id)
|
107
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
108
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/documents/#{document_id}"
|
109
|
+
response = get(endpoint, headers)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Performs GET /widget/:id/auditTrail
|
113
|
+
#
|
114
|
+
# @param widget_id [String]
|
115
|
+
# @return [Hash] Response body
|
116
|
+
def self.get_widget_audit_trail(token, widget_id)
|
117
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
118
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/auditTrail"
|
119
|
+
response = get(endpoint, headers)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Performs GET /widget/:id/formData
|
123
|
+
#
|
124
|
+
# @param widget_id [String]
|
125
|
+
# @return [Hash] Response body
|
126
|
+
def self.get_widget_form_data(token, widget_id)
|
127
|
+
headers = { :content_type => :json, :accept => :json, 'Access-Token' => token }
|
128
|
+
endpoint = "#{ENDPOINT.fetch(:widget)}/#{widget_id}/formData"
|
129
|
+
response = get(endpoint, headers)
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Echochamber
|
2
|
+
class WidgetCompletionInfo < Hash
|
3
|
+
|
4
|
+
include Validatable
|
5
|
+
|
6
|
+
# Widget initialization object
|
7
|
+
#
|
8
|
+
# @param [Hash] params SYMBOL-referenced Hash containing:
|
9
|
+
# @option params [String] :url A publicly accessible url to which the user will be sent after successfully completing the widget. If the URL you provide includes information that allows you to identify the specific transaction, such as your own unique identifier, you can use the browser request to this URL as a callback to notify you that this transaction is completed. In addition, EchoSign will append a documentKey parameter to the URL which will contain the EchoSign DocumentKey for this signed widget, but only if the sender is the same as the API key user. Your application can use this value to get the form data for this widget. (REQUIRED)
|
10
|
+
# @option params [Boolean] :deframe If deframe is false, the success page will be shown inside the widget frame. If deframe is true, the success page will be shown in the full browser window. Note that if this widget is loaded through javascript returned from this end point, browser security restrictions do not permit automatic redirection in the full browser window, so if deframe is true the user will instead just see a link to the success page. We recommend this scenario be avoided - in other words, setting deframe to false is recommended for this case.
|
11
|
+
# @option params [Fixnum] :delay The delay (in seconds) before the user is taken to the success page. If this value is greater than 0, the user will first see the standard EchoSign success message, and then after a delay will be redirected to your success page. Note that this parameter has no effect for widgets loaded with javascript when deframe is true
|
12
|
+
def initialize(params)
|
13
|
+
require_keys([:url])
|
14
|
+
merge!(params)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Echochamber
|
2
|
+
class WidgetPersonalization < Hash
|
3
|
+
|
4
|
+
include Validatable
|
5
|
+
|
6
|
+
# Initialization object
|
7
|
+
#
|
8
|
+
# @option params [String] :email (string): The email address of the person who will be receiving this widget (REQUIRED)
|
9
|
+
# expiration (date, optional): Expiration date for the personalization of this widget. After this date, the identity of the signer will not be assumed by EchoSign.,
|
10
|
+
# @option params [String] :expiration Expiration date for the personalization of this widget. After this date, the identity of the signer will not be assumed by EchoSign.
|
11
|
+
# @option params [String] :comment Comment describing how the API caller established the signer's identity - will appear in the audit trail.
|
12
|
+
# @option params [Boolean] :reusable Should the intended signer be allowed to sign this widget more than once
|
13
|
+
# @option params [Boolean] :allowManualVerification Not used at this time,
|
14
|
+
# @return [Echochamber::Validatable]
|
15
|
+
def initialize(params)
|
16
|
+
require_keys([:email], params)
|
17
|
+
merge!(params)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|