Class: Kounta::Order

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

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

coerce, #delete!, has_many, has_many_in_time_range, has_one, #new?, #save!

Constructor Details

#initialize(hash = {}) ⇒ Order

Returns a new instance of Order.



25
26
27
28
29
# File 'lib/kounta/order.rb', line 25

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

Instance Method Details

#ignored_propertiesObject

we manually map these



43
44
45
# File 'lib/kounta/order.rb', line 43

def ignored_properties
  super(i[lock site_id])
end

#resource_pathObject



38
39
40
# File 'lib/kounta/order.rb', line 38

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

#to_hashObject



31
32
33
34
35
36
# File 'lib/kounta/order.rb', line 31

def to_hash
  returning = {}
  returning[:lines] = lines.map(&:to_hash) if lines && !lines.empty?
  returning[:payments] = payments.map(&:to_hash) if payments && !payments.empty?
  super(returning)
end