Class: EOAT::EveApi

Inherits:
Object
  • Object
show all
Defined in:
lib/eoat/eve_api.rb

Overview

EveApi class - call class. Collects user input, building a url request and passes it to the Request class.

Examples:

skills = EOAT::EveApi.new.SkillTree
skills.result #=> ["skillGroups"]

Get API key info

key_info = EOAT::EveApi.new('keyID', 'vCode', scope: 'account').APIKeyInfo
key_info.key.type #=> "Corporation"

Author:

Instance Method Summary collapse

Constructor Details

#initialize(key_id = '', v_code = '', scope: 'eve', host: 'https://api.eveonline.com') ⇒ EveApi

Returns a new instance of EveApi.

Parameters:

  • key_id (Integer, String) (defaults to: '')

    EVE API keyID

  • v_code (String) (defaults to: '')

    EVE API vCode

  • scope (String) (defaults to: 'eve')

    part of request uri

  • host (String) (defaults to: 'https://api.eveonline.com')

    request host

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
# File 'lib/eoat/eve_api.rb', line 17

def initialize(key_id='', v_code='', scope: 'eve', host: 'https://api.eveonline.com')
  @key_id = key_id.to_s
  @v_code = v_code.to_s
  @scope = scope.to_s
  @host = host.to_s
  unless key_id.to_s.empty?
    raise ArgumentError, 'You do not specify vCode' if v_code.to_s.empty?
  end
  raise ArgumentError, 'vCode must be string' unless v_code.instance_of? String
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, **kwargs) ⇒ Object

Create an request according to the method called. This is used to dynamically create api calls.

Returns:

  • (Object)

    the result class



31
32
33
34
# File 'lib/eoat/eve_api.rb', line 31

def method_missing(method, **kwargs)
  uri = create_uri(method.id2name, kwargs)
  EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get
end