Class: EveOnline::ESI::Client

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

Constant Summary collapse

BASE_URL =
"https://esi.evetech.net/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token: nil, language: "en", tenant: "tranquility", adapter: Faraday.default_adapter, cache: false, cache_store: nil, timeout: 30, open_timeout: 30, read_timeout: 30, write_timeout: 30) ⇒ Client

Returns a new instance of Client.

Parameters:

  • token (String) (defaults to: nil)

    ESI token. Default: nil.

  • language (String) (defaults to: "en")

    The language to use for the response. One of: "en", "de", "fr", "ja", "zh", "ko", "es". Default: "en".

  • tenant (String) (defaults to: "tranquility")

    The tenant ID for the request. Default: "tranquility".

  • adapter (Symbol) (defaults to: Faraday.default_adapter)

    Default: Faraday.default_adapter

  • cache (Boolean) (defaults to: false)

    Use faraday-http-cache for cache? Default: false.

  • cache_store (ActiveSupport::Cache) (defaults to: nil)

    Rails.cache store. Default: nil.

  • timeout (Integer | Float) (defaults to: 30)

    The max number of seconds to wait for the request to complete. Default: 30.

  • open_timeout (Integer | Float) (defaults to: 30)

    The max number of seconds to wait for the connection to be established. Default: 30.

  • read_timeout (Integer | Float) (defaults to: 30)

    The max number of seconds to wait for one block to be read. Default: 30.

  • write_timeout (Integer | Float) (defaults to: 30)

    The max number of seconds to wait for one block to be written. Default: 30.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/eve_online/esi/client.rb', line 24

def initialize(token: nil, language: "en", tenant: "tranquility",
  adapter: Faraday.default_adapter,
  cache: false, cache_store: nil,
  timeout: 30, open_timeout: 30, read_timeout: 30, write_timeout: 30)
  @token = token
  @language = language
  @tenant = tenant
  @adapter = adapter
  @cache = cache
  @cache_store = cache_store
  @middlewares = []
  @timeout = timeout
  @open_timeout = open_timeout
  @read_timeout = read_timeout
  @write_timeout = write_timeout
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def adapter
  @adapter
end

#cacheObject (readonly)

Returns the value of attribute cache.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def cache
  @cache
end

#cache_storeObject (readonly)

Returns the value of attribute cache_store.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def cache_store
  @cache_store
end

#languageObject (readonly)

Returns the value of attribute language.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def language
  @language
end

#open_timeoutObject (readonly)

Returns the value of attribute open_timeout.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def open_timeout
  @open_timeout
end

#read_timeoutObject (readonly)

Returns the value of attribute read_timeout.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def read_timeout
  @read_timeout
end

#tenantObject (readonly)

Returns the value of attribute tenant.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def tenant
  @tenant
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def timeout
  @timeout
end

#tokenObject (readonly)

Returns the value of attribute token.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def token
  @token
end

#write_timeoutObject (readonly)

Returns the value of attribute write_timeout.



11
12
13
# File 'lib/eve_online/esi/client.rb', line 11

def write_timeout
  @write_timeout
end

Instance Method Details

#add_middleware(middleware) ⇒ Object



208
209
210
# File 'lib/eve_online/esi/client.rb', line 208

def add_middleware(middleware)
  @middlewares << middleware
end

#alliancesObject

Alliance APIs



44
45
46
# File 'lib/eve_online/esi/client.rb', line 44

def alliances
  Resources::AlliancesResources.new(self)
end

#assetsObject

Assets APIs



49
50
51
# File 'lib/eve_online/esi/client.rb', line 49

def assets
  Resources::AssetsResources.new(self)
end

#calendarObject

Calendar APIs



54
55
56
# File 'lib/eve_online/esi/client.rb', line 54

def calendar
  Resources::CalendarsResources.new(self)
end

#charactersObject

Character APIs



59
60
61
# File 'lib/eve_online/esi/client.rb', line 59

def characters
  Resources::CharactersResources.new(self)
end

#clonesObject

Clones APIs



64
65
66
# File 'lib/eve_online/esi/client.rb', line 64

def clones
  Resources::ClonesResources.new(self)
end

#connectionObject



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/eve_online/esi/client.rb', line 212

def connection
  @connection ||= Faraday.new(BASE_URL) do |c|
    if token
      c.request :authorization, "Bearer", token
    end

    if cache
      c.use :http_cache,
        store: cache_store,
        strategy: Faraday::HttpCache::Strategies::ByUrl,
        serializer: Marshal
    end

    c.options.timeout = timeout if timeout
    c.options.open_timeout = open_timeout if open_timeout
    c.options.read_timeout = read_timeout if read_timeout
    c.options.write_timeout = write_timeout if write_timeout

    c.request :json

    c.response :esi_raise_errors
    c.response :esi_parse_eve_dates
    c.response :json, content_type: "application/json"

    c.adapter adapter
  end
end

#contactsObject

Contacts APIs



69
70
71
# File 'lib/eve_online/esi/client.rb', line 69

def contacts
  Resources::ContactsResources.new(self)
end

#contractsObject

Contracts APIs



74
75
76
# File 'lib/eve_online/esi/client.rb', line 74

def contracts
  Resources::ContractsResources.new(self)
end

#corporation_projectsObject

Corporation Projects APIs



84
85
86
# File 'lib/eve_online/esi/client.rb', line 84

def corporation_projects
  Resources::CorporationProjectsResources.new(self)
end

#corporationsObject

Corporation APIs



79
80
81
# File 'lib/eve_online/esi/client.rb', line 79

def corporations
  Resources::CorporationsResources.new(self)
end

#dogmaObject

Dogma APIs



89
90
91
# File 'lib/eve_online/esi/client.rb', line 89

def dogma
  Resources::DogmaResources.new(self)
end

#faction_warfareObject

Faction Warfare APIs



94
95
96
# File 'lib/eve_online/esi/client.rb', line 94

def faction_warfare
  Resources::FactionWarfareResources.new(self)
end

#fittingsObject

Fittings APIs



99
100
101
# File 'lib/eve_online/esi/client.rb', line 99

def fittings
  Resources::FittingsResources.new(self)
end

#fleetsObject

Fleets APIs



104
105
106
# File 'lib/eve_online/esi/client.rb', line 104

def fleets
  Resources::FleetsResources.new(self)
end

#freelance_jobsObject

Freelance Jobs APIs



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

def freelance_jobs
  Resources::FreelanceJobsResources.new(self)
end

#incursionsObject

Incursions APIs



114
115
116
# File 'lib/eve_online/esi/client.rb', line 114

def incursions
  Resources::IncursionsResources.new(self)
end

#industryObject

Industry APIs



119
120
121
# File 'lib/eve_online/esi/client.rb', line 119

def industry
  Resources::IndustryResources.new(self)
end

#insuranceObject

Insurance APIs



124
125
126
# File 'lib/eve_online/esi/client.rb', line 124

def insurance
  Resources::InsuranceResources.new(self)
end

#killmailsObject

Killmails APIs



129
130
131
# File 'lib/eve_online/esi/client.rb', line 129

def killmails
  Resources::KillmailsResources.new(self)
end

#locationsObject

Location APIs



134
135
136
# File 'lib/eve_online/esi/client.rb', line 134

def locations
  Resources::LocationResources.new(self)
end

#loyaltyObject

Loyalty APIs



139
140
141
# File 'lib/eve_online/esi/client.rb', line 139

def loyalty
  Resources::LoyaltyPointsResources.new(self)
end

#mailObject

Mail APIs



144
145
146
# File 'lib/eve_online/esi/client.rb', line 144

def mail
  Resources::MailResources.new(self)
end

#marketObject

Market APIs



149
150
151
# File 'lib/eve_online/esi/client.rb', line 149

def market
  Resources::MarketResources.new(self)
end

#metaObject

Meta APIs



154
155
156
# File 'lib/eve_online/esi/client.rb', line 154

def meta
  Resources::MetaResources.new(self)
end

#planetary_interactionObject

Planetary Interaction APIs



159
160
161
# File 'lib/eve_online/esi/client.rb', line 159

def planetary_interaction
  Resources::PlanetaryInteractionResources.new(self)
end

#routesObject

Routes APIs



164
165
166
# File 'lib/eve_online/esi/client.rb', line 164

def routes
  Resources::RoutesResources.new(self)
end

#searchObject

Search APIs



169
170
171
# File 'lib/eve_online/esi/client.rb', line 169

def search
  Resources::SearchResources.new(self)
end

#server_statusObject

Status API



184
185
186
# File 'lib/eve_online/esi/client.rb', line 184

def server_status
  Resources::ServerStatusResources.new(self)
end

#skillsObject

Skills APIs



174
175
176
# File 'lib/eve_online/esi/client.rb', line 174

def skills
  Resources::SkillsResources.new(self)
end

#sovereigntyObject

Sovereignty APIs



179
180
181
# File 'lib/eve_online/esi/client.rb', line 179

def sovereignty
  Resources::SovereigntyResources.new(self)
end

#universeObject

Universe



189
190
191
# File 'lib/eve_online/esi/client.rb', line 189

def universe
  Resources::UniverseResources.new(self)
end

#user_interfaceObject

User Interface APIs



194
195
196
# File 'lib/eve_online/esi/client.rb', line 194

def user_interface
  Resources::UserInterfaceResources.new(self)
end

#walletObject

Wallet APIs



199
200
201
# File 'lib/eve_online/esi/client.rb', line 199

def wallet
  Resources::WalletResources.new(self)
end

#warsObject

Wars APIs



204
205
206
# File 'lib/eve_online/esi/client.rb', line 204

def wars
  Resources::WarsResources.new(self)
end