Class: Workarea::Affirm::Order

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/affirm/order.rb

Defined Under Namespace

Modules: ProductImageUrl, ProductUrl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order_id, options = {}) ⇒ Order

Returns a new instance of Order.



24
25
26
27
28
# File 'app/services/workarea/affirm/order.rb', line 24

def initialize(order_id, options = {})
  wa_order = Workarea::Order.find(order_id)
  @order = Workarea::Storefront::OrderViewModel.wrap(wa_order)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



22
23
24
# File 'app/services/workarea/affirm/order.rb', line 22

def options
  @options
end

#orderObject (readonly)

Returns the value of attribute order.



22
23
24
# File 'app/services/workarea/affirm/order.rb', line 22

def order
  @order
end

Instance Method Details

#to_hashObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/services/workarea/affirm/order.rb', line 34

def to_hash
  {
    merchant: merchant,
    shipping: shipping,
    billing: billing,
    items: items,
    order_id: order.id,
    shipping_amount: order.shipping_total.cents,
    tax_amount: order.tax_total.cents,
    total: order.order_balance.cents
  }
end

#to_json(*_args) ⇒ Object



30
31
32
# File 'app/services/workarea/affirm/order.rb', line 30

def to_json(*_args)
  to_hash.to_json
end