Class: Workarea::Orderbot::Order

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/orderbot/order.rb,
app/services/workarea/orderbot/order/item.rb,
app/services/workarea/orderbot/order/tender/general.rb,
app/services/workarea/orderbot/order/tender/gift_card.rb,
app/services/workarea/orderbot/order/tender/credit_card.rb,
app/services/workarea/orderbot/order/tender/store_credit.rb

Defined Under Namespace

Modules: Tender Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order_id) ⇒ Order

Returns a new instance of Order.



6
7
8
9
# File 'app/services/workarea/orderbot/order.rb', line 6

def initialize(order_id)
  wa_order = Workarea::Order.find(order_id)
  @order = Workarea::Storefront::OrderViewModel.new(wa_order)
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/services/workarea/orderbot/order.rb', line 4

def order
  @order
end

Instance Method Details

#to_aObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/workarea/orderbot/order.rb', line 11

def to_a
  [
    {
      reference_order_id: order.id,
      order_date: order.placed_at.iso8601,
      order_status: "unshipped",
      orderbot_account_id: orderbot_customer_id, # account and customer ids are the same
      orderbot_customer_id: orderbot_customer_id,
      reference_account_id: reference_customer_id,
      reference_customer_id: reference_customer_id,
      distribution_center_id: Workarea.config.inventory_distribution_center_id,
      order_guide_id: Workarea.config.default_order_guide_id,
      email_confirmation_address: order.email,
      subtotal: subtotal,
      order_discount: discount_amount,
      order_total: order.total_price.to_f,
      shipping_info: shipping_info,
      ship_to: shipping_address,
      billing_to: billing_address,
      order_items: items,
      payments: payments,
      taxes: taxes
    }
  ]
end