Class: RubyPaypalNvp::Model::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_paypal_nvp/model/item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Item

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_paypal_nvp/model/item.rb', line 12

def initialize(hash = {})
  @timestamp = hash['L_TIMESTAMP'] || nil
  @timezone = hash['L_TIMEZONE'] || nil
  @type = hash['L_TYPE'] || nil
  @email = hash['L_EMAIL'] || nil
  @name = hash['L_NAME'] || nil
  @transaction_id = hash['L_TRANSACTIONID'] || nil
  @status = hash['L_STATUS'] || nil
  @amount = (hash['L_AMT'] || nil).to_f
  @currency_code = hash['L_CURRENCYCODE'] || nil
  @fee_amount = (hash['L_FEEAMT'] || nil).to_f
  @net_amount = (hash['L_NETAMT'] || nil).to_f
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def amount
  @amount
end

#currency_codeObject

Returns the value of attribute currency_code.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def currency_code
  @currency_code
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def email
  @email
end

#fee_amountObject

Returns the value of attribute fee_amount.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def fee_amount
  @fee_amount
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def name
  @name
end

#net_amountObject

Returns the value of attribute net_amount.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def net_amount
  @net_amount
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def status
  @status
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def timestamp
  @timestamp
end

#timezoneObject

Returns the value of attribute timezone.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def timezone
  @timezone
end

#transaction_idObject

Returns the value of attribute transaction_id.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def transaction_id
  @transaction_id
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/ruby_paypal_nvp/model/item.rb', line 4

def type
  @type
end

Class Method Details

.attributesObject

rubocop:enable Metrics/AbcSize rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/MethodLength



30
31
32
# File 'lib/ruby_paypal_nvp/model/item.rb', line 30

def self.attributes
  new.instance_variable_names.map { |a| a.delete('@') }
end

Instance Method Details

#to_csvObject



34
35
36
# File 'lib/ruby_paypal_nvp/model/item.rb', line 34

def to_csv
  instance_variables.map { |k| instance_variable_get(k) }
end