class Blinksale::Clients

Attributes

service[R]

Public Class Methods

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

Public Instance Methods

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