Class: Paypal::Payment::Response::Item

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/payment/response/item.rb

Constant Summary collapse

@@attribute_mapping =
{
  :NAME => :name,
  :DESC => :description,
  :QTY => :quantity,
  :NUMBER => :number,
  :ITEMCATEGORY => :category,
  :ITEMWIDTHVALUE => :width,
  :ITEMHEIGHTVALUE => :height,
  :ITEMLENGTHVALUE => :length,
  :ITEMWEIGHTVALUE => :weight,
  :SHIPPINGAMT => :shipping,
  :HANDLINGAMT => :handling,
  :CURRENCYCODE => :currency
  
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#==, formatted_amount, #numeric_attribute?, to_numeric

Constructor Details

#initialize(attributes = {}) ⇒ Item

Returns a new instance of Item.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/paypal/payment/response/item.rb', line 23

def initialize(attributes = {})
  attrs = attributes.dup
  @@attribute_mapping.each do |key, value|
    self.send "#{value}=", attrs.delete(key)
  end
  @quantity = @quantity.to_i
  @amount = Common::Amount.new(
    :total => attrs.delete(:AMT),
    :tax => attrs.delete(:TAXAMT)
  )

  # warn ignored params
  attrs.each do |key, value|
    Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



21
22
23
# File 'lib/paypal/payment/response/item.rb', line 21

def amount
  @amount
end