lib/signaturit_client.rb in signaturit-sdk-0.0.4 vs lib/signaturit_client.rb in signaturit-sdk-0.0.5

- old
+ new

@@ -9,11 +9,11 @@ # Initialize the object with the token and environment def initialize(token, production = false) base = production ? 'https://api.signaturit.com' : 'http://api.sandbox.signaturit.com' - @client = RestClient::Resource.new base, :headers => { :Authorization => "Bearer #{token}" }, :ssl_version => :TLSv1_2 + @client = RestClient::Resource.new base, :headers => { :Authorization => "Bearer #{token}", :user_agent => 'signaturit-ruby-sdk 0.0.4' }, :ssl_version => :TLSv1_2 end # get info from your account def get_account request :get, '/v2/account.json' @@ -64,30 +64,48 @@ # Params: # +limit+:: Maximum number of results to return # +offset+:: Offset of results to skip # +status+:: Status of the signature objects to filter # +since+:: Filter signature objects created since this date - def get_signatures(limit = 100, offset = 0, status = nil, since = nil) + # +data+:: Filter signature objects using custom data + def get_signatures(limit = 100, offset = 0, status = nil, since = nil, data = nil) params = { :limit => limit, :offset => offset } params[:status] = status unless status.nil? params[:since] = since unless since.nil? + if data + data.each do |key, value| + new_key = "data.#{key}" + + params[new_key] = value + end + end + request :get, '/v2/signs.json', params end # Get the number of signature objects # # Params: # +status+:: Status of the signature objects to filter # +since+:: Filter signature objects created since this date - def count_signatures(status = nil, since = nil) + # +data+:: Filter signature objects using custom data + def count_signatures(status = nil, since = nil, data = nil) params = {} params[:status] = status unless status.nil? params[:since] = since unless since.nil? + if data + data.each do |key, value| + new_key = "data.#{key}" + + params[new_key] = value + end + end + request :get, '/v2/signs/count.json', params end # Get a concrete document from a concrete Signature # @@ -108,11 +126,11 @@ # Get the audit trail of concrete document # # Params: # +signature_id++:: The id of the signature object - # +document_id++:: THe id of the document object + # +document_id++:: The id of the document object # +path++:: Path where the document will be stored def get_audit_trail(signature_id, document_id, path) response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/doc_proof", {}, false File.open(path, 'wb') do |file| @@ -124,11 +142,11 @@ # Get the signed document # # Params: # +signature_id++:: The id of the signature object - # +document_id++:: THe id of the document object + # +document_id++:: The id of the document object # +path++:: Path where the document will be stored def get_signed_document(signature_id, document_id, path) response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/signed", {}, false File.open(path, 'wb') do |file| @@ -178,10 +196,19 @@ # +signature_id++:: The id of the signature object def cancel_signature_request(signature_id) request :patch, "/v2/signs/#{signature_id}/cancel.json" end + # Send a reminder for the given signature request document + # + # Param + # +signature_id++:: The id of the signature object + # +document_id++:: The id of the document object + def send_reminder(signature_id, document_id) + request :post, "/v2/signs/#{signature_id}/documents/#{document_id}/reminder.json" + end + # Get a concrete branding # # Params # +branding_id+:: The id of the branding object def get_branding(branding_id) @@ -291,7 +318,6 @@ body = JSON.parse body if to_json body end - end