eve_online 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +27 -10
  4. data/Gemfile +1 -1
  5. data/LICENSE.txt +1 -1
  6. data/README.md +297 -121
  7. data/gemfiles/activesupport_51.gemfile +5 -0
  8. data/gemfiles/activesupport_edge.gemfile +5 -0
  9. data/lib/eve_online.rb +52 -45
  10. data/lib/eve_online/esi/character.rb +13 -11
  11. data/lib/eve_online/esi/character_loyalty_points.rb +1 -1
  12. data/lib/eve_online/esi/character_portrait.rb +5 -5
  13. data/lib/eve_online/esi/models/loyalty_point.rb +2 -2
  14. data/lib/eve_online/esi/models/skill.rb +3 -3
  15. data/lib/eve_online/esi/server_status.rb +40 -0
  16. data/lib/eve_online/exceptions/{exception.rb → base.rb} +1 -1
  17. data/lib/eve_online/exceptions/invalid_character_id_exception.rb +6 -0
  18. data/lib/eve_online/exceptions/timeout_exception.rb +1 -1
  19. data/lib/eve_online/exceptions/unauthorized_exception.rb +6 -0
  20. data/lib/eve_online/version.rb +1 -1
  21. data/lib/eve_online/{account/characters.rb → xml/account_characters.rb} +2 -2
  22. data/lib/eve_online/xml/account_status.rb +31 -0
  23. data/lib/eve_online/{account → xml}/api_key_info.rb +11 -22
  24. data/lib/eve_online/xml/base.rb +84 -0
  25. data/lib/eve_online/{characters/account_balance.rb → xml/character_account_balance.rb} +2 -2
  26. data/lib/eve_online/{characters/asset_list.rb → xml/character_asset_list.rb} +2 -2
  27. data/lib/eve_online/{characters/blueprints.rb → xml/character_blueprints.rb} +2 -2
  28. data/lib/eve_online/{characters/bookmarks.rb → xml/character_bookmarks.rb} +2 -2
  29. data/lib/eve_online/{characters/calendar_event_attendees.rb → xml/character_calendar_event_attendees.rb} +2 -2
  30. data/lib/eve_online/{characters/chat_channels.rb → xml/character_chat_channels.rb} +2 -2
  31. data/lib/eve_online/{characters/contact_list.rb → xml/character_contact_list.rb} +2 -2
  32. data/lib/eve_online/{characters/contact_notifications.rb → xml/character_contact_notifications.rb} +2 -2
  33. data/lib/eve_online/{characters/contract_bids.rb → xml/character_contract_bids.rb} +2 -2
  34. data/lib/eve_online/{characters/contract_items.rb → xml/character_contract_items.rb} +2 -2
  35. data/lib/eve_online/{characters/contracts.rb → xml/character_contracts.rb} +2 -2
  36. data/lib/eve_online/{characters/fac_war_stats.rb → xml/character_fac_war_stats.rb} +2 -2
  37. data/lib/eve_online/{characters/industry_jobs.rb → xml/character_industry_jobs.rb} +2 -2
  38. data/lib/eve_online/{characters/industry_jobs_history.rb → xml/character_industry_jobs_history.rb} +2 -2
  39. data/lib/eve_online/{characters/kill_mails.rb → xml/character_kill_mails.rb} +2 -2
  40. data/lib/eve_online/{characters/locations.rb → xml/character_locations.rb} +2 -2
  41. data/lib/eve_online/{characters/mail_bodies.rb → xml/character_mail_bodies.rb} +2 -2
  42. data/lib/eve_online/{characters/mail_messages.rb → xml/character_mail_messages.rb} +2 -2
  43. data/lib/eve_online/{characters/mailing_lists.rb → xml/character_mailing_lists.rb} +2 -2
  44. data/lib/eve_online/{characters/market_orders.rb → xml/character_market_orders.rb} +2 -2
  45. data/lib/eve_online/{characters/medals.rb → xml/character_medals.rb} +2 -2
  46. data/lib/eve_online/{characters/notification_texts.rb → xml/character_notification_texts.rb} +2 -2
  47. data/lib/eve_online/{characters/notifications.rb → xml/character_notifications.rb} +2 -2
  48. data/lib/eve_online/{characters/planetary_colonies.rb → xml/character_planetary_colonies.rb} +2 -2
  49. data/lib/eve_online/{characters/planetary_links.rb → xml/character_planetary_links.rb} +2 -2
  50. data/lib/eve_online/{characters/planetary_pins.rb → xml/character_planetary_pins.rb} +2 -2
  51. data/lib/eve_online/{characters/planetary_routes.rb → xml/character_planetary_routes.rb} +2 -2
  52. data/lib/eve_online/{characters/research.rb → xml/character_research.rb} +2 -2
  53. data/lib/eve_online/{characters → xml}/character_sheet.rb +16 -7
  54. data/lib/eve_online/{characters/skill_in_training.rb → xml/character_skill_in_training.rb} +2 -2
  55. data/lib/eve_online/{characters/skill_queue.rb → xml/character_skill_queue.rb} +2 -2
  56. data/lib/eve_online/{characters/standings.rb → xml/character_standings.rb} +2 -2
  57. data/lib/eve_online/{characters/upcoming_calendar_events.rb → xml/character_upcoming_calendar_events.rb} +2 -2
  58. data/lib/eve_online/{characters/wallet_journal.rb → xml/character_wallet_journal.rb} +2 -2
  59. data/lib/eve_online/{characters/wallet_transactions.rb → xml/character_wallet_transactions.rb} +2 -2
  60. data/lib/eve_online/{corporations/market_orders.rb → xml/corporation_market_orders.rb} +2 -2
  61. data/lib/eve_online/xml/models/account_status.rb +40 -0
  62. data/lib/eve_online/xml/models/account_type_object.rb +22 -0
  63. data/lib/eve_online/xml/models/api_key_info.rb +35 -0
  64. data/lib/eve_online/{server/status.rb → xml/server_status.rb} +2 -2
  65. metadata +53 -45
  66. data/lib/eve_online/account/status.rb +0 -47
  67. data/lib/eve_online/account_type_object.rb +0 -18
@@ -0,0 +1,84 @@
1
+ require 'nori'
2
+ require 'memoist'
3
+ require 'faraday'
4
+ require 'active_support/time'
5
+
6
+ module EveOnline
7
+ module XML
8
+ class Base
9
+ extend Memoist
10
+
11
+ attr_reader :parser
12
+
13
+ def initialize
14
+ @parser = Nori.new(advanced_typecasting: false)
15
+ end
16
+
17
+ def url
18
+ raise NotImplementedError
19
+ end
20
+
21
+ def user_agent
22
+ "EveOnline API (https://github.com/biow0lf/eve_online) v#{ VERSION }"
23
+ end
24
+
25
+ def content
26
+ faraday = Faraday.new
27
+
28
+ faraday.headers[:user_agent] = user_agent
29
+ faraday.options.timeout = 60
30
+ faraday.options.open_timeout = 60
31
+
32
+ resource = faraday.get(url)
33
+
34
+ case resource.status
35
+ when 200
36
+ resource.body
37
+ when 400
38
+ raise EveOnline::Exceptions::InvalidCharacterIDException
39
+ when 403
40
+ raise EveOnline::Exceptions::UnauthorizedException
41
+ end
42
+ rescue Faraday::TimeoutError
43
+ raise EveOnline::Exceptions::TimeoutException
44
+ end
45
+ memoize :content
46
+
47
+ def response
48
+ parser.parse(content)
49
+ end
50
+ memoize :response
51
+
52
+ def eveapi
53
+ response.fetch('eveapi')
54
+ end
55
+ memoize :eveapi
56
+
57
+ def result
58
+ eveapi.fetch('result')
59
+ end
60
+ memoize :result
61
+
62
+ def cached_until
63
+ parse_datetime_with_timezone(eveapi.fetch('cachedUntil'))
64
+ end
65
+ memoize :cached_until
66
+
67
+ def current_time
68
+ parse_datetime_with_timezone(eveapi.fetch('currentTime'))
69
+ end
70
+ memoize :current_time
71
+
72
+ def version
73
+ eveapi.fetch('@version').to_i
74
+ end
75
+ memoize :version
76
+
77
+ private
78
+
79
+ def parse_datetime_with_timezone(value)
80
+ ActiveSupport::TimeZone['UTC'].parse(value)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_accountbalance.html
4
- class AccountBalance < BaseXML
4
+ class CharacterAccountBalance < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/AccountBalance.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 1
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_assetlist.html
4
- class AssetList < BaseXML
4
+ class CharacterAssetList < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/AssetList.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_blueprints.html
4
- class Blueprints < BaseXML
4
+ class CharacterBlueprints < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Blueprints.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_bookmarks.html
4
- class Bookmarks < BaseXML
4
+ class CharacterBookmarks < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Bookmarks.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 268_435_456
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_calendareventattendees.html
4
- class CalendarEventAttendees < BaseXML
4
+ class CharacterCalendarEventAttendees < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/CalendarEventAttendees.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 4
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_chatchannels.html
4
- class ChatChannels < BaseXML
4
+ class CharacterChatChannels < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/ChatChannels.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 536_870_912
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_contactlist.html
4
- class ContactList < BaseXML
4
+ class CharacterContactList < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/ContactList.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 16
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_contactnotifications.html
4
- class ContactNotifications < BaseXML
4
+ class CharacterContactNotifications < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/ContactNotifications.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 32
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_contractbids.html
4
- class ContractBids < BaseXML
4
+ class CharacterContractBids < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/ContractBids.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 67_108_864
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_contractitems.html
4
- class ContractItems < BaseXML
4
+ class CharacterContractItems < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/ContractItems.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 67_108_864
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_contracts.html
4
- class Contracts < BaseXML
4
+ class CharacterContracts < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Contracts.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 67_108_864
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_facwarstats.html
4
- class FacWarStats < BaseXML
4
+ class CharacterFacWarStats < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/FacWarStats.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 64
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_industryjobs.html
4
- class IndustryJobs < BaseXML
4
+ class CharacterIndustryJobs < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/IndustryJobs.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 128
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_industryjobshistory.html
4
- class IndustryJobsHistory < BaseXML
4
+ class CharacterIndustryJobsHistory < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/IndustryJobsHistory.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 128
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_killmails.html
4
- class KillMails < BaseXML
4
+ class CharacterKillMails < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/KillMails.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 256
@@ -1,9 +1,9 @@
1
1
  require 'uri'
2
2
 
3
3
  module EveOnline
4
- module Characters
4
+ module XML
5
5
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_locations.html
6
- class Locations < BaseXML
6
+ class CharacterLocations < Base
7
7
  API_ENDPOINT = 'https://api.eveonline.com/char/Locations.xml.aspx'.freeze
8
8
 
9
9
  ACCESS_MASK = 134_217_728
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_mailbodies.html
4
- class MailBodies < BaseXML
4
+ class CharacterMailBodies < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/MailBodies.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 512
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_mailmessages.html
4
- class MailMessages < BaseXML
4
+ class CharacterMailMessages < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/MailMessages.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2_048
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_mailinglists.html
4
- class MailingLists < BaseXML
4
+ class CharacterMailingLists < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/mailinglists.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 1_024
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_marketorders.html
4
- class MarketOrders < BaseXML
4
+ class CharacterMarketOrders < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/MarketOrders.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 4_096
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_medals.html
4
- class Medals < BaseXML
4
+ class CharacterMedals < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Medals.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 8_192
@@ -1,9 +1,9 @@
1
1
  require 'uri'
2
2
 
3
3
  module EveOnline
4
- module Characters
4
+ module XML
5
5
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_notificationtexts.html
6
- class NotificationTexts < BaseXML
6
+ class CharacterNotificationTexts < Base
7
7
  API_ENDPOINT = 'https://api.eveonline.com/char/NotificationTexts.xml.aspx'.freeze
8
8
 
9
9
  ACCESS_MASK = 32_768
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_notifications.html
4
- class Notifications < BaseXML
4
+ class CharacterNotifications < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Notifications.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 16_384
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_planetarycolonies.html
4
- class PlanetaryColonies < BaseXML
4
+ class CharacterPlanetaryColonies < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/PlanetaryColonies.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_planetarylinks.html
4
- class PlanetaryLinks < BaseXML
4
+ class CharacterPlanetaryLinks < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/PlanetaryLinks.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_planetarypins.html
4
- class PlanetaryPins < BaseXML
4
+ class CharacterPlanetaryPins < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/PlanetaryPins.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_planetaryroutes.html
4
- class PlanetaryRoutes < BaseXML
4
+ class CharacterPlanetaryRoutes < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/PlanetaryRoutes.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 2
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_research.html
4
- class Research < BaseXML
4
+ class CharacterResearch < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/Research.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 65_536
@@ -1,7 +1,7 @@
1
1
  module EveOnline
2
- module Characters
2
+ module XML
3
3
  # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_charactersheet.html
4
- class CharacterSheet < BaseXML
4
+ class CharacterSheet < Base
5
5
  API_ENDPOINT = 'https://api.eveonline.com/char/CharacterSheet.xml.aspx'.freeze
6
6
 
7
7
  ACCESS_MASK = 8
@@ -149,39 +149,48 @@ module EveOnline
149
149
  parse_datetime_with_timezone(result.fetch('remoteStationDate'))
150
150
  end
151
151
 
152
+ # TODO: add to as_json output
152
153
  def jump_activation
153
154
  parse_datetime_with_timezone(result.fetch('jumpActivation'))
154
155
  end
155
156
 
157
+ # TODO: add to as_json output
156
158
  def jump_fatigue
157
159
  parse_datetime_with_timezone(result.fetch('jumpFatigue'))
158
160
  end
159
161
 
162
+ # TODO: add to as_json output
160
163
  def jump_last_update
161
164
  parse_datetime_with_timezone(result.fetch('jumpLastUpdate'))
162
165
  end
163
166
 
167
+ # TODO: add to as_json output
164
168
  def balance
165
169
  result.fetch('balance').to_f
166
170
  end
167
171
 
168
- def base_intelligence
172
+ # TODO: add to as_json output
173
+ def intelligence
169
174
  attributes.fetch('intelligence').to_i
170
175
  end
171
176
 
172
- def base_memory
177
+ # TODO: add to as_json output
178
+ def memory
173
179
  attributes.fetch('memory').to_i
174
180
  end
175
181
 
176
- def base_charisma
182
+ # TODO: add to as_json output
183
+ def charisma
177
184
  attributes.fetch('charisma').to_i
178
185
  end
179
186
 
180
- def base_perception
187
+ # TODO: add to as_json output
188
+ def perception
181
189
  attributes.fetch('perception').to_i
182
190
  end
183
191
 
184
- def base_willpower
192
+ # TODO: add to as_json output
193
+ def willpower
185
194
  attributes.fetch('willpower').to_i
186
195
  end
187
196