Class: Legalizer::Find

Inherits:
Base
  • Object
show all
Defined in:
lib/legalizer/find.rb

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from Legalizer::Base

Instance Method Details

#all_contractsObject



8
9
10
11
12
13
14
15
# File 'lib/legalizer/find.rb', line 8

def all_contracts
  contracts = []
  result = JSON.parse(@connection.request(:get, '/api/documents.json', @token, {}).body)["page"]["documents"]
  result.each do |contract|
    contracts << Legalizer::Contract.new({:config => @config, :object => contract})
  end
  contracts
end

#all_templatesObject



22
23
24
25
26
27
28
29
# File 'lib/legalizer/find.rb', line 22

def all_templates
  templates = []
  result = JSON.parse(@connection.request(:get, '/api/templates.json', @token, {}).body)["templates"]
  result.each do |contract|
    templates << Legalizer::Template.new({:config => @config, :object => contract})
  end
  templates
end

#contract(contract_id) ⇒ Object



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

def contract(contract_id)
  result = JSON.parse(@connection.request(:get, "/api/documents/#{contract_id}.json", @token, {}).body)["document"]
  Legalizer::Contract.new({:config => @config, :object => result})
end

#template(template_id) ⇒ Object



17
18
19
20
# File 'lib/legalizer/find.rb', line 17

def template(template_id)
  result = JSON.parse(@connection.request(:get, "/api/templates/#{template_id}.json", @token, {}).body)["template"]
  Legalizer::Template.new({:config => @config, :object => result})
end