Sha256: 627b56c32fa53a708e7cf92f6ad011d604ae43be24ff2d22c995f03be01a633a

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

module RubyPaypalNvp
  module Model
    class Item
      attr_accessor :timestamp, :timezone, :type, :email, :name,
                    :transaction_id, :status, :amount, :currency_code, :fee_amount,
                    :net_amount

      # rubocop:disable Metrics/AbcSize
      # rubocop:disable Metrics/CyclomaticComplexity
      # rubocop:disable Metrics/PerceivedComplexity
      # rubocop:disable Metrics/MethodLength
      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
      # rubocop:enable Metrics/AbcSize
      # rubocop:enable Metrics/CyclomaticComplexity
      # rubocop:enable Metrics/PerceivedComplexity
      # rubocop:enable Metrics/MethodLength

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_paypal_nvp-0.1.1 lib/ruby_paypal_nvp/model/item.rb
ruby_paypal_nvp-0.1.0 lib/ruby_paypal_nvp/model/item.rb