class Blinksale::Invoices

Attributes

service[R]

Public Class Methods

new(service) click to toggle source
# File lib/invoices.rb, line 23
def initialize(service)
  @service = service
end

Public Instance Methods

all(params = {}) click to toggle source
# File lib/invoices.rb, line 27
def all(params = {})
  headers = {
    :content_type => "application/vnd.blinksale+xml",
    :accept => "application/vnd.blinksale+xml"
  }
  xml = service.rest_resource["invoices"].get(
    :params => params,
    :headers => headers
  )
  doc = Nokogiri::XML(xml)
  doc.xpath('//xmlns:invoice').map do |node|
    Invoice.from_node(node)
  end
end
get(id, params = {}) click to toggle source
# File lib/invoices.rb, line 42
def get(id, params = {})
  headers = {
    :content_type => "application/vnd.blinksale+xml",
    :accept => "application/vnd.blinksale+xml"
  }
  xml = service.rest_resource["invoices/#{ id }"].get(
    :params => params,
    :headers => headers
  )
  doc = Nokogiri::XML(xml)
  Invoice.from_node(doc.xpath('//xmlns:invoice').first)
end