Class: Kounta::Order

Inherits:
Resource
  • Object
show all
Defined in:
lib/kounta/order.rb

Instance Method Summary collapse

Methods inherited from Resource

#client, coerce, has_many, has_one, #new?, #save!

Constructor Details

#initialize(hash = {}) ⇒ Order



22
23
24
25
26
# File 'lib/kounta/order.rb', line 22

def initialize(hash={})
	super(hash)
	self.payments ||= []
	self.lines ||= []
end

Instance Method Details

#ignored_propertiesObject

we manually map these



40
41
42
# File 'lib/kounta/order.rb', line 40

def ignored_properties
	super([:lines, :payments])
end

#resource_pathObject



35
36
37
# File 'lib/kounta/order.rb', line 35

def resource_path
	{companies: company_id, orders: id}
end

#to_hashObject



28
29
30
31
32
33
# File 'lib/kounta/order.rb', line 28

def to_hash
	returning = {}
	returning[:lines] = lines.map {|line| line.to_hash } if lines
	returning[:payments] = payments.map {|payment| payment.to_hash } if payments
	super(returning)
end