Class: Mifiel::Document
- Inherits:
-
Base
- Object
- Base
- Mifiel::Document
- Defined in:
- lib/mifiel/document.rb
Class Method Summary collapse
- .build_signatories(signatories) ⇒ Object
-
.create(args) ⇒ Object
rubocop:disable-next Metrics/MethodLength.
Instance Method Summary collapse
- #request_signature(email, cc: nil) ⇒ Object deprecated Deprecated.
- #save_file(path) ⇒ Object
- #save_file_signed(path) ⇒ Object
- #save_xml(path) ⇒ Object
Class Method Details
.build_signatories(signatories) ⇒ Object
66 67 68 69 70 |
# File 'lib/mifiel/document.rb', line 66 def self.build_signatories(signatories) sgries = {} signatories.each_with_index { |s, i| sgries[i] = s } sgries end |
.create(args) ⇒ Object
rubocop:disable-next Metrics/MethodLength
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mifiel/document.rb', line 27 def self.create(args) signatories = args[:signatories] file = args[:file] hash = args[:hash] name = args[:name] callback_url = args[:callback_url] raise ArgumentError, 'Either file or hash must be provided' if !file && !hash raise ArgumentError, 'Only one of file or hash must be provided' if file && hash payload = { signatories: build_signatories(signatories), callback_url: callback_url, file: (File.new(file) if file), original_hash: hash, name: name, } payload = args.merge(payload).compact process_request('/documents', :post, payload: payload, type: :form_multipart) end |
Instance Method Details
#request_signature(email, cc: nil) ⇒ Object
Deprecated.
48 49 50 51 52 |
# File 'lib/mifiel/document.rb', line 48 def request_signature(email, cc: nil) params = { email: email } params[:cc] = cc if cc.is_a?(Array) Mifiel::Base.process_request("/documents/#{id}/request_signature", :post, payload: params) end |
#save_file(path) ⇒ Object
54 55 56 |
# File 'lib/mifiel/document.rb', line 54 def save_file(path) File.binwrite(path, raw_file) end |
#save_file_signed(path) ⇒ Object
58 59 60 |
# File 'lib/mifiel/document.rb', line 58 def save_file_signed(path) File.binwrite(path, raw_file_signed) end |
#save_xml(path) ⇒ Object
62 63 64 |
# File 'lib/mifiel/document.rb', line 62 def save_xml(path) File.write(path, raw_xml) end |