Sha256: 102b971a9f4159f56db2999691379157eda92cfc91ec2dbb7ce44e38c0cff582

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require_relative "../base_item"

module Greeve
  module Character
    # Location and name of specific items that belong to the character of the
    # api key. This call can be used to retrieve the player-set name of
    # containers and ships.
    #
    # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_locations.html
    class Locations < Greeve::BaseItem
      endpoint "char/Locations"

      rowset :locations, xpath: "eveapi/result/rowset[@name='locations']" do
        attribute :item_id,   xpath: "@itemID",   type: :integer
        attribute :item_name, xpath: "@itemName", type: :string
        attribute :x,         xpath: "@x",        type: :numeric
        attribute :y,         xpath: "@y",        type: :numeric
        attribute :z,         xpath: "@z",        type: :numeric
      end

      # @param character_id [Integer] EVE character ID
      #
      # @option opts [Array<Integer>, Integer] :ids (nil) ID or array of IDs of
      #   items belonging to the character
      def initialize(character_id, opts = {})
        ids = opts.delete(:ids)
        ids = [ids] unless ids.nil? || ids.is_a?(Array)

        opts[:query_params] = { "characterID" => character_id }
        opts[:query_params]["IDs"] = ids.join(",") if ids

        super(opts)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
greeve-1.0.0 lib/greeve/character/locations.rb