Sha256: 9c863d6198f9ef7d42f159567fb07963d4592c5e0310b950152583c5e164ceb5

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

module EveOnline
  module XML
    # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_standings.html
    class CharacterStandings < Base
      API_ENDPOINT = 'https://api.eveonline.com/char/Standings.xml.aspx'.freeze

      ACCESS_MASK = 524_288

      attr_reader :key_id, :v_code, :character_id

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

      def agents
        output = []
        agents_rowset.each do |agent|
          output << Standing.new(agent)
        end
        output
      end
      memoize :agents

      def npc_corporations
        output = []
        npc_corporations_rowset.each do |agent|
          output << Standing.new(agent)
        end
        output
      end
      memoize :npc_corporations

      def factions
        output = []
        factions_rowset.each do |agent|
          output << Standing.new(agent)
        end
        output
      end
      memoize :factions

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

      private

      def agents_rowset
        result.fetch('characterNPCStandings').fetch('rowset').reject { |a| a.fetch('@name') != 'agents' }.first.fetch('row')
      end
      memoize :agents_rowset

      def npc_corporations_rowset
        result.fetch('characterNPCStandings').fetch('rowset').reject { |a| a.fetch('@name') != 'NPCCorporations' }.first.fetch('row')
      end
      memoize :npc_corporations_rowset

      def factions_rowset
        result.fetch('characterNPCStandings').fetch('rowset').reject { |a| a.fetch('@name') != 'factions' }.first.fetch('row')
      end
      memoize :factions_rowset
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.12.0 lib/eve_online/xml/character_standings.rb