Module: ESignLive::API::Calls
- Included in:
- Client
- Defined in:
- lib/esignlive/api/calls.rb
Constant Summary collapse
- 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
- #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
20 21 22 23 24 25 26 |
# File 'lib/esignlive/api/calls.rb', line 20 def authentication_token(package_id:) ::HTTParty.post( "#{url}/authenticationTokens", body: { packageId: package_id }.to_json, headers: headers ).parsed_response end |
#create_package(opts: {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/esignlive/api/calls.rb', line 108 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}/packages", body: body.to_json, headers: headers ).parsed_response end |
#create_package_from_template(template_id:, opts: {}) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/esignlive/api/calls.rb', line 127 def create_package_from_template(template_id:, opts: {}) ::HTTParty.post( "#{url}/packages/#{template_id}/clone", headers: headers, body: package_hash(opts).to_json ).parsed_response end |
#get_document(package_id:, document_id:, pdf: false) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/esignlive/api/calls.rb', line 68 def get_document(package_id:, document_id:, pdf: false) endpoint = "#{url}/packages/#{package_id}/documents/#{document_id}" pdf ? url = "#{endpoint}/pdf" : url = endpoint ::HTTParty.get( url, headers: headers ).parsed_response end |
#get_package(package_id:) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/esignlive/api/calls.rb', line 54 def get_package(package_id:) ::HTTParty.get( "#{url}/packages/#{package_id}", headers: headers ).parsed_response end |
#get_packages ⇒ Object
47 48 49 50 51 52 |
# File 'lib/esignlive/api/calls.rb', line 47 def get_packages ::HTTParty.get( "#{url}/packages", headers: headers ).parsed_response end |
#get_role(package_id:, role_id:) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/esignlive/api/calls.rb', line 84 def get_role(package_id:, role_id:) ::HTTParty.get( "#{url}/packages/#{package_id}/roles/#{role_id}", headers: headers ).parsed_response end |
#get_roles(package_id:) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/esignlive/api/calls.rb', line 77 def get_roles(package_id:) ::HTTParty.get( "#{url}/packages/#{package_id}/roles", headers: headers ).parsed_response["results"] end |
#get_signing_status(package_id:) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/esignlive/api/calls.rb', line 61 def get_signing_status(package_id:) ::HTTParty.get( "#{url}/packages/#{package_id}/signingStatus", headers: headers ).parsed_response end |
#remove_document_from_package(document_id:, package_id:) ⇒ Object
144 145 146 147 148 149 |
# File 'lib/esignlive/api/calls.rb', line 144 def remove_document_from_package(document_id:, package_id:) ::HTTParty.delete( "#{url}/packages/#{package_id}/documents/#{document_id}", headers: headers ).parsed_response end |
#send_package(package_id:) ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/esignlive/api/calls.rb', line 135 def send_package(package_id:) response = ::HTTParty.post( "#{url}/packages/#{package_id}", body: { status: "SENT" }.to_json, headers: headers ) { code: response["code"], message: response["message"] } end |
#sender_authentication_token(package_id:) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/esignlive/api/calls.rb', line 28 def sender_authentication_token(package_id:) ::HTTParty.post( "#{url}/senderAuthenticationTokens", body: { packageId: package_id }.to_json, headers: headers ).parsed_response end |
#signer_authentication_token(signer_id:, package_id:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/esignlive/api/calls.rb', line 36 def signer_authentication_token(signer_id:, package_id:) ::HTTParty.post( "#{url}/signerAuthenticationTokens", body: { signerId: signer_id, packageId: package_id }.to_json, headers: headers ).parsed_response end |
#signing_url(package_id:, role_id:) ⇒ Object
151 152 153 154 155 156 |
# File 'lib/esignlive/api/calls.rb', line 151 def signing_url(package_id:, role_id:) ::HTTParty.get( "#{url}/packages/#{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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/esignlive/api/calls.rb', line 91 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}/packages/#{package_id}/roles/#{role_id}", body: body.to_json, headers: headers ).parsed_response end |