Sha256: 520321077628fcdc016bd3a64f706661f7ba3dce1f982e4ce94044dba40dd212

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

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

      ACCESS_MASK = 268_435_456

      attr_reader :key_id, :v_code, :character_id

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

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

      def url
        output = "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }"
        output = "#{ output }&characterID=#{ character_id }" if character_id
        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

2 entries across 2 versions & 1 rubygems

Version Path
eve_online-0.11.0 lib/eve_online/characters/bookmarks.rb
eve_online-0.10.0 lib/eve_online/characters/bookmarks.rb