class EVEApi::Client
Client
instance and HTTP method handling
Attributes
Character
ID @return [String]
HTTP connection to the API endpoint @return [Excon::Connection]
API Key ID @return [String]
Number of result rows to get @return [String]
API Key verification code @return [String]
Public Class Methods
@param [String] key_id
API key ID @param [String] vcode API verification code @param [String] character_id
Character
ID @return [EVEAPI::Client] client
# 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
Public Instance Methods
Account Status
@return [Hash] account status @example
client.account_status # => { # :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 # }
# File lib/eveapi/client.rb, line 126 def account_status api_request(:account_account_status) end
API methods
@return [Array] list of ruby API method names @example
client.api_methods # => [ # [ 0] :char_chat_channels, # [ 1] :char_bookmarks, # [ 2] :char_locations, # [ 3] :char_contracts, # ... # ]
# File lib/eveapi/client.rb, line 55 def api_methods api_methods_hash.map { |m| m[:name] } end
Description of method Details @return [Hash] list of API :calls
and :call_groups
@example
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." # }, # ... ]
# File lib/eveapi/client.rb, line 172 def call_list api_request(:api_call_list) end
List of characters belonging to the account
@return [Array] of characters for account @see Character
@example
client = Client.new(4278167, "supersecretstuff", 95512059) characters = client.characters characters.first.name # => "Quint Slade"
# File lib/eveapi/client.rb, line 91 def characters case account_characters when Array return characters_array(account_characters) when Hash return characters_hash(account_characters) end end
API key details
@return [Hash] API key info @example
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 => "" # } # }
# File lib/eveapi/client.rb, line 151 def key_info api_request(:account_api_key_info) end
Query params used in the API request
@return [Hash] query params for the API request
# 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
Status of the Tranquility server
@return [Hash] Tranquility server status @example
Client.new.server_status # => { # :server_open => "True", # :online_players => "25292" # }
# File lib/eveapi/client.rb, line 109 def server_status api_request(:server_server_status) end
List of implemented methods
@return [Array] list of implemented Client
methods @example
Client.new.working_methods # => [ # [0] :account_status, # [1] :server_status, # [2] :characters, # [3] :api_methods, # [4] :key_info, # [5] :call_list # ]
# File lib/eveapi/client.rb, line 203 def working_methods EVEApi::WORKING_METHODS end
Private Instance Methods
# File lib/eveapi/client.rb, line 59 def api_methods_hash api_call_list[:calls].map do |m| { name: m.ruby_method_name, desc: m[:description] } end end
# File lib/eveapi/client.rb, line 176 def api_request(name) http = connection.get(path: name.to_path, query: params) request = EVEApi::Request.new(http) request.result end
# File lib/eveapi/client.rb, line 66 def characters_array(account_characters) account_characters.to_a.map do |character| args = character args.merge!(key_id: key_id, vcode: vcode) Character.new(args) end end
# File lib/eveapi/client.rb, line 75 def characters_hash(account_characters) args = account_characters args.merge!(key_id: key_id, vcode: vcode) [Character.new(args)] end
Dynamic handling of API requests
# 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