Sha256: 0eecb0b938d9a635dc7a0fc75c63b4f0ef80d3359b1dd6c9009841170743163b

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

require 'active_support/time'

module EveOnline
  class WalletJournalEntry
    attr_reader :options

    def initialize(options)
      @options = options
    end

    def as_json
      {
        date: date,
        ref_id: ref_id,
        ref_type_id: ref_type_id,
        owner_name1: owner_name1,
        owner_id1: owner_id1,
        owner_name2: owner_name2,
        owner_id2: owner_id2,
        arg_name1: arg_name1,
        arg_id1: arg_id1,
        amount: amount,
        balance: balance,
        reason: reason,
        tax_receiver_id: tax_receiver_id,
        tax_amount: tax_amount,
        owner1_type_id: owner1_type_id,
        owner2_type_id: owner2_type_id
      }
    end

    def date
      ActiveSupport::TimeZone['UTC'].parse(options.fetch('@date'))
    end

    def ref_id
      options.fetch('@refID').to_i
    end

    def ref_type_id
      options.fetch('@refTypeID').to_i
    end

    def owner_name1
      options.fetch('@ownerName1')
    end

    def owner_id1
      options.fetch('@ownerID1').to_i
    end

    def owner_name2
      options.fetch('@ownerName2')
    end

    def owner_id2
      options.fetch('@ownerID2').to_i
    end

    def arg_name1
      options.fetch('@argName1')
    end

    def arg_id1
      options.fetch('@argID1').to_i
    end

    def amount
      options.fetch('@amount').to_f
    end

    def balance
      options.fetch('@balance').to_f
    end

    def reason
      options.fetch('@reason')
    end

    def tax_receiver_id
      # TODO: to_i
      options.fetch('@taxReceiverID')
    end

    def tax_amount
      options.fetch('@taxAmount')
    end

    def owner1_type_id
      options.fetch('@owner1TypeID').to_i
    end

    def owner2_type_id
      options.fetch('@owner2TypeID').to_i
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eve_online-0.14.0 lib/eve_online/wallet_journal_entry.rb
eve_online-0.13.0 lib/eve_online/wallet_journal_entry.rb
eve_online-0.12.0 lib/eve_online/wallet_journal_entry.rb
eve_online-0.11.0 lib/eve_online/wallet_journal_entry.rb
eve_online-0.10.0 lib/eve_online/wallet_journal_entry.rb
eve_online-0.9.0 lib/eve_online/wallet_journal_entry.rb