Sha256: 3894c9856f09bba820d77a2f75f0e698ec784ea06e8ad05056da9c06718304b9

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

module EveOnline
  module Characters
    # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_walletjournal.html
    class WalletJournal < BaseXML
      API_ENDPOINT = 'https://api.eveonline.com/char/WalletJournal.xml.aspx'.freeze

      ACCESS_MASK = 2_097_152

      attr_reader :key_id, :v_code, :character_id, :account_key, :from_id, :row_count

      def initialize(key_id, v_code, character_id, options = {})
        super()
        @key_id = key_id
        @v_code = v_code
        @character_id = character_id
        @account_key = options.fetch(:account_key, 1000)
        @from_id = options.fetch(:from_id, nil)
        @row_count = options.fetch(:row_count, nil)
      end

      def wallet_journal_entries
        case row
        when Hash
          [WalletJournalEntry.new(row)]
        when Array
          output = []
          row.each do |blueprint|
            output << WalletJournalEntry.new(blueprint)
          end
          output
        else
          raise ArgumentError
        end
      end
      memoize :wallet_journal_entries

      def url
        output = "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }&characterID=#{ character_id }&accountKey=#{ account_key }"
        output = "#{ output }&fromID=#{ from_id }" if from_id
        output = "#{ output }&rowCount=#{ row_count }" if row_count
        output
      end

      private

      def rowset
        result.fetch('rowset')
      end
      memoize :rowset

      def row
        rowset.fetch('row')
      end
      memoize :row
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eve_online-0.11.0 lib/eve_online/characters/wallet_journal.rb
eve_online-0.10.0 lib/eve_online/characters/wallet_journal.rb
eve_online-0.9.0 lib/eve_online/characters/wallet_journal.rb