Class: Jirafe::Callback::Events::Refund

Inherits:
Jirafe::Callback::Event show all
Includes:
DataHelper, Model
Defined in:
lib/jirafe/callback/events/refund.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/refund.rb', line 7

def created_at
  @created_at
end

#discount_amountObject

Returns the value of attribute discount_amount.



7
8
9
# File 'lib/jirafe/callback/events/refund.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/refund.rb', line 7

def grand_total
  @grand_total
end

#identifierObject

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#itemsObject

Returns the value of attribute items.



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

def items
  @items
end

#order_identifierObject

Returns the value of attribute order_identifier.



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

def order_identifier
  @order_identifier
end

#shipping_amountObject

Returns the value of attribute shipping_amount.



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

def shipping_amount
  @shipping_amount
end

#sub_totalObject

Returns the value of attribute sub_total.



7
8
9
# File 'lib/jirafe/callback/events/refund.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/refund.rb', line 7

def tax_amount
  @tax_amount
end

Instance Method Details

#action_mapObject



11
12
13
14
15
16
# File 'lib/jirafe/callback/events/refund.rb', line 11

def action_map
  {
    :create => "refundCreate",
    :import => "refundImport",
  }
end

#dataObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jirafe/callback/events/refund.rb', line 18

def data
  {
    "refundId" => identifier,
    "orderId" => order_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