Module: ESignLive::API::Calls
- Included in:
- Client
- Defined in:
- lib/esignlive/api/calls.rb
Constant Summary collapse
- URL =
"https://sandbox.esignlive.com/api/packages"- AUTH_URL =
"https://sandbox.esignlive.com/api/authenticationTokens"- SENDER_AUTH_URL =
"https://sandbox.esignlive.com/api/senderAuthenticationTokens"- SIGNER_AUTH_URL =
"https://sandbox.esignlive.com/api/signerAuthenticationTokens"- PACKAGE_DEFAULTS =
{ name: "New Package #{Time.now}", language: "en", email_message: "Documents to sign!", description: "Document(s) require your signature", visibility: "ACCOUNT", settings: { ceremony: { inPerson: false } }, autocomplete: true }
Instance Method Summary collapse
- #authentication_token(package_id:) ⇒ Object
- #create_package(opts: {}) ⇒ Object
- #create_package_from_template(template_id:, opts: {}) ⇒ Object
- #get_document(package_id:, document_id:, pdf: false) ⇒ Object
- #get_package(package_id:) ⇒ Object
- #get_packages ⇒ Object
- #get_role(package_id:, role_id:) ⇒ Object
- #get_roles(package_id:) ⇒ Object
- #get_signing_status(package_id:) ⇒ Object
- #package_hash(opts) ⇒ Object
- #remove_document_from_package(document_id:, package_id:) ⇒ Object
- #send_package(package_id:) ⇒ Object
- #sender_authentication_token(package_id:) ⇒ Object
- #signer_authentication_token(signer_id:, package_id:) ⇒ Object
- #signing_url(package_id:, role_id:) ⇒ Object
- #update_role_signer(package_id:, role_id:, email:, first_name:, last_name:) ⇒ Object
Instance Method Details
#authentication_token(package_id:) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/esignlive/api/calls.rb', line 24 def authentication_token(package_id:) ::HTTParty.post( AUTH_URL, body: { packageId: package_id }.to_json, headers: headers ).parsed_response end |
#create_package(opts: {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/esignlive/api/calls.rb', line 112 def create_package(opts: {}) body = package_hash(opts) if opts[:sender].is_a? Hash sender_hash = { sender: { lastName: sender_opts[:last_name], firstName: sender_opts[:first_name], email: sender_opts[:email] } } body.merge!(sender_hash) end ::HTTParty.post( URL, body: body.to_json, headers: headers ).parsed_response end |
#create_package_from_template(template_id:, opts: {}) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/esignlive/api/calls.rb', line 131 def create_package_from_template(template_id:, opts: {}) ::HTTParty.post( "https://sandbox.esignlive.com/api/packages/#{template_id}/clone", headers: headers, body: package_hash(opts).to_json ).parsed_response end |
#get_document(package_id:, document_id:, pdf: false) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/esignlive/api/calls.rb', line 72 def get_document(package_id:, document_id:, pdf: false) endpoint = "#{URL}/#{package_id}/documents/#{document_id}" pdf ? url = "#{endpoint}/pdf" : url = endpoint ::HTTParty.get( url, headers: headers ).parsed_response end |
#get_package(package_id:) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/esignlive/api/calls.rb', line 58 def get_package(package_id:) ::HTTParty.get( "#{URL}/#{package_id}", headers: headers ).parsed_response end |
#get_packages ⇒ Object
51 52 53 54 55 56 |
# File 'lib/esignlive/api/calls.rb', line 51 def get_packages ::HTTParty.get( URL, headers: headers ).parsed_response end |
#get_role(package_id:, role_id:) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/esignlive/api/calls.rb', line 88 def get_role(package_id:, role_id:) ::HTTParty.get( "#{URL}/#{package_id}/roles/#{role_id}", headers: headers ).parsed_response end |
#get_roles(package_id:) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/esignlive/api/calls.rb', line 81 def get_roles(package_id:) ::HTTParty.get( "#{URL}/#{package_id}/roles", headers: headers ).parsed_response["results"] end |
#get_signing_status(package_id:) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/esignlive/api/calls.rb', line 65 def get_signing_status(package_id:) ::HTTParty.get( "#{URL}/#{package_id}/signingStatus", headers: headers ).parsed_response end |
#package_hash(opts) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/esignlive/api/calls.rb', line 162 def package_hash(opts) { type: "PACKAGE", name: opts[:name] || PACKAGE_DEFAULTS[:name], language: opts[:language] || PACKAGE_DEFAULTS[:language], emailMessage: opts[:email_message] || PACKAGE_DEFAULTS[:email_message], description: opts[:description] || PACKAGE_DEFAULTS[:description], autocomplete: opts[:autocomplete] || PACKAGE_DEFAULTS[:autocomplete], settings: opts[:settings] || PACKAGE_DEFAULTS[:settings], visibility: opts[:visibility] || PACKAGE_DEFAULTS[:visibility] } end |
#remove_document_from_package(document_id:, package_id:) ⇒ Object
148 149 150 151 152 153 |
# File 'lib/esignlive/api/calls.rb', line 148 def remove_document_from_package(document_id:, package_id:) ::HTTParty.delete( "#{URL}/#{package_id}/documents/#{document_id}", headers: headers ).parsed_response end |
#send_package(package_id:) ⇒ Object
139 140 141 142 143 144 145 146 |
# File 'lib/esignlive/api/calls.rb', line 139 def send_package(package_id:) ::HTTParty.post( "#{URL}/#{package_id}", body: { status: "SENT" }.to_json, headers: headers ) true end |
#sender_authentication_token(package_id:) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/esignlive/api/calls.rb', line 32 def sender_authentication_token(package_id:) ::HTTParty.post( SENDER_AUTH_URL, body: { packageId: package_id }.to_json, headers: headers ).parsed_response end |
#signer_authentication_token(signer_id:, package_id:) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/esignlive/api/calls.rb', line 40 def signer_authentication_token(signer_id:, package_id:) ::HTTParty.post( SIGNER_AUTH_URL, body: { signerId: signer_id, sipackageId: package_id }.to_json, headers: headers ).parsed_response end |
#signing_url(package_id:, role_id:) ⇒ Object
155 156 157 158 159 160 |
# File 'lib/esignlive/api/calls.rb', line 155 def signing_url(package_id:, role_id:) ::HTTParty.get( "#{URL}/#{package_id}/roles/#{role_id}/signingUrl", headers: headers ).parsed_response["url"] end |
#update_role_signer(package_id:, role_id:, email:, first_name:, last_name:) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/esignlive/api/calls.rb', line 95 def update_role_signer(package_id:, role_id:, email:, first_name:, last_name:) body = { signers: [ { email: email, firstName: first_name, lastName: last_name } ] } ::HTTParty.put( "#{URL}/#{package_id}/roles/#{role_id}", body: body.to_json, headers: headers ).parsed_response end |