Class: Echochamber::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/echochamber/client.rb,
lib/echochamber/widget/client.rb,
lib/echochamber/agreement/client.rb,
lib/echochamber/library_documents/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Echochamber::Client

Initializes the Client object

Parameters:



15
16
17
# File 'lib/echochamber/client.rb', line 15

def initialize(credentials)
  @token = Echochamber::Request.get_token(credentials)
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/echochamber/client.rb', line 10

def token
  @token
end

Instance Method Details

#agreement_combined_pdf(agreement_id, file_path = nil, versionId = nil, participantEmail = nil, attachSupportingDocuments = true, auditReport = false) ⇒ String

Gets a single combined PDF document for the documents associated with an agreement.

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • file_path (String) (defaults to: nil)

    File path to save the document. If no file path is given, nothing is saved to disk.

  • versionId (String) (defaults to: nil)

    The version identifier of agreement as provided by get_agreement. If not provided then latest version will be used

  • participantEmail (String) (defaults to: nil)

    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

  • attachSupportingDocuments (Boolean) (defaults to: true)

    When set to YES, attach corresponding supporting documents to the signed agreement PDF. Default value of this parameter is true.

  • auditReport (Boolean) (defaults to: false)

    When set to YES, attach an audit report to the signed agreement PDF. Default value is false

Returns:

  • (String)

    Raw bytes from document file



92
93
94
95
96
97
98
99
100
# File 'lib/echochamber/agreement/client.rb', line 92

def agreement_combined_pdf(agreement_id, file_path=nil, versionId=nil, participantEmail=nil, attachSupportingDocuments=true, auditReport=false)
  response = Echochamber::Request.agreement_combined_pdf(token, agreement_id, versionId, participantEmail, attachSupportingDocuments, auditReport)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#agreement_document_file(agreement_id, document_id, file_path = nil) ⇒ String

Retrieve a document file from an agreement

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • document_id (String)

    (REQUIRED)

  • file_path (String) (defaults to: nil)

    File path to save the document. If no file path is given, nothing is saved to disk.

Returns:

  • (String)

    Raw bytes from document file



65
66
67
68
69
70
71
72
73
# File 'lib/echochamber/agreement/client.rb', line 65

def agreement_document_file(agreement_id, document_id, file_path=nil)
  response = Echochamber::Request.agreement_document_file(token, agreement_id, document_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#agreement_documents(agreement_id, recipient_email, format, version_id = nil) ⇒ Array

All documents relating to an agreement

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • recipient_email (String)

    The email address of the participant to be used to retrieve documents. (REQUIRED)

  • format (String)

    Content format of the supported documents. It can have two possible values ORIGINAL or CONVERTED_PDF. (REQUIRED)

  • version_id (String) (defaults to: nil)

    Version of the agreement as provided by agreement_info(). If not provided, the latest version of the agreement is used.

Returns:

  • (Array)

    Documents relating to agreement.



55
56
57
# File 'lib/echochamber/agreement/client.rb', line 55

def agreement_documents(agreement_id, recipient_email, format, version_id=nil)
  result = Echochamber::Request.agreement_documents(token, agreement_id, recipient_email, format, version_id)
end

#agreement_form_data(agreement_id, file_path = nil) ⇒ String

Retrieves library document audit trail file

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • file_path (String) (defaults to: nil)

    File path where to save the CSV file. If no file path is given, nothing is saved to disk.

Returns:

  • (String)

    Raw bytes representing CSV file



107
108
109
110
111
112
113
114
115
# File 'lib/echochamber/agreement/client.rb', line 107

def agreement_form_data(agreement_id, file_path=nil)
  response = Echochamber::Request.agreement_form_data(token, agreement_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#agreement_info(agreement_id) ⇒ Hash

Gets detailed info on an agreement

Parameters:

  • agreement_id (String)

    ID of agreement to retrieve info on.

Returns:

  • (Hash)

    Detailed agreement info



27
28
29
# File 'lib/echochamber/agreement/client.rb', line 27

def agreement_info(agreement_id)
  Echochamber::Request.agreement_info(token, agreement_id)
end

#agreement_signing_urls(agreement_id) ⇒ Hash

Retrieves the URL for the eSign page for the current signer(s) of an agreement

Parameters:

  • agreement_id (String)

    (REQUIRED)

Returns:

  • (Hash)

    URL information for the eSign page of the agreement



79
80
81
# File 'lib/echochamber/agreement/client.rb', line 79

def agreement_signing_urls(agreement_id)
  response = Echochamber::Request.agreement_signing_urls(token, agreement_id)
end

#audit_trail_pdf(agreement_id, file_path = nil) ⇒ String

Retrieve a PDF audit file for an agreement

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • file_path (String) (defaults to: nil)

    File path to save the document. If no file path is given, nothing is saved to disk.

Returns:

  • (String)

    Raw bytes from document file



52
53
54
55
56
57
58
59
60
# File 'lib/echochamber/client.rb', line 52

def audit_trail_pdf(agreement_id, file_path=nil)
  response = Echochamber::Request.audit_trail_pdf(token, agreement_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#cancel_agreement(agreement_id, notify_signer = false, comment = nil) ⇒ String

Cancel agreement

Parameters:

  • agreement_id (String)

    (REQUIRED)

  • notify_signer (Boolean) (defaults to: false)

    Whether to notify the signer by email of the cancellation. Default is false.

  • comment (String) (defaults to: nil)

    Comment regarding this cancellation.

Returns:

  • (String)

    Result of the operation



37
38
39
40
41
42
43
44
45
46
# File 'lib/echochamber/agreement/client.rb', line 37

def cancel_agreement(agreement_id, notify_signer=false, comment=nil)
  request_body = {
    "value" => "CANCEL",
    "notifySigner" => notify_signer 
  }
  request_body.merge!(comment: comment) unless comment.nil?

  agreement_status_response = Echochamber::Request.update_agreement_status(token, agreement_id, request_body)
  agreement_status_response.fetch('result')
end

#create_agreement(agreement) ⇒ String

Creates an agreement

Parameters:

Returns:

  • (String)

    Agreement ID



9
10
11
12
# File 'lib/echochamber/agreement/client.rb', line 9

def create_agreement(agreement)
  agreement_response = Echochamber::Request.create_agreement(agreement, token, agreement.user_id, agreement.user_email)
  agreement_response.fetch("agreementId")
end

#create_reminder(reminder) ⇒ String

Creates a reminder

Parameters:

Returns:

  • (String)

    Reminder ID



32
33
34
# File 'lib/echochamber/client.rb', line 32

def create_reminder(reminder)
  reminder_response = Echochamber::Request.create_reminder(token, reminder)
end

#create_transient_document(file_name, mime_type, file_handle) ⇒ String

Creates a transient document for later referral

Parameters:

  • file_name (String)
  • mime_type (String)
  • file_handle (File)

Returns:

  • (String)

    Transient document ID



42
43
44
45
# File 'lib/echochamber/client.rb', line 42

def create_transient_document(file_name, mime_type, file_handle)
  transient_document_response = Echochamber::Request.create_transient_document(token, file_name, file_handle, mime_type)
  transient_document_response.fetch("transientDocumentId")
end

#create_user(user) ⇒ String

Creates a user for the current application

Parameters:

Returns:

  • (String)

    User ID of new Echosign user



23
24
25
26
# File 'lib/echochamber/client.rb', line 23

def create_user(user)
  user_response  = Echochamber::Request.create_user(user, token)
  user_response.fetch("userId")
end

#create_widget(widget) ⇒ Hash

Creates a widget and returns the Javascript snippet and URL to access the widget and widgetID in response to the client

Parameters:

Returns:

  • (Hash)


9
10
11
# File 'lib/echochamber/widget/client.rb', line 9

def create_widget(widget)
  Echochamber::Request.create_widget(token, widget)
end

#get_agreementsString

Gets list of agreements

Parameters:

Returns:

  • (String)

    Agreement ID



18
19
20
21
# File 'lib/echochamber/agreement/client.rb', line 18

def get_agreements
  get_agreements_response = Echochamber::Request.get_agreements(token)
  get_agreements_response.fetch("userAgreementList")
end

#get_library_document(library_document_id) ⇒ Hash

Retrieves library document metadata

Parameters:

  • library_document_id (String)

    (REQUIRED)

Returns:

  • (Hash)

    Library document metadata



18
19
20
# File 'lib/echochamber/library_documents/client.rb', line 18

def get_library_document(library_document_id)
  Echochamber::Request.get_library_document(token, library_document_id)
end

#get_library_document_file(library_document_id, file_id, file_path = nil) ⇒ String

Retrieves library document file data

Parameters:

  • library_document_id (REQUIRED)
  • file_id (String)

    (REQUIRED)

  • file_path (String) (defaults to: nil)

    File path for saving the document. If none is given, nothing will be saved to disk.

Returns:

  • (String)

    Raw library document file data



36
37
38
39
40
41
42
43
44
# File 'lib/echochamber/library_documents/client.rb', line 36

def get_library_document_file(library_document_id, file_id, file_path=nil)
  response = Echochamber::Request.get_library_document_file(token, library_document_id, file_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#get_library_document_files(library_document_id) ⇒ Hash

Retrieves library document files metadata

Parameters:

  • library_document_id (String)

    (REQUIRED)

Returns:

  • (Hash)

    Library document files metadata



26
27
28
# File 'lib/echochamber/library_documents/client.rb', line 26

def get_library_document_files(library_document_id)
  Echochamber::Request.get_library_document_files(token, library_document_id)
end

#get_library_documents(user_id = nil, user_email = nil) ⇒ Hash

Retrieves library documents metadata for a user.

Parameters:

  • user_id (String) (defaults to: nil)

    The ID of the user whose library documents are being requested.

  • user_email (String) (defaults to: nil)

    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.

Returns:

  • (Hash)

    Library documents metadata



10
11
12
# File 'lib/echochamber/library_documents/client.rb', line 10

def get_library_documents(user_id=nil, user_email=nil)
  Echochamber::Request.get_library_documents(token, user_id, user_email)
end

#get_user(user_id) ⇒ Hash

Gets all the users in an account that the caller has permissions to access.

Parameters:

  • user_id (String)

Returns:

  • (Hash)

    User info hash



75
76
77
# File 'lib/echochamber/client.rb', line 75

def get_user(user_id)
  Echochamber::Request.get_user(token, user_id)
end

#get_users(user_email) ⇒ Hash

Gets all the users in an account that the caller has permissions to access.

Parameters:

  • user_email (String)

    The email address of the user whose details are being requested (REQUIRED)

Returns:

  • (Hash)

    User info hash



67
68
69
# File 'lib/echochamber/client.rb', line 67

def get_users(user_email)
  Echochamber::Request.get_users(token, user_email)
end

#get_widget(widget_id) ⇒ Hash

Retrieves the details of a widget

Parameters:

  • widget_id

Returns:

  • (Hash)

    Detailed widget info



44
45
46
# File 'lib/echochamber/widget/client.rb', line 44

def get_widget(widget_id)
  Echochamber::Request.get_widget(token, widget_id)
end

#get_widget_audit_trail(widget_id, file_path = nil) ⇒ String

Note:

SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE

Retrieves the audit trail of a widget identified by widgetId

Parameters:

  • widget_id (String)
  • file_path (String) (defaults to: nil)

    File path where to save the document. If none is given, nothing will be saved to file.

Returns:

  • (String)

    Raw file stream



80
81
82
83
84
85
86
87
88
# File 'lib/echochamber/widget/client.rb', line 80

def get_widget_audit_trail(widget_id, file_path=nil)
  response = Echochamber::Request.get_widget_audit_trail(token, widget_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#get_widget_combined_pdf(widget_id, file_path = nil) ⇒ String

Note:

SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE

Gets a single combined PDF document for the documents associated with a widget.

Parameters:

  • widget_id (String)
  • file_path (String) (defaults to: nil)

    File path where to save the document. If none is given, nothing will be saved to file.

Returns:

  • (String)

    Raw file stream



96
97
98
99
100
101
102
103
104
# File 'lib/echochamber/widget/client.rb', line 96

def get_widget_combined_pdf(widget_id, file_path=nil)
  response = Echochamber::Request.get_widget_combined_pdf(token, widget_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#get_widget_document_file(widget_id, document_id, file_path = nil) ⇒ String

Retrieves the file stream of a document of a widget

Parameters:

  • widget_id (String)
  • document_id (String)
  • file_path (String) (defaults to: nil)

    File path where to save the document. If none is given, nothing will be saved to file.

Returns:

  • (String)

    Raw file stream



64
65
66
67
68
69
70
71
72
# File 'lib/echochamber/widget/client.rb', line 64

def get_widget_document_file(widget_id, document_id, file_path=nil)
  response = Echochamber::Request.get_widget_document_file(token, widget_id, document_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#get_widget_documents(widget_id, version_id = nil, participant_email = nil) ⇒ Hash

Retrieves the IDs of the documents associated with widget.

Parameters:

  • widget_id (String)
  • version_id (String) (defaults to: nil)

    The version identifier of widget as provided by get_widget. If not provided then latest version will be used.

  • participant_email (String) (defaults to: nil)

    The email address of the participant to be used to retrieve documents

Returns:

  • (Hash)

    Info about widget documents



54
55
56
# File 'lib/echochamber/widget/client.rb', line 54

def get_widget_documents(widget_id, version_id=nil, participant_email=nil)
  Echochamber::Request.get_widget_documents(token, widget_id, version_id, participant_email)
end

#get_widget_form_data(widget_id, file_path = nil) ⇒ String

Note:

SEEMINGLY NOT YET IMPLEMENTED SERVER-SIDE

Retrieves data entered by the user into interactive form fields at the time they signed the widget

Parameters:

  • widget_id (String)
  • file_path (String) (defaults to: nil)

    File path where to save the document. If none is given, nothing will be saved to file.

Returns:

  • (String)

    Raw file stream



112
113
114
115
116
117
118
119
120
# File 'lib/echochamber/widget/client.rb', line 112

def get_widget_form_data(widget_id, file_path=nil)
  response = Echochamber::Request.get_widget_form_data(token, widget_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#get_widgets(user_id = nil, user_email = nil) ⇒ Hash

Retrieves widgets for a user

Parameters:

  • user_id (String) (defaults to: nil)

    The ID of the user whose widgets are being requested

  • user_email (String) (defaults to: nil)

    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

Returns:

  • (Hash)

    Widgets info



36
37
38
# File 'lib/echochamber/widget/client.rb', line 36

def get_widgets(user_id=nil, user_email=nil)
  Echochamber::Request.get_widgets(token, user_id, user_email)
end

#library_combined_document(library_document_id, file_path = nil, auditReport = false) ⇒ String

Retrieves library combined document file

Parameters:

  • library_document_id (REQUIRED)
  • file_path (String) (defaults to: nil)

    File path for saving the document. If none is given, nothing will be saved to disk.

  • auditReport (Boolean) (defaults to: false)

    When set to YES attach an audit report to the library document PDF. Default value will be false.

Returns:

  • (String)

    Raw library combined document file data



67
68
69
70
71
72
73
74
75
# File 'lib/echochamber/library_documents/client.rb', line 67

def library_combined_document(library_document_id, file_path=nil, auditReport=false)
  response = Echochamber::Request.library_combined_document(token, library_document_id, auditReport)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#library_document_audit_trail(library_document_id, file_path = nil) ⇒ String

Retrieves library document audit trail file

Parameters:

  • library_document_id (REQUIRED)
  • file_path (String) (defaults to: nil)

    File path for saving the document. If none is given, nothing will be saved to disk.

Returns:

  • (String)

    Raw library document file data



51
52
53
54
55
56
57
58
59
# File 'lib/echochamber/library_documents/client.rb', line 51

def library_document_audit_trail(library_document_id, file_path=nil)
  response = Echochamber::Request.library_document_audit_trail(token, library_document_id)
  unless file_path.nil?
    file = File.new(file_path, 'wb')
    file.write(response)
    file.close
  end
  response
end

#personalize_widget(widget_id, personalization) ⇒ Hash

Personalize the widget to a signable document for a specific known user

Parameters:

Returns:

  • (Hash)

    Operation result



18
19
20
# File 'lib/echochamber/widget/client.rb', line 18

def personalize_widget(widget_id, personalization)
  Echochamber::Request.personalize_widget(token, widget_id, personalization)
end

#update_widget_status(widget_id, status) ⇒ Hash

Enables or Disables a widget

Parameters:

Returns:

  • (Hash)

    Widget status



27
28
29
# File 'lib/echochamber/widget/client.rb', line 27

def update_widget_status(widget_id, status)
  Echochamber::Request.update_widget_status(token, widget_id, status)
end