eve_online 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +10 -0
  3. data/.rubocop.yml +2 -7
  4. data/.travis.yml +4 -1
  5. data/Gemfile +1 -1
  6. data/README.md +273 -7
  7. data/eve_online.gemspec +4 -2
  8. data/lib/eve_online.rb +32 -2
  9. data/lib/eve_online/characters/skill_queue.rb +3 -3
  10. data/lib/eve_online/esi/base.rb +15 -2
  11. data/lib/eve_online/esi/character.rb +75 -0
  12. data/lib/eve_online/esi/character_loyalty_points.rb +31 -0
  13. data/lib/eve_online/esi/character_portrait.rb +61 -0
  14. data/lib/eve_online/esi/character_skill_queue.rb +31 -0
  15. data/lib/eve_online/esi/character_skills.rb +41 -0
  16. data/lib/eve_online/esi/models/loyalty_point.rb +28 -0
  17. data/lib/eve_online/esi/models/skill.rb +33 -0
  18. data/lib/eve_online/esi/models/skill_queue_entry.rb +60 -0
  19. data/lib/eve_online/sde/agt_agent_types.rb +14 -0
  20. data/lib/eve_online/sde/agt_agents.rb +14 -0
  21. data/lib/eve_online/sde/agt_research_agents.rb +14 -0
  22. data/lib/eve_online/sde/base.rb +25 -0
  23. data/lib/eve_online/sde/chr_races.rb +14 -0
  24. data/lib/eve_online/sde/inv_flags.rb +14 -0
  25. data/lib/eve_online/sde/inv_items.rb +14 -0
  26. data/lib/eve_online/sde/inv_names.rb +14 -0
  27. data/lib/eve_online/sde/inv_positions.rb +14 -0
  28. data/lib/eve_online/sde/models/agt_agent.rb +58 -0
  29. data/lib/eve_online/sde/models/agt_agent_type.rb +28 -0
  30. data/lib/eve_online/sde/models/agt_research_agent.rb +28 -0
  31. data/lib/eve_online/sde/models/chr_race.rb +38 -0
  32. data/lib/eve_online/sde/models/inv_flag.rb +38 -0
  33. data/lib/eve_online/sde/models/inv_item.rb +48 -0
  34. data/lib/eve_online/sde/models/inv_name.rb +28 -0
  35. data/lib/eve_online/sde/models/inv_position.rb +53 -0
  36. data/lib/eve_online/version.rb +1 -1
  37. data/lib/eve_online/xml/models/skill_queue_entry.rb +55 -0
  38. metadata +31 -6
  39. data/lib/eve_online/esi/characters/character.rb +0 -20
  40. data/lib/eve_online/skill_queue_entry.rb +0 -51
@@ -18,11 +18,11 @@ module EveOnline
18
18
  def skills
19
19
  case row
20
20
  when Hash
21
- [SkillQueueEntry.new(row)]
21
+ [EveOnline::XML::Models::SkillQueueEntry.new(row)]
22
22
  when Array
23
23
  output = []
24
- row.each do |blueprint|
25
- output << SkillQueueEntry.new(blueprint)
24
+ row.each do |skill|
25
+ output << EveOnline::XML::Models::SkillQueueEntry.new(skill)
26
26
  end
27
27
  output
28
28
  else
@@ -1,13 +1,15 @@
1
1
  require 'memoist'
2
+ require 'active_support/time'
2
3
 
3
4
  module EveOnline
4
5
  module ESI
5
6
  class Base
6
7
  extend Memoist
7
8
 
8
- attr_reader :parser
9
+ attr_reader :token, :parser
9
10
 
10
- def initialize
11
+ def initialize(token = nil)
12
+ @token = token
11
13
  @parser = JSON
12
14
  end
13
15
 
@@ -15,6 +17,10 @@ module EveOnline
15
17
  raise NotImplementedError
16
18
  end
17
19
 
20
+ def scope
21
+ raise NotImplementedError
22
+ end
23
+
18
24
  def user_agent
19
25
  "EveOnline API (https://github.com/biow0lf/eve_online) v#{ VERSION }"
20
26
  end
@@ -23,6 +29,7 @@ module EveOnline
23
29
  faraday = Faraday.new
24
30
 
25
31
  faraday.headers[:user_agent] = user_agent
32
+ faraday.authorization(:Bearer, token) if token
26
33
  faraday.options.timeout = 60
27
34
  faraday.options.open_timeout = 60
28
35
 
@@ -36,6 +43,12 @@ module EveOnline
36
43
  parser.parse(content)
37
44
  end
38
45
  memoize :response
46
+
47
+ private
48
+
49
+ def parse_datetime_with_timezone(value)
50
+ ActiveSupport::TimeZone['UTC'].parse(value)
51
+ end
39
52
  end
40
53
  end
41
54
  end
@@ -0,0 +1,75 @@
1
+ module EveOnline
2
+ module ESI
3
+ class Character < Base
4
+ API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/?datasource=tranquility'.freeze
5
+
6
+ attr_reader :character_id
7
+
8
+ def initialize(character_id)
9
+ super()
10
+ @character_id = character_id
11
+ end
12
+
13
+ def as_json
14
+ {
15
+ corporation_id: corporation_id,
16
+ birthday: birthday,
17
+ name: name,
18
+ gender: gender,
19
+ race_id: race_id,
20
+ bloodline_id: bloodline_id,
21
+ description: description,
22
+ alliance_id: alliance_id,
23
+ ancestry_id: ancestry_id,
24
+ security_status: security_status
25
+ }
26
+ end
27
+
28
+ def corporation_id
29
+ response.fetch('corporation_id')
30
+ end
31
+
32
+ def birthday
33
+ parse_datetime_with_timezone(response.fetch('birthday'))
34
+ end
35
+
36
+ def name
37
+ response.fetch('name')
38
+ end
39
+
40
+ def gender
41
+ response.fetch('gender')
42
+ end
43
+
44
+ def race_id
45
+ response.fetch('race_id')
46
+ end
47
+
48
+ def bloodline_id
49
+ response.fetch('bloodline_id')
50
+ end
51
+
52
+ def description
53
+ response.fetch('description')
54
+ end
55
+
56
+ def alliance_id
57
+ response.fetch('alliance_id')
58
+ end
59
+
60
+ def ancestry_id
61
+ response.fetch('ancestry_id')
62
+ end
63
+
64
+ def security_status
65
+ response.fetch('security_status')
66
+ end
67
+
68
+ def scope; end
69
+
70
+ def url
71
+ API_ENDPOINT % character_id
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,31 @@
1
+ module EveOnline
2
+ module ESI
3
+ class CharacterLoyaltyPoints < Base
4
+ API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/loyalty/points/?datasource=tranquility'.freeze
5
+
6
+ attr_reader :character_id
7
+
8
+ def initialize(token, character_id)
9
+ super(token)
10
+ @character_id = character_id
11
+ end
12
+
13
+ def loyalty_points
14
+ output = []
15
+ response.each do |lp|
16
+ output << Models::LoyaltyPoint.new(lp)
17
+ end
18
+ output
19
+ end
20
+ memoize :loyalty_points
21
+
22
+ def scope
23
+ 'esi-characters.read_loyalty.v1'
24
+ end
25
+
26
+ def url
27
+ API_ENDPOINT % character_id
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,61 @@
1
+ module EveOnline
2
+ module ESI
3
+ class CharacterPortrait < Base
4
+ API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/portrait/?datasource=tranquility'.freeze
5
+
6
+ attr_reader :character_id
7
+
8
+ def initialize(character_id)
9
+ super()
10
+ @character_id = character_id
11
+ end
12
+
13
+ # https://eveonline-third-party-documentation.readthedocs.io/en/latest/imageserver/intro.html#character-images
14
+ # Available Sizes: 32, 64, 128, 256, 512, 1024
15
+ # https://nethackwiki.com/wiki/Physical_size
16
+ # Tiny = 0; Small = 1; Medium = 2; Large = 3; Huge = 4; Gigantic = 7.
17
+ def as_json
18
+ {
19
+ small: small,
20
+ medium: medium,
21
+ large: large,
22
+ huge: huge
23
+ }
24
+ end
25
+
26
+ def tiny
27
+ # FIXME: https://github.com/ccpgames/esi-issues/issues/270
28
+ # FIXME: https://github.com/ccpgames/esi-issues/issues/131
29
+ raise NotImplementedError
30
+ end
31
+
32
+ def small
33
+ response.fetch('px64x64')
34
+ end
35
+
36
+ def medium
37
+ response.fetch('px128x128')
38
+ end
39
+
40
+ def large
41
+ response.fetch('px256x256')
42
+ end
43
+
44
+ def huge
45
+ response.fetch('px512x512')
46
+ end
47
+
48
+ def gigantic
49
+ # FIXME: https://github.com/ccpgames/esi-issues/issues/270
50
+ # FIXME: https://github.com/ccpgames/esi-issues/issues/131
51
+ raise NotImplementedError
52
+ end
53
+
54
+ def scope; end
55
+
56
+ def url
57
+ API_ENDPOINT % character_id
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,31 @@
1
+ module EveOnline
2
+ module ESI
3
+ class CharacterSkillQueue < Base
4
+ API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/skillqueue/?datasource=tranquility'.freeze
5
+
6
+ attr_reader :character_id
7
+
8
+ def initialize(token, character_id)
9
+ super(token)
10
+ @character_id = character_id
11
+ end
12
+
13
+ def skills
14
+ output = []
15
+ response.each do |skill|
16
+ output << EveOnline::ESI::Models::SkillQueueEntry.new(skill)
17
+ end
18
+ output
19
+ end
20
+ memoize :skills
21
+
22
+ def scope
23
+ 'esi-skills.read_skillqueue.v1'
24
+ end
25
+
26
+ def url
27
+ API_ENDPOINT % character_id
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ module EveOnline
2
+ module ESI
3
+ class CharacterSkills < Base
4
+ API_ENDPOINT = 'https://esi.tech.ccp.is/latest/characters/%s/skills/?datasource=tranquility'.freeze
5
+
6
+ attr_reader :character_id
7
+
8
+ def initialize(token, character_id)
9
+ super(token)
10
+ @character_id = character_id
11
+ end
12
+
13
+ def as_json
14
+ {
15
+ total_sp: total_sp
16
+ }
17
+ end
18
+
19
+ def total_sp
20
+ response.fetch('total_sp')
21
+ end
22
+
23
+ def skills
24
+ output = []
25
+ response.fetch('skills').each do |skill|
26
+ output << EveOnline::ESI::Models::Skill.new(skill)
27
+ end
28
+ output
29
+ end
30
+ memoize :skills
31
+
32
+ def scope
33
+ 'esi-skills.read_skills.v1'
34
+ end
35
+
36
+ def url
37
+ API_ENDPOINT % character_id
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,28 @@
1
+ module EveOnline
2
+ module ESI
3
+ module Models
4
+ class LoyaltyPoint
5
+ attr_reader :options
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def as_json
12
+ {
13
+ corporation_id: corporation_id,
14
+ loyalty_points: loyalty_points
15
+ }
16
+ end
17
+
18
+ def corporation_id
19
+ options.fetch('corporation_id')
20
+ end
21
+
22
+ def loyalty_points
23
+ options.fetch('loyalty_points')
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ module EveOnline
2
+ module ESI
3
+ module Models
4
+ class Skill
5
+ attr_reader :options
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def as_json
12
+ {
13
+ skill_id: skill_id,
14
+ skillpoints_in_skill: skillpoints_in_skill,
15
+ current_skill_level: current_skill_level
16
+ }
17
+ end
18
+
19
+ def skill_id
20
+ options.fetch('skill_id')
21
+ end
22
+
23
+ def skillpoints_in_skill
24
+ options.fetch('skillpoints_in_skill')
25
+ end
26
+
27
+ def current_skill_level
28
+ options.fetch('current_skill_level')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,60 @@
1
+ require 'active_support/time'
2
+
3
+ module EveOnline
4
+ module ESI
5
+ module Models
6
+ class SkillQueueEntry
7
+ attr_reader :options
8
+
9
+ def initialize(options)
10
+ @options = options
11
+ end
12
+
13
+ def as_json
14
+ {
15
+ skill_id: skill_id,
16
+ finished_level: finished_level,
17
+ queue_position: queue_position,
18
+ finish_date: finish_date,
19
+ start_date: start_date,
20
+ training_start_sp: training_start_sp,
21
+ level_end_sp: level_end_sp,
22
+ level_start_sp: level_start_sp
23
+ }
24
+ end
25
+
26
+ def skill_id
27
+ options.fetch('skill_id')
28
+ end
29
+
30
+ def finished_level
31
+ options.fetch('finished_level')
32
+ end
33
+
34
+ def queue_position
35
+ options.fetch('queue_position')
36
+ end
37
+
38
+ def finish_date
39
+ ActiveSupport::TimeZone['UTC'].parse(options.fetch('finish_date'))
40
+ end
41
+
42
+ def start_date
43
+ ActiveSupport::TimeZone['UTC'].parse(options.fetch('start_date'))
44
+ end
45
+
46
+ def training_start_sp
47
+ options.fetch('training_start_sp')
48
+ end
49
+
50
+ def level_end_sp
51
+ options.fetch('level_end_sp')
52
+ end
53
+
54
+ def level_start_sp
55
+ options.fetch('level_start_sp')
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ module EveOnline
2
+ module SDE
3
+ class AgtAgentTypes < Base
4
+ def agt_agent_types
5
+ output = []
6
+ data.each do |agt_agent_type|
7
+ output << EveOnline::SDE::Models::AgtAgentType.new(agt_agent_type)
8
+ end
9
+ output
10
+ end
11
+ memoize :agt_agent_types
12
+ end
13
+ end
14
+ end