Class: Harvester::Invoices
- Inherits:
-
Object
- Object
- Harvester::Invoices
- Defined in:
- lib/invoices.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #all(params = {}) ⇒ Object
- #get(id, params = {}) ⇒ Object
-
#initialize(client) ⇒ Invoices
constructor
A new instance of Invoices.
Constructor Details
#initialize(client) ⇒ Invoices
Returns a new instance of Invoices.
23 24 25 |
# File 'lib/invoices.rb', line 23 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
21 22 23 |
# File 'lib/invoices.rb', line 21 def client @client end |
Instance Method Details
#all(params = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/invoices.rb', line 27 def all(params = {}) headers = { :content_type => "application/xml", :accept => "application/xml" } xml = client.rest_resource["invoices"].get( :params => params, :headers => headers ) doc = Nokogiri::XML(xml) doc.xpath('//invoice').map do |node| Invoice.from_node(node) end end |
#get(id, params = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/invoices.rb', line 42 def get(id, params = {}) headers = { :content_type => "application/xml", :accept => "application/xml" } xml = client.rest_resource["invoices/#{ id }"].get( :params => params, :headers => headers ) doc = Nokogiri::XML(xml) Invoice.from_node(doc.xpath('//invoice').first) end |