Sha256: 3b46a262d8cc3bbb5eefff8ae1363baeb035fdebde51807ab2ef43228e0b3f8c

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module EveOnline
  module ESI
    class CharacterPortrait < Base
      API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/portrait/?datasource=tranquility'.freeze

      attr_reader :character_id

      def initialize(character_id)
        super()
        @character_id = character_id
      end

      # https://eveonline-third-party-documentation.readthedocs.io/en/latest/imageserver/intro.html#character-images
      # Available Sizes: 32, 64, 128, 256, 512, 1024
      # https://nethackwiki.com/wiki/Physical_size
      # Tiny = 0; Small = 1; Medium = 2; Large = 3; Huge = 4; Gigantic = 7.
      def as_json
        {
          small: small,
          medium: medium,
          large: large,
          huge: huge
        }
      end

      def tiny
        # FIXME: https://github.com/ccpgames/esi-issues/issues/270
        # FIXME: https://github.com/ccpgames/esi-issues/issues/131
        raise NotImplementedError
      end

      def small
        response.fetch('px64x64')
      end

      def medium
        response.fetch('px128x128')
      end

      def large
        response.fetch('px256x256')
      end

      def huge
        response.fetch('px512x512')
      end

      def gigantic
        # FIXME: https://github.com/ccpgames/esi-issues/issues/270
        # FIXME: https://github.com/ccpgames/esi-issues/issues/131
        raise NotImplementedError
      end

      def scope; end

      def url
        API_ENDPOINT % character_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.11.0 lib/eve_online/esi/character_portrait.rb