Class: Kounta::Order
- Defined in:
- lib/kounta/order.rb
Instance Method Summary collapse
-
#ignored_properties ⇒ Object
we manually map these.
-
#initialize(hash = {}) ⇒ Order
constructor
A new instance of Order.
- #resource_path ⇒ Object
- #to_hash ⇒ Object
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_properties ⇒ Object
we manually map these
41 42 43 |
# File 'lib/kounta/order.rb', line 41 def ignored_properties super([:lines, :payments]) end |
#resource_path ⇒ Object
36 37 38 |
# File 'lib/kounta/order.rb', line 36 def resource_path {companies: company_id, orders: id} end |
#to_hash ⇒ Object
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 |