Sha256: 7b599b292b4a18c4c08f291ef30603f026961fb22b5ae9d732c8a16e291e15a1

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

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

      attr_reader :key_id, :v_code, :character_id, :flat

      def initialize(key_id, v_code, character_id, flat = 1)
        super()
        @key_id = key_id
        @v_code = v_code
        @character_id = character_id
        @flat = flat
      end

      def assets
        case row
        when Hash
          [EveOnline::Item.new(row)]
        when Array
          output = []
          row.each do |item|
            output << EveOnline::Item.new(item)
          end
          output
        else
          raise ArgumentError
        end
      end

      def row
        @row ||= rowset.fetch('row')
      end

      def rowset
        @rowset ||= result.fetch('rowset')
      end

      def url
        "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }&characterID=#{ character_id }&flat=#{ flat }"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.7.0 lib/eve_online/characters/asset_list.rb