esi 0.4.6 → 0.4.7.pre.alpha.pre.60

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4ef7c659090137fe7ff8581cdb6c6a9e9c240faa
4
- data.tar.gz: 1e47ffce54eda2555fa7f64e3e841e0507162040
2
+ SHA256:
3
+ metadata.gz: fbc70e783ed11bfc5bc067cf0d195819a97654300ef948efa0ee0dfe808bbea3
4
+ data.tar.gz: fddd2c207b9252ab65cb20e2e97b98d3b2c6d4fa53fadb73aad17bada64d79b3
5
5
  SHA512:
6
- metadata.gz: 3354040d05b7f3d674c072081b30815bc63b1ced681d64933e24461b039839f424e29724e2e624320120b652a5e4e43dc7253a5eca4fd3371b0a745bc6db60c1
7
- data.tar.gz: 318a635d10e008cd0fc1daf06f8cfe028c677f041af49db8261a8f6d08d535862ff1a25ac758835b2397d9d96f0cbc84dce9dbecfffbbe6c5c0f3f85e366d825
6
+ metadata.gz: 5a87bad611f8897e6ecbb073e4f8f17dedde3996ddf9293f918133459773e477dde1850a5c4039459ceb10a4ab2b557c75fcbe562c9cb5cd558e6d5b3d046d4f
7
+ data.tar.gz: eb14b1cffdd7f6f6a4c02c970834da709fa1e55c7e7d9cfee58099b47079b87d68d62fbe4d5123e9856cc41dbd690cc5a1780e1c0019ed8efb505fbed323196e
data/esi.gemspec CHANGED
@@ -6,10 +6,15 @@ require 'esi/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'esi'
9
- spec.version = Esi::VERSION
10
9
  spec.authors = ['Danny Hiemstra', 'Aaron Allen']
11
10
  spec.email = ['dannyhiemstra@gmail.com', 'aaronmallen4@gmail.com']
12
11
 
12
+ # @note https://docs.travis-ci.com/user/deployment/rubygems/#Pre-releasing
13
+ # rubocop:disable Gemspec/DuplicatedAssignment
14
+ spec.version = Esi::VERSION
15
+ spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
16
+ # rubocop:enable Gemspec/DuplicatedAssignment
17
+
13
18
  spec.summary = 'EVE ESI API wrapper'
14
19
  spec.description = 'EVE ESI API wrapper'
15
20
  spec.homepage = 'https://github.com/dhiemstra/esi'
data/lib/esi/api_error.rb CHANGED
@@ -16,8 +16,8 @@ module Esi
16
16
  attr_reader :response, :key, :message, :type, :original_exception
17
17
 
18
18
  # Create a new instance of ApiError
19
- # @param [Esi::Response] response the response that generated the exception
20
- # @param [ExceptionClass|nil] the orginally raised exception
19
+ # @param response [Esi::Response] response the response that generated the exception
20
+ # @param original_exception [ExceptionClass|nil] the orginally raised exception
21
21
  # @return [Esi::ApiError] an instance of ApiError
22
22
  def initialize(response, original_exception = nil)
23
23
  super(response.original_response)
@@ -38,7 +38,7 @@ module Esi
38
38
  attr_reader :original_exception
39
39
 
40
40
  # Create a new instance of ApiRequestError
41
- # @param [ExceptionClass|nil] the orginally raised exception
41
+ # @param original_exception [ExceptionClass|nil] the orginally raised exception
42
42
  # @return [Esi::ApiRequestError] the instance of ApiRequestError
43
43
  def initialize(original_exception)
44
44
  @original_exception = original_exception
data/lib/esi/calls.rb CHANGED
@@ -1,620 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'esi/calls/base'
4
+ require 'esi/calls/info'
5
+ require 'esi/calls/universe'
6
+ require 'esi/calls/dogma'
7
+ require 'esi/calls/characters'
8
+ require 'esi/calls/corporations'
9
+ require 'esi/calls/alliances'
10
+ require 'esi/calls/ui'
11
+ require 'esi/calls/search'
12
+ require 'esi/calls/route'
13
+ require 'esi/calls/industry'
14
+ require 'esi/calls/killmails'
15
+ require 'esi/calls/fleets'
16
+
3
17
  module Esi
4
18
  class Calls
5
19
  class << self
20
+ # Generate a list with all available calls
21
+ #
22
+ # @return [Array<Symbol>] list of underscored call names
6
23
  def list
7
- constants.select { |c| Esi::Calls.const_get(c).try(:scope) }.map { |c| c.to_s.underscore.to_sym }
8
- end
9
- end
10
-
11
- class Info
12
- attr_reader :name, :call
13
- delegate :scope, :cache_duration, to: :call
14
-
15
- def initialize(name)
16
- @name = name.to_sym
17
- @call = Calls.const_get(name.to_s.camelize)
18
- end
19
-
20
- def to_s
21
- @name.to_s
22
- end
23
-
24
- def character?
25
- name.to_s.starts_with?('character')
26
- end
27
-
28
- def corporation?
29
- name.to_s.starts_with?('corporat')
30
- end
31
- end
32
-
33
- class Base
34
- CACHE_NAMESPACE = 'esi'
35
-
36
- class_attribute :scope
37
- class_attribute :cache_duration
38
-
39
- attr_accessor :path, :params
40
-
41
- def cache_key
42
- @cache_key ||= begin
43
- cache_args = [CACHE_NAMESPACE, path.gsub(%r{^\/}, ''), params.sort].flatten
44
- ActiveSupport::Cache.expand_cache_key(cache_args)
45
- end
46
- end
47
-
48
- def method
49
- @method ||= :get
50
- end
51
-
52
- def url
53
- Esi.generate_url(path, params)
54
- end
55
-
56
- def page=(page)
57
- self.params ||= {}
58
- self.params[:page] = page
59
- end
60
-
61
- def paginated?
62
- !@paginated
63
- end
64
- end
65
-
66
- class Regions < Base
67
- def initialize
68
- @path = '/universe/regions/'
69
- end
70
- end
71
-
72
- class Region < Base
73
- def initialize(region_id)
74
- @path = "/universe/regions/#{region_id}"
75
- end
76
- end
77
-
78
- class Constellations < Base
79
- def initialize
80
- @path = '/universe/constellations/'
81
- end
82
- end
83
-
84
- class Constellation < Base
85
- def initialize(constellation_id)
86
- @path = "/universe/constellations/#{constellation_id}"
87
- end
88
- end
89
-
90
- class SolarSystem < Base
91
- def initialize(system_id)
92
- @path = "/universe/systems/#{system_id}"
93
- end
94
- end
95
-
96
- class SolarSystems < Base
97
- def initialize
98
- @path = '/universe/systems/'
99
- end
100
- end
101
-
102
- class Star < Base
103
- def initialize(star_id)
104
- @path = "/universe/stars/#{star_id}"
105
- end
106
- end
107
-
108
- class Planet < Base
109
- def initialize(planet_id)
110
- @path = "/universe/planets/#{planet_id}"
111
- end
112
- end
113
-
114
- class Moon < Base
115
- def initialize(moon_id)
116
- @path = "/universe/moons/#{moon_id}"
117
- end
118
- end
119
-
120
- class Stargate < Base
121
- def initialize(stargate_id)
122
- @path = "/universe/stargates/#{stargate_id}"
123
- end
124
- end
125
-
126
- class Station < Base
127
- def initialize(station_id)
128
- @path = "/universe/stations/#{station_id}"
129
- end
130
- end
131
-
132
- class Structures < Base
133
- def initialize
134
- @path = '/universe/structures/'
135
- end
136
- end
137
-
138
- class Structure < Base
139
- def initialize(structure_id)
140
- @path = "universe/structures/#{structure_id}"
141
- end
142
- end
143
-
144
- class Types < Base
145
- def initialize
146
- @path = '/universe/types'
147
- @paginated = true
148
- end
149
- end
150
-
151
- class Type < Base
152
- def initialize(type_id)
153
- @path = "/universe/types/#{type_id}"
154
- end
155
- end
156
-
157
- class DogmaAttributes < Base
158
- def initialize
159
- @path = '/dogma/attributes/'
160
- end
161
- end
162
-
163
- class DogmaAttribute < Base
164
- def initialize(attribute_id)
165
- @path = "/dogma/attributes/#{attribute_id}"
166
- end
167
- end
168
-
169
- class DogmaEffects < Base
170
- def initialize
171
- @path = '/dogma/effects/'
172
- end
173
- end
174
-
175
- class DogmaEffect < Base
176
- def initialize(effect_id)
177
- @path = "/dogma/effects/#{effect_id}"
178
- end
179
- end
180
-
181
- class IndustryFacilities < Base
182
- self.scope = nil
183
- self.cache_duration = 3600
184
-
185
- def initialize
186
- @path = '/industry/facilities'
187
- end
188
- end
189
-
190
- class IndustrySystems < Base
191
- self.scope = nil
192
- self.cache_duration = 3600
193
-
194
- def initialize
195
- @path = '/industry/systems'
196
- end
197
- end
198
-
199
- class Search < Base
200
- self.scope = nil
201
- # https://esi.tech.ccp.is/latest/characters/907452336/search/?categories=structure&datasource=tranquility&search=Kamela&strict=false&token=Fp3ThF7wjvYBIDIIrtWE_Ryjt9BhYwUP75y2EL5Eq9mHPm8tYt9I9NwgZz8o26FFQBKoUToh2DYVc-Q5Ws400g2
202
-
203
- def initialize(character_id: nil, categories:, search:, strict: false)
204
- @path = (character_id ? "/characters/#{character_id}" : '') + '/search'
205
- @params = { categories: categories, search: search, strict: strict }
206
- end
207
- end
208
-
209
- class StructureOrders < Base
210
- def initialize(structure_id:)
211
- @path = "/markets/structures/#{structure_id}"
212
- @paginated = true
213
- end
214
- end
215
-
216
- class CharacterNames < Base
217
- self.cache_duration = 3600
218
-
219
- def initialize(character_ids)
220
- @path = '/characters/names'
221
- @params = { character_ids: character_ids.join(',') }
222
- end
223
- end
224
-
225
- class Character < Base
226
- self.cache_duration = 3600
227
-
228
- def initialize(character_id)
229
- @path = "/characters/#{character_id}"
230
- end
231
- end
232
-
233
- # Cache: 2 minutes
234
- class CharacterWallet < Base
235
- self.scope = 'esi-wallet.read_character_wallet.v1'
236
- self.cache_duration = 120
237
-
238
- def initialize(character_id)
239
- @path = "/characters/#{character_id}/wallet"
240
- end
241
- end
242
-
243
- class CharacterSkills < Base
244
- self.scope = 'esi-skills.read_skills.v1'
245
- self.cache_duration = 120
246
-
247
- def initialize(character_id)
248
- @path = "/characters/#{character_id}/skills"
249
- end
250
- end
251
-
252
- class CharacterWalletJournal < Base
253
- self.scope = 'esi-wallet.read_character_wallet.v1'
254
- self.cache_duration = 3600
255
-
256
- def initialize(character_id)
257
- @path = "/characters/#{character_id}/wallet/journal"
258
- end
259
- end
260
-
261
- class CharacterWalletTransactions < Base
262
- self.scope = 'esi-wallet.read_character_wallet.v1'
263
- self.cache_duration = 3600
264
-
265
- def initialize(character_id)
266
- @path = "/characters/#{character_id}/wallet/transactions"
267
- end
268
- end
269
-
270
- class CharacterOrders < Base
271
- self.scope = 'esi-markets.read_character_orders.v1'
272
- self.cache_duration = 3600
273
-
274
- def initialize(character_id)
275
- @path = "/characters/#{character_id}/orders"
276
- end
277
- end
278
-
279
- #################################
280
- ### IndustryJobs
281
- #################################
282
- class CharacterIndustryJobs < Base
283
- self.scope = 'esi-industry.read_character_jobs.v1'
284
- self.cache_duration = 300
285
-
286
- def initialize(character_id, with_completed: true)
287
- @path = "/characters/#{character_id}/industry/jobs"
288
- @params = { include_completed: with_completed }
289
- end
290
- end
291
-
292
- class CorporationIndustryJobs < Base
293
- self.scope = 'esi-industry.read_corporation_jobs.v1'
294
- self.cache_duration = 300
295
-
296
- def initialize(corporation_id, with_completed: true)
297
- @path = "/corporations/#{corporation_id}/industry/jobs"
298
- @params = { include_completed: with_completed }
299
- end
300
- end
301
-
302
- #################################
303
- ### Blueprints
304
- #################################
305
- class CharacterBlueprints < Base
306
- self.scope = 'esi-characters.read_blueprints.v1'
307
- self.cache_duration = 3600
308
-
309
- def initialize(character_id)
310
- @path = "/characters/#{character_id}/blueprints"
311
- end
312
- end
313
-
314
- class CorporationBlueprints < Base
315
- self.scope = 'esi-corporations.read_blueprints.v1'
316
- self.cache_duration = 3600
317
-
318
- def initialize(corporation_id)
319
- @path = "/corporations/#{corporation_id}/blueprints"
320
- end
321
- end
322
-
323
- #################################
324
- ### Assets
325
- #################################
326
- class CharacterAssets < Base
327
- self.scope = 'esi-assets.read_assets.v1'
328
- self.cache_duration = 3600
329
-
330
- def initialize(character_id)
331
- @path = "/characters/#{character_id}/assets"
332
- @paginated = true
333
- end
334
- end
335
-
336
- class CorporationAssets < Base
337
- self.scope = 'esi-assets.read_corporation_assets.v1'
338
- self.cache_duration = 3600
339
-
340
- def initialize(corporation_id)
341
- @path = "/corporations/#{corporation_id}/assets"
342
- @paginated = true
343
- end
344
- end
345
-
346
- #################################
347
- ### Contracts
348
- #################################
349
- class CharacterContracts < Base
350
- self.scope = 'esi-contracts.read_character_contracts.v1'
351
- self.cache_duration = 3600
352
-
353
- def initialize(character_id)
354
- @path = "/characters/#{character_id}/contracts"
355
- end
356
- end
357
-
358
- class ContractItems < Base
359
- self.scope = 'esi-contracts.read_character_contracts.v1'
360
- self.cache_duration = 3600
361
-
362
- def initialize(character_id, contract_id)
363
- @path = "/characters/#{character_id}/contracts/#{contract_id}/items"
364
- end
365
- end
366
-
367
- class CharacterLocation < Base
368
- self.scope = 'esi-location.read_location.v1'
369
- self.cache_duration = 5
370
-
371
- def initialize(character_id)
372
- @path = "/characters/#{character_id}/location"
373
- end
374
- end
375
-
376
- # characters/{character_id}/online
377
- # esi-location.read_online.v1
378
- # 60
379
-
380
- # /characters/{character_id}/attributes
381
- # esi-skills.read_skills.v1
382
- # 3600
383
-
384
- # /characters/{character_id}/chat_channels
385
- # esi-characters.read_chat_channels.v1
386
- # 300
387
-
388
- # /characters/{character_id}/clones
389
- # esi-clones.read_clones.v1
390
- # 120
391
-
392
- # /characters/{character_id}/implants
393
- # esi-clones.read_implants.v1
394
- # 3600
395
-
396
- # /characters/{character_id}/roles
397
- # esi-characters.read_corporation_roles.v1
398
- # 3600
399
-
400
- class CharacterMail < Base
401
- self.scope = 'esi-mail.read_mail.v1'
402
- self.cache_duration = 30
403
-
404
- def initialize(character_id)
405
- @path = "/characters/#{character_id}/mail"
406
- end
407
- end
408
-
409
- class Assets < Base
410
- self.scope = 'esi-assets.read_assets.v1'
411
- self.cache_duration = 3600
412
-
413
- def initialize(character_id)
414
- @path = "/characters/#{character_id}/assets"
415
- end
416
- end
417
-
418
- class Alliances < Base
419
- self.cache_duration = 3600
420
-
421
- def initialize
422
- @path = '/alliances'
423
- end
424
- end
425
-
426
- class AllianceNames < Base
427
- self.cache_duration = 3600
428
-
429
- def initialize(alliance_ids)
430
- @path = '/alliances/names'
431
- @params = { alliance_ids: alliance_ids.join(',') }
432
- end
433
- end
434
-
435
- class Alliance < Base
436
- self.cache_duration = 3600
437
-
438
- def initialize(alliance_id)
439
- @path = "/alliances/#{alliance_id}"
440
- end
441
- end
442
-
443
- class CorporationNames < Base
444
- self.cache_duration = 3600
445
-
446
- def initialize(corporation_ids)
447
- @path = '/corporations/names'
448
- @params = { corporation_ids: corporation_ids.join(',') }
449
- end
450
- end
451
-
452
- class Corporation < Base
453
- self.cache_duration = 3600
454
-
455
- def initialize(corporation_id)
456
- @path = "/corporations/#{corporation_id}"
457
- end
458
- end
459
-
460
- class CorporationStructures < Base
461
- self.scope = 'esi-corporations.read_structures.v1'
462
- self.cache_duration = 3600
463
-
464
- def initialize(corporation_id)
465
- @path = "/corporations/#{corporation_id}/structures"
466
- end
467
- end
468
-
469
- class CorporationMembers < Base
470
- self.scope = 'esi-corporations.read_corporation_membership.v1'
471
- self.cache_duration = 3600
472
-
473
- def initialize(corporation_id)
474
- @path = "/corporations/#{corporation_id}/members"
475
- end
476
- end
477
-
478
- class CorporationMemberTracking < Base
479
- self.scope = 'esi-corporations.track_members.v1'
480
- self.cache_duration = 3600
481
-
482
- def initialize(corporation_id)
483
- @path = "/corporations/#{corporation_id}/membertracking"
484
- end
485
- end
486
-
487
- # Link: https://esi.tech.ccp.is/dev/#!/Corporation/get_corporations_corporation_id_roles
488
- class CorporationRoles < Base
489
- self.scope = 'esi-corporations.read_corporation_membership.v1'
490
- self.cache_duration = 3600
491
-
492
- def initialize(corporation_id)
493
- @path = "/corporations/#{corporation_id}/roles"
494
- end
495
- end
496
-
497
- class CorporationWallet < Base
498
- self.scope = 'esi-wallet.read_corporation_wallet.v1'
499
- self.cache_duration = 120
500
-
501
- def initialize(corporation_id)
502
- @path = "/corporations/#{corporation_id}/wallets"
503
- end
504
- end
505
-
506
- class CorporationWallets < Base
507
- self.scope = 'esi-wallet.read_corporation_wallets.v1'
508
- self.cache_duration = 300
509
- end
510
-
511
- class Route < Base
512
- def initialize(origin_id, destination_id)
513
- @path = "/route/#{origin_id}/#{destination_id}"
514
- end
515
- end
516
-
517
- class MarketHistory < Base
518
- def initialize(region_id:, type_id:)
519
- @path = "/markets/#{region_id}/history"
520
- @params = { type_id: type_id }
521
- end
522
- end
523
-
524
- class MarketTypes < Base
525
- self.scope = nil
526
- self.cache_duration = 600
527
-
528
- def initialize(region_id:)
529
- @path = "/markets/#{region_id}/types"
530
- @paginated = true
531
- end
532
- end
533
-
534
- class MarketGroups < Base
535
- def initialize
536
- @path = '/markets/groups'
537
- @paginated = true
538
- end
539
- end
540
-
541
- class MarketGroup < Base
542
- def initialize(id)
543
- @path = "/markets/groups/#{id}"
544
- end
545
- end
546
-
547
- class MarketPrices < Base
548
- def initialize
549
- @path = '/markets/prices'
550
- end
551
- end
552
-
553
- class MarketOrders < Base
554
- def initialize(region_id:, type_id: nil)
555
- @path = "/markets/#{region_id}/orders"
556
- @params = { order_type: :all }
557
- @params[:type_id] = type_id if type_id.present?
558
- @paginated = type_id.blank?
559
- end
560
- end
561
-
562
- class Killmails < Base
563
- self.scope = 'esi-killmails.read_killmails.v1'
564
-
565
- def initialize(character_id:, max_count: 50, max_kill_id: nil)
566
- @path = "/characters/#{character_id}/killmails/recent"
567
- @params = { max_count: max_count }
568
- @params[:max_kill_id] = max_kill_id if max_kill_id
569
- end
570
- end
571
-
572
- class Killmail < Base
573
- def initialize(id:, hash:)
574
- @path = "killmails/#{id}/#{hash}"
575
- end
576
- end
577
-
578
- class Fleet < Base
579
- def initialize(fleet_id)
580
- @path = "fleets/#{fleet_id}"
581
- end
582
- end
583
-
584
- class FleetMembers < Base
585
- def initialize(fleet_id)
586
- @path = "fleets/#{fleet_id}/members"
587
- end
588
- end
589
-
590
- class FleetWings < Base
591
- def initialize(fleet_id)
592
- @path = "fleets/#{fleet_id}/wings"
593
- end
594
- end
595
-
596
- class Fittings < Base
597
- self.scope = 'esi-fittings.read_fittings.v1'
598
-
599
- def initialize(character_id)
600
- @path = "characters/#{character_id}/fittings"
601
- end
602
- end
603
-
604
- class DeleteFitting < Base
605
- def initialize(character_id, fitting_id)
606
- @path = "characters/#{character_id}/fittings/#{fitting_id}"
607
- @method = :delete
608
- end
609
- end
610
-
611
- class OpenMarketDetails < Base
612
- self.scope = 'esi-ui.open_window.v1'
613
-
614
- def initialize(type_id)
615
- @path = '/ui/openwindow/marketdetails'
616
- @method = :post
617
- @params = { type_id: type_id }
24
+ @list ||= constants.select { |c| Esi::Calls.const_get(c).try(:scope) }
25
+ .map { |c| c.to_s.underscore.to_sym }
618
26
  end
619
27
  end
620
28
  end