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

Returns a new instance of Order.



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

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

Instance Method Details

#ignored_propertiesObject

we manually map these



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

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

#resource_pathObject



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

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

#to_hashObject



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

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