Sha256: ba4ac4ed0ffe01ca3e249598fcb24aa6a8738a5b360aa7afbbe870eafcf29693

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module EveOnline
  module ESI
    class CharacterSkills < Base
      API_ENDPOINT = 'https://esi.evetech.net/v4/characters/%<character_id>s/skills/?datasource=%<datasource>s'

      attr_reader :character_id

      def initialize(options)
        super

        @character_id = options.fetch(:character_id)
      end

      def as_json
        {
          total_sp: total_sp,
          unallocated_sp: unallocated_sp
        }
      end

      def skills
        @skills ||=
          begin
            output = []
            response.fetch('skills').each do |skill|
              output << Models::Skill.new(skill)
            end
            output
          end
      end

      def total_sp
        response['total_sp']
      end

      def unallocated_sp
        response['unallocated_sp']
      end

      def scope
        'esi-skills.read_skills.v1'
      end

      def url
        format(API_ENDPOINT, character_id: character_id, datasource: datasource)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eve_online-0.23.0 lib/eve_online/esi/character_skills.rb
eve_online-0.22.0 lib/eve_online/esi/character_skills.rb
eve_online-0.21.0 lib/eve_online/esi/character_skills.rb