Class: Legalizer::Template

Inherits:
Document show all
Defined in:
lib/legalizer/document/template.rb

Instance Method Summary collapse

Methods inherited from Document

#id, #source, #to_s, #to_struct

Methods inherited from Base

#config, #connection, #contracts, #find, #templates, #token

Constructor Details

#initialize(options = {}) ⇒ Template

Returns a new instance of Template.



3
4
5
6
# File 'lib/legalizer/document/template.rb', line 3

def initialize(options={})
  super(options)
  @source = options[:object]
end

Instance Method Details

#packageObject

prepare a template for sending, return the guid of the prepared instance



9
10
11
12
13
# File 'lib/legalizer/document/template.rb', line 9

def package
  template_guid = self.source["guid"]
  package = @config.connection.request(:get, "/api/templates/#{template_guid}/prepackage.json", @config.token, {})
  JSON.parse(package.body)["template"]["guid"]
end

#send(request_xml) ⇒ Object



15
16
17
18
# File 'lib/legalizer/document/template.rb', line 15

def send(request_xml)
  response = JSON.parse(@config.connection.request(:post, '/api/templates.json', @config.token, {}, request_xml, { 'Content-Type' => 'application/xml' }).body)
  response["document"]["guid"]
end