Sha256: 8344ff8a042cbca2d0cd6c7afa721b61c8b294bd72852848250ec052b39bc62e

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

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

      ACCESS_MASK = 32

      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 contact_notifications
        case row
        when Hash
          [ContactNotification.new(row)]
        when Array
          output = []
          row.each do |contact_notification|
            output << ContactNotification.new(contact_notification)
          end
          output
        else
          raise ArgumentError
        end
      end
      memoize :contact_notifications

      def url
        "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }&characterID=#{ character_id }"
      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/contact_notifications.rb
eve_online-0.10.0 lib/eve_online/characters/contact_notifications.rb
eve_online-0.9.0 lib/eve_online/characters/contact_notifications.rb