Class: Blinksale::Clients
- Inherits:
-
Object
- Object
- Blinksale::Clients
- Defined in:
- lib/clients.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #all(params = {}) ⇒ Object
- #get(id, params = {}) ⇒ Object
-
#initialize(service) ⇒ Clients
constructor
A new instance of Clients.
Constructor Details
#initialize(service) ⇒ Clients
Returns a new instance of Clients.
25 26 27 |
# File 'lib/clients.rb', line 25 def initialize(service) @service = service end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
23 24 25 |
# File 'lib/clients.rb', line 23 def service @service end |
Instance Method Details
#all(params = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 |