Class: Workarea::Yotpo::Order

Inherits:
Object
  • Object
show all
Defined in:
app/services/yotpo/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
# File 'app/services/yotpo/order.rb', line 24

def initialize(order_id, options = {})
  @order_id = order_id
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#order_idObject (readonly)

Returns the value of attribute order_id.



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

def order_id
  @order_id
end

Instance Method Details

#to_hHash

Builds an order hash for Yotpo API consumption

Returns:

  • (Hash)


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

def to_h
  {
    validate_data: true,
    platform: "general", # TODO - get on the list of approved yotpo platforms
    email: order.email,
    customer_name: order.billing_address.first_name + " " + order.billing_address.last_name,
    order_id: order.id,
    order_date: order.placed_at,
    currency_iso: order.total_price.currency.iso_code,
    products: products,
    customer: customer
  }
end