Class: EVEApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/eveapi/client.rb

Overview

Client instance and HTTP method handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_id = nil, vcode = nil, character_id = nil) ⇒ EVEAPI::Client


24
25
26
27
28
29
# File 'lib/eveapi/client.rb', line 24

def initialize(key_id = nil, vcode = nil, character_id = nil)
  @connection ||= Excon.new(API_ENDPOINT)
  @key_id = key_id
  @character_id = character_id
  @vcode = vcode
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_args, &_block) ⇒ Object (private)

Dynamic handling of API requests


184
185
186
187
# File 'lib/eveapi/client.rb', line 184

def method_missing(name, *_args, &_block)
  fail 'Invalid Method Name' if name.to_path.empty?
  api_request(name)
end

Instance Attribute Details

#character_idString

Character ID


15
16
17
# File 'lib/eveapi/client.rb', line 15

def character_id
  @character_id
end

#connectionExcon::Connection

HTTP connection to the API endpoint


6
7
8
# File 'lib/eveapi/client.rb', line 6

def connection
  @connection
end

#key_idString

API Key ID


9
10
11
# File 'lib/eveapi/client.rb', line 9

def key_id
  @key_id
end

#row_countString

Number of result rows to get


18
19
20
# File 'lib/eveapi/client.rb', line 18

def row_count
  @row_count
end

#vcodeString

API Key verification code


12
13
14
# File 'lib/eveapi/client.rb', line 12

def vcode
  @vcode
end

Instance Method Details

#account_statusHash

Account Status

Examples:

client.# => {
#                   :paid_until => "2015-10-12 23:55:48",
#                  :create_date => "2006-09-10 02:17:00",
#                  :logon_count => "2276",
#                :logon_minutes => "193996",
#     :multi_character_training => nil,
#                       :offers => nil
# }

126
127
128
# File 'lib/eveapi/client.rb', line 126

def 
  api_request(:account_account_status)
end

#api_methodsArray

API methods

Examples:

client.api_methods# => [
# [ 0] :char_chat_channels,
# [ 1] :char_bookmarks,
# [ 2] :char_locations,
# [ 3] :char_contracts,
# ...
# ]

55
56
57
# File 'lib/eveapi/client.rb', line 55

def api_methods
  api_methods_hash.map { |m| m[:name] }
end

#call_listHash

Description of method Details

Examples:

Client.new.call_list.keys# => [
#     [0] :call_groups,
#     [1] :calls
#    ]

Client.new.call_list[:call_groups]# => [
# [0] {
#    :group_id => "1",
#        :name => "Account and Market",
# :description => "Market Orders, account balance and journal history."
# },
# ... ]

172
173
174
# File 'lib/eveapi/client.rb', line 172

def call_list
  api_request(:api_call_list)
end

#charactersArray

List of characters belonging to the account

Examples:

client = Client.new(4278167, "supersecretstuff", 95512059)
characters = client.characters
characters.first.name# => "Quint Slade"

See Also:


91
92
93
94
95
96
97
98
# File 'lib/eveapi/client.rb', line 91

def characters
  case 
  when Array
    return characters_array()
  when Hash
    return characters_hash()
  end
end

#key_infoHash

API key details

Examples:

client = Client.new(4278167, "supersecretstuff", 95512059)
client.key_info# => {
#     :access_mask => "268435455",
#            :type => "Account",
#         :expires => "",
#      :characters => {
#             :character_id => "95512059",
#           :character_name => "Quint Slade",
#           :corporation_id => "1000166",
#         :corporation_name => "Imperial Academy",
#              :alliance_id => "0",
#            :alliance_name => "",
#               :faction_id => "0",
#             :faction_name => ""
#     }
# }

151
152
153
# File 'lib/eveapi/client.rb', line 151

def key_info
  api_request(:account_api_key_info)
end

#paramsHash

Query params used in the API request


34
35
36
37
38
39
40
41
# File 'lib/eveapi/client.rb', line 34

def params
  {
    'rowCount'    => row_count,
    'keyID'       => key_id,
    'vCode'       => vcode,
    'characterID' => character_id
  }.select { |_k, v| v }
end

#server_statusHash

Status of the Tranquility server

Examples:

Client.new.server_status# => {
#        :server_open => "True",
#     :online_players => "25292"
# }

109
110
111
# File 'lib/eveapi/client.rb', line 109

def server_status
  api_request(:server_server_status)
end

#working_methodsArray

List of implemented methods

Examples:

Client.new.working_methods# => [
#     [0] :account_status,
#     [1] :server_status,
#     [2] :characters,
#     [3] :api_methods,
#     [4] :key_info,
#     [5] :call_list
# ]

203
204
205
# File 'lib/eveapi/client.rb', line 203

def working_methods
  EVEApi::WORKING_METHODS
end