Class: Signatory::DocumentPackage

Inherits:
API::Base
  • Object
show all
Defined in:
lib/signatory/document_package.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from API::Base

connection, escape_url_attrs, formatted_collection_name, formatted_name, #has_many, #id, instantiate_collection, #instantiate_record, #persisted?

Class Method Details

.allObject

Raises:

  • (NoMethodError)


6
# File 'lib/signatory/document_package.rb', line 6

def self.all; raise NoMethodError; end

.findObject

Raises:

  • (NoMethodError)


7
# File 'lib/signatory/document_package.rb', line 7

def self.find; raise NoMethodError; end

Instance Method Details

#prefill_and_send(merge_fields, roles, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/signatory/document_package.rb', line 9

def prefill_and_send(merge_fields, roles, opts={})
  attributes.merge!({
    'merge_fields' => merge_fields,
    'roles' => roles,
    'action' => 'send'
  })
  if opts[:document_data].present?
    attributes.merge!({
      'document_data' => {
        'type' => 'base64',
        'filename' => 'document.pdf',
        'value' => Base64.encode64(opts[:document_data])
      }
    })
  end

  doc = connection.format.decode(connection.post("/api/templates.xml", self.to_xml).body)
  Document.find(doc['guid'])
end

#to_xml(opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/signatory/document_package.rb', line 29

def to_xml(opts = {})
  super(opts.merge(:dasherize => false, :skip_types => true, :except => [:pages, :_type, :redirect_token, :content_type, :size, :tags])) do |b|
    b.tag!(:tags) do
      tags.split(" ").each do |tag|
        b.tag!(:tag) { b.value tag}
      end
    end unless attributes['tags'].blank?
  end
end