Class: Jirafe::Callback::Events::Order

Inherits:
Jirafe::Callback::Event show all
Includes:
DataHelper, Model
Defined in:
lib/jirafe/callback/events/order.rb

Constant Summary

Constants inherited from Jirafe::Callback::Event

Jirafe::Callback::Event::GLOBAL_ACTION

Instance Attribute Summary collapse

Attributes inherited from Jirafe::Callback::Event

#action, #version

Instance Method Summary collapse

Methods included from DataHelper

#format_amount, #format_discount_amount

Methods included from Model

#attributes, #attributes_for_change, #create, included, #initialize, #reinitialize, #update

Methods inherited from Jirafe::Callback::Event

events_url, send, #to_json, trust_callback?

Methods inherited from JirafeCallback

callback_url, logger, notify

Methods included from ResponseParser

included

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def created_at
  @created_at
end

#customerObject

Returns the value of attribute customer.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def customer
  @customer
end

#discount_amountObject

Returns the value of attribute discount_amount.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def discount_amount
  @discount_amount
end

#grand_totalObject

Returns the value of attribute grand_total.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def grand_total
  @grand_total
end

#identifierObject

Returns the value of attribute identifier.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def identifier
  @identifier
end

#itemsObject

Returns the value of attribute items.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def items
  @items
end

#shipping_amountObject

Returns the value of attribute shipping_amount.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def shipping_amount
  @shipping_amount
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def status
  @status
end

#sub_totalObject

Returns the value of attribute sub_total.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def sub_total
  @sub_total
end

#tax_amountObject

Returns the value of attribute tax_amount.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def tax_amount
  @tax_amount
end

#visitor_identifierObject

Returns the value of attribute visitor_identifier.



7
8
9
# File 'lib/jirafe/callback/events/order.rb', line 7

def visitor_identifier
  @visitor_identifier
end

Instance Method Details

#action_mapObject



24
25
26
27
28
29
30
# File 'lib/jirafe/callback/events/order.rb', line 24

def action_map
  {
    :create => "orderCreate",
    :update => "orderUpdate",
    :import => "orderImport"
  }
end

#dataObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jirafe/callback/events/order.rb', line 32

def data
  {
    "orderId" => identifier,
    "status" => status_map[status],
    "customerHash" => customer,
    "vistorId" => visitor_identifier,
    "time" => created_at || Time.now.to_i,
    "grandTotal" => format_amount(grand_total),
    "subTotal" => format_amount(sub_total),
    "taxAmount" => format_amount(tax_amount),
    "shippingAmount" => format_amount(shipping_amount),
    "discountAmount" => format_discount_amount(discount_amount),
    "items" => items.map { |item| item.data }
  }
end

#status_mapObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jirafe/callback/events/order.rb', line 10

def status_map
  {
    :new => "new",
    :payment_pending => "pendingPayment",
    :processing => "processing",
    :complete => "complete",
    :closed => "closed",
    :canceled => "canceled",
    :held => "held",
    :payment_review => "paymentReview",
    :unknown => "unknown"
  }
end