greeve 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +139 -0
  3. data/doc/Greeve.html +5 -5
  4. data/doc/Greeve/API.html +15 -3
  5. data/doc/Greeve/API/CallList.html +466 -0
  6. data/doc/Greeve/Account.html +130 -0
  7. data/doc/Greeve/Account/APIKeyInfo.html +599 -0
  8. data/doc/Greeve/Account/AccountStatus.html +579 -0
  9. data/doc/Greeve/Account/Characters.html +389 -0
  10. data/doc/Greeve/Application.html +428 -0
  11. data/doc/Greeve/Attributable.html +123 -0
  12. data/doc/Greeve/BaseItem.html +240 -210
  13. data/doc/Greeve/Character.html +15 -3
  14. data/doc/Greeve/Character/AccountBalance.html +420 -0
  15. data/doc/Greeve/Character/AssetList.html +480 -0
  16. data/doc/Greeve/Character/Blueprints.html +535 -0
  17. data/doc/Greeve/Character/CalendarEventAttendees.html +461 -0
  18. data/doc/Greeve/Character/CharacterSheet.html +3407 -0
  19. data/doc/Greeve/Character/Clones.html +1700 -0
  20. data/doc/Greeve/Character/ContactList.html +1047 -0
  21. data/doc/Greeve/Character/ContactNotifications.html +446 -0
  22. data/doc/Greeve/Character/ContractBids.html +446 -0
  23. data/doc/Greeve/Character/ContractItems.html +483 -0
  24. data/doc/Greeve/Character/Contracts.html +720 -0
  25. data/doc/Greeve/Character/FacWarStats.html +1075 -0
  26. data/doc/Greeve/Character/IndustryJobs.html +732 -0
  27. data/doc/Greeve/Character/IndustryJobsHistory.html +732 -0
  28. data/doc/Greeve/Character/Locations.html +503 -0
  29. data/doc/Greeve/Character/MailBodies.html +435 -0
  30. data/doc/Greeve/Character/MailMessages.html +485 -0
  31. data/doc/Greeve/Character/MailingLists.html +407 -0
  32. data/doc/Greeve/Character/MarketOrders.html +626 -0
  33. data/doc/Greeve/Character/Medals.html +665 -0
  34. data/doc/Greeve/Character/Notifications.html +459 -0
  35. data/doc/Greeve/Character/PlanetaryColonies.html +524 -0
  36. data/doc/Greeve/Character/PlanetaryLinks.html +444 -0
  37. data/doc/Greeve/Character/PlanetaryPins.html +587 -0
  38. data/doc/Greeve/Character/PlanetaryRoutes.html +548 -0
  39. data/doc/Greeve/Character/Research.html +446 -0
  40. data/doc/Greeve/Character/SkillInTraining.html +865 -0
  41. data/doc/Greeve/Character/SkillQueue.html +472 -0
  42. data/doc/Greeve/Character/Skills.html +516 -0
  43. data/doc/Greeve/Character/Standings.html +650 -0
  44. data/doc/Greeve/Character/UpcomingCalendarEvents.html +511 -0
  45. data/doc/Greeve/Character/WalletJournal.html +658 -0
  46. data/doc/Greeve/Character/WalletTransactions.html +631 -0
  47. data/doc/Greeve/Config.html +315 -0
  48. data/doc/Greeve/Corporation.html +15 -3
  49. data/doc/Greeve/Corporation/AccountBalance.html +324 -0
  50. data/doc/Greeve/Corporation/Contracts.html +700 -0
  51. data/doc/Greeve/Corporation/CorporationSheet.html +1285 -0
  52. data/doc/Greeve/Corporation/IndustryJobs.html +636 -0
  53. data/doc/Greeve/Corporation/IndustryJobsHistory.html +636 -0
  54. data/doc/Greeve/Corporation/Locations.html +452 -0
  55. data/doc/Greeve/Corporation/MarketOrders.html +609 -0
  56. data/doc/Greeve/Corporation/MemberTracking.html +596 -0
  57. data/doc/Greeve/Corporation/Standings.html +554 -0
  58. data/doc/Greeve/Corporation/StarbaseDetail.html +619 -0
  59. data/doc/Greeve/Corporation/StarbaseList.html +389 -0
  60. data/doc/Greeve/Corporation/WalletJournal.html +631 -0
  61. data/doc/Greeve/Corporation/WalletTransactions.html +657 -0
  62. data/doc/Greeve/Eve.html +3 -3
  63. data/doc/Greeve/Eve/AllianceList.html +476 -0
  64. data/doc/Greeve/Eve/CharacterAffiliation.html +491 -0
  65. data/doc/Greeve/Eve/CharacterID.html +413 -0
  66. data/doc/Greeve/Eve/CharacterInfo.html +1705 -52
  67. data/doc/Greeve/Eve/CharacterName.html +414 -0
  68. data/doc/Greeve/Eve/ConquerableStationList.html +402 -0
  69. data/doc/Greeve/Eve/ErrorList.html +311 -0
  70. data/doc/Greeve/Eve/RefTypes.html +312 -0
  71. data/doc/Greeve/Eve/TypeName.html +413 -0
  72. data/doc/Greeve/Helpers.html +130 -0
  73. data/doc/Greeve/Helpers/AddAttribute.html +124 -0
  74. data/doc/Greeve/Helpers/AttributeToHash.html +245 -0
  75. data/doc/Greeve/Helpers/DefineAttributeMethod.html +124 -0
  76. data/doc/Greeve/Helpers/DefineDSLMethods.html +124 -0
  77. data/doc/Greeve/Map.html +15 -3
  78. data/doc/Greeve/Map/FacWarSystems.html +404 -0
  79. data/doc/Greeve/Map/Jumps.html +313 -0
  80. data/doc/Greeve/Map/Kills.html +339 -0
  81. data/doc/Greeve/Map/Sovereignty.html +351 -0
  82. data/doc/Greeve/Namespace.html +586 -0
  83. data/doc/Greeve/ResponseError.html +521 -0
  84. data/doc/Greeve/Row.html +40 -161
  85. data/doc/Greeve/Rowset.html +28 -22
  86. data/doc/Greeve/Server.html +15 -3
  87. data/doc/Greeve/Server/ServerStatus.html +349 -0
  88. data/doc/_index.html +600 -4
  89. data/doc/class_list.html +1 -1
  90. data/doc/file.CONTRIBUTING.html +1 -1
  91. data/doc/file.LICENSE.html +1 -1
  92. data/doc/file.README.html +140 -1
  93. data/doc/index.html +140 -1
  94. data/doc/method_list.html +2024 -32
  95. data/doc/top-level-namespace.html +1 -1
  96. data/lib/greeve.rb +75 -0
  97. data/lib/greeve/account/account_status.rb +22 -0
  98. data/lib/greeve/account/api_key_info.rb +27 -0
  99. data/lib/greeve/account/characters.rb +23 -0
  100. data/lib/greeve/api/call_list.rb +27 -0
  101. data/lib/greeve/base_item.rb +41 -57
  102. data/lib/greeve/character/account_balance.rb +24 -0
  103. data/lib/greeve/character/asset_list.rb +32 -0
  104. data/lib/greeve/character/blueprints.rb +35 -0
  105. data/lib/greeve/character/calendar_event_attendees.rb +33 -0
  106. data/lib/greeve/character/character_sheet.rb +110 -0
  107. data/lib/greeve/character/clones.rb +60 -0
  108. data/lib/greeve/character/contact_list.rb +58 -0
  109. data/lib/greeve/character/contact_notifications.rb +26 -0
  110. data/lib/greeve/character/contract_bids.rb +26 -0
  111. data/lib/greeve/character/contract_items.rb +32 -0
  112. data/lib/greeve/character/contracts.rb +49 -0
  113. data/lib/greeve/character/fac_war_stats.rb +30 -0
  114. data/lib/greeve/character/industry_jobs.rb +48 -0
  115. data/lib/greeve/character/industry_jobs_history.rb +48 -0
  116. data/lib/greeve/character/locations.rb +36 -0
  117. data/lib/greeve/character/mail_bodies.rb +33 -0
  118. data/lib/greeve/character/mail_messages.rb +29 -0
  119. data/lib/greeve/character/mailing_lists.rb +23 -0
  120. data/lib/greeve/character/market_orders.rb +42 -0
  121. data/lib/greeve/character/medals.rb +40 -0
  122. data/lib/greeve/character/notifications.rb +27 -0
  123. data/lib/greeve/character/planetary_colonies.rb +32 -0
  124. data/lib/greeve/character/planetary_links.rb +30 -0
  125. data/lib/greeve/character/planetary_pins.rb +41 -0
  126. data/lib/greeve/character/planetary_routes.rb +38 -0
  127. data/lib/greeve/character/research.rb +26 -0
  128. data/lib/greeve/character/skill_in_training.rb +27 -0
  129. data/lib/greeve/character/skill_queue.rb +28 -0
  130. data/lib/greeve/character/skills.rb +28 -0
  131. data/lib/greeve/character/standings.rb +36 -0
  132. data/lib/greeve/character/upcoming_calendar_events.rb +31 -0
  133. data/lib/greeve/character/wallet_journal.rb +49 -0
  134. data/lib/greeve/character/wallet_transactions.rb +47 -0
  135. data/lib/greeve/config.rb +16 -0
  136. data/lib/greeve/corporation/account_balance.rb +18 -0
  137. data/lib/greeve/corporation/contracts.rb +46 -0
  138. data/lib/greeve/corporation/corporation_sheet.rb +43 -0
  139. data/lib/greeve/corporation/industry_jobs.rb +42 -0
  140. data/lib/greeve/corporation/industry_jobs_history.rb +42 -0
  141. data/lib/greeve/corporation/locations.rb +31 -0
  142. data/lib/greeve/corporation/market_orders.rb +39 -0
  143. data/lib/greeve/corporation/member_tracking.rb +38 -0
  144. data/lib/greeve/corporation/standings.rb +30 -0
  145. data/lib/greeve/corporation/starbase_detail.rb +58 -0
  146. data/lib/greeve/corporation/starbase_list.rb +23 -0
  147. data/lib/greeve/corporation/wallet_journal.rb +48 -0
  148. data/lib/greeve/corporation/wallet_transactions.rb +50 -0
  149. data/lib/greeve/eve/alliance_list.rb +29 -0
  150. data/lib/greeve/eve/character_affiliation.rb +34 -0
  151. data/lib/greeve/eve/character_id.rb +28 -0
  152. data/lib/greeve/eve/character_info.rb +4 -1
  153. data/lib/greeve/eve/character_name.rb +29 -0
  154. data/lib/greeve/eve/conquerable_station_list.rb +24 -0
  155. data/lib/greeve/eve/error_list.rb +17 -0
  156. data/lib/greeve/eve/ref_types.rb +18 -0
  157. data/lib/greeve/eve/type_name.rb +28 -0
  158. data/lib/greeve/helpers/add_attribute.rb +25 -0
  159. data/lib/greeve/helpers/attribute_to_hash.rb +24 -0
  160. data/lib/greeve/helpers/define_dsl_methods.rb +70 -0
  161. data/lib/greeve/map/fac_war_systems.rb +26 -0
  162. data/lib/greeve/map/jumps.rb +19 -0
  163. data/lib/greeve/map/kills.rb +21 -0
  164. data/lib/greeve/map/sovereignty.rb +21 -0
  165. data/lib/greeve/namespace.rb +74 -0
  166. data/lib/greeve/response_error.rb +21 -0
  167. data/lib/greeve/row.rb +11 -33
  168. data/lib/greeve/rowset.rb +6 -15
  169. data/lib/greeve/server/server_status.rb +15 -0
  170. data/lib/greeve/version.rb +1 -1
  171. metadata +165 -2
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Wed Aug 24 18:52:46 2016 by
105
+ Generated on Mon Dec 26 15:56:22 2016 by
106
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.5 (ruby-2.1.7).
108
108
  </div>
@@ -3,17 +3,89 @@ require "ox"
3
3
  require "typhoeus"
4
4
 
5
5
  require_relative "greeve/version"
6
+ require_relative "greeve/config"
6
7
 
8
+ require_relative "greeve/helpers/add_attribute"
9
+ require_relative "greeve/helpers/attribute_to_hash"
10
+ require_relative "greeve/helpers/define_dsl_methods"
11
+
12
+ require_relative "greeve/response_error"
7
13
  require_relative "greeve/base_item"
14
+ require_relative "greeve/namespace"
8
15
  require_relative "greeve/row"
9
16
  require_relative "greeve/rowset"
17
+ require_relative "greeve/account/account_status"
18
+ require_relative "greeve/account/api_key_info"
19
+ require_relative "greeve/account/characters"
20
+ require_relative "greeve/api/call_list"
21
+ require_relative "greeve/character/account_balance"
22
+ require_relative "greeve/character/asset_list"
23
+ require_relative "greeve/character/blueprints"
24
+ require_relative "greeve/character/calendar_event_attendees"
25
+ require_relative "greeve/character/character_sheet"
26
+ require_relative "greeve/character/clones"
27
+ require_relative "greeve/character/contact_list"
28
+ require_relative "greeve/character/contact_notifications"
29
+ require_relative "greeve/character/contract_bids"
30
+ require_relative "greeve/character/contract_items"
31
+ require_relative "greeve/character/contracts"
32
+ require_relative "greeve/character/fac_war_stats"
33
+ require_relative "greeve/character/industry_jobs"
34
+ require_relative "greeve/character/industry_jobs_history"
35
+ require_relative "greeve/character/locations"
36
+ require_relative "greeve/character/mail_bodies"
37
+ require_relative "greeve/character/mail_messages"
38
+ require_relative "greeve/character/mailing_lists"
39
+ require_relative "greeve/character/market_orders"
40
+ require_relative "greeve/character/medals"
41
+ require_relative "greeve/character/notifications"
42
+ require_relative "greeve/character/planetary_colonies"
43
+ require_relative "greeve/character/planetary_links"
44
+ require_relative "greeve/character/planetary_pins"
45
+ require_relative "greeve/character/planetary_routes"
46
+ require_relative "greeve/character/research"
47
+ require_relative "greeve/character/skill_in_training"
48
+ require_relative "greeve/character/skill_queue"
49
+ require_relative "greeve/character/skills"
50
+ require_relative "greeve/character/standings"
51
+ require_relative "greeve/character/upcoming_calendar_events"
52
+ require_relative "greeve/character/wallet_journal"
53
+ require_relative "greeve/character/wallet_transactions"
54
+ require_relative "greeve/corporation/account_balance"
55
+ require_relative "greeve/corporation/contracts"
56
+ require_relative "greeve/corporation/corporation_sheet"
57
+ require_relative "greeve/corporation/industry_jobs"
58
+ require_relative "greeve/corporation/industry_jobs_history"
59
+ require_relative "greeve/corporation/locations"
60
+ require_relative "greeve/corporation/market_orders"
61
+ require_relative "greeve/corporation/member_tracking"
62
+ require_relative "greeve/corporation/standings"
63
+ require_relative "greeve/corporation/starbase_detail"
64
+ require_relative "greeve/corporation/starbase_list"
65
+ require_relative "greeve/corporation/wallet_journal"
66
+ require_relative "greeve/corporation/wallet_transactions"
67
+ require_relative "greeve/eve/alliance_list"
68
+ require_relative "greeve/eve/character_affiliation"
69
+ require_relative "greeve/eve/character_id"
10
70
  require_relative "greeve/eve/character_info"
71
+ require_relative "greeve/eve/character_name"
72
+ require_relative "greeve/eve/conquerable_station_list"
73
+ require_relative "greeve/eve/error_list"
74
+ require_relative "greeve/eve/ref_types"
75
+ require_relative "greeve/eve/type_name"
76
+ require_relative "greeve/map/fac_war_systems"
77
+ require_relative "greeve/map/jumps"
78
+ require_relative "greeve/map/kills"
79
+ require_relative "greeve/map/sovereignty"
80
+ require_relative "greeve/server/server_status"
11
81
 
12
82
  # A Ruby wrapper for the EVE Online XML API.
13
83
  module Greeve
14
84
  # Base URL of the EVE XML API.
15
85
  EVE_API_BASE_URL = "https://api.eveonline.com".freeze
16
86
 
87
+ # Account resources.
88
+ module Account; end
17
89
  # API resources.
18
90
  module API; end
19
91
  # Character resources.
@@ -26,4 +98,7 @@ module Greeve
26
98
  module Map; end
27
99
  # Server resources.
28
100
  module Server; end
101
+
102
+ # A namespace containing helper modules.
103
+ module Helpers; end
29
104
  end
@@ -0,0 +1,22 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Account
5
+ # Information about a player’s EVE account like creation time, minutes spent
6
+ # in game etc.
7
+ #
8
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/account/account_accountstatus.html
9
+ class AccountStatus < Greeve::BaseItem
10
+ endpoint "account/AccountStatus"
11
+
12
+ attribute :paid_until, xpath: "eveapi/result/paidUntil/?[0]", type: :datetime
13
+ attribute :create_date, xpath: "eveapi/result/createDate/?[0]", type: :datetime
14
+ attribute :logon_count, xpath: "eveapi/result/logonCount/?[0]", type: :integer
15
+ attribute :logon_minutes, xpath: "eveapi/result/logonMinutes/?[0]", type: :integer
16
+
17
+ rowset :multi_character_training, xpath: "eveapi/result/rowset[@name='multiCharacterTraining']" do
18
+ attribute :training_end, xpath: "@trainingEnd", type: :datetime
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Account
5
+ # Represents the access rights of an API key.
6
+ #
7
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/account/account_apikeyinfo.html
8
+ class APIKeyInfo < Greeve::BaseItem
9
+ endpoint "account/APIKeyInfo"
10
+
11
+ attribute :access_mask, xpath: "eveapi/result/key/@accessMask", type: :integer
12
+ attribute :type, xpath: "eveapi/result/key/@type", type: :string
13
+ attribute :expires, xpath: "eveapi/result/key/@expires", type: :datetime
14
+
15
+ rowset :characters, xpath: "eveapi/result/key/rowset[@name='characters']" do
16
+ attribute :character_id, xpath: "@characterID", type: :integer
17
+ attribute :character_name, xpath: "@characterName", type: :string
18
+ attribute :corporation_id, xpath: "@corporationID", type: :integer
19
+ attribute :corporation_name, xpath: "@corporationName", type: :string
20
+ attribute :alliance_id, xpath: "@allianceID", type: :integer
21
+ attribute :alliance_name, xpath: "@allianceName", type: :string
22
+ attribute :faction_id, xpath: "@factionID", type: :integer
23
+ attribute :faction_name, xpath: "@factionName", type: :string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Account
5
+ # Lists all characters for an API key.
6
+ #
7
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/account/account_characters.html
8
+ class Characters < Greeve::BaseItem
9
+ endpoint "account/Characters"
10
+
11
+ rowset :characters, xpath: "eveapi/result/rowset[@name='characters']" do
12
+ attribute :name, xpath: "@name", type: :string
13
+ attribute :character_id, xpath: "@characterID", type: :integer
14
+ attribute :corporation_name, xpath: "@corporationName", type: :string
15
+ attribute :corporation_id, xpath: "@corporationID", type: :integer
16
+ attribute :alliance_name, xpath: "@allianceName", type: :string
17
+ attribute :alliance_id, xpath: "@allianceID", type: :integer
18
+ attribute :faction_name, xpath: "@factionName", type: :string
19
+ attribute :faction_id, xpath: "@factionID", type: :integer
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module API
5
+ # List of all selectable API endpoints/groups to which an API grants
6
+ # access to.
7
+ #
8
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/api/api_calllist.html
9
+ class CallList < Greeve::BaseItem
10
+ endpoint "api/CallList"
11
+
12
+ rowset :call_groups, xpath: "eveapi/result/rowset[@name='callGroups']" do
13
+ attribute :group_id, xpath: "@groupID", type: :integer
14
+ attribute :name, xpath: "@name", type: :string
15
+ attribute :description, xpath: "@description", type: :string
16
+ end
17
+
18
+ rowset :calls, xpath: "eveapi/result/rowset[@name='calls']" do
19
+ attribute :access_mask, xpath: "@accessMask", type: :integer
20
+ attribute :type, xpath: "@type", type: :string
21
+ attribute :name, xpath: "@name", type: :string
22
+ attribute :group_id, xpath: "@groupID", type: :integer
23
+ attribute :description, xpath: "@description", type: :string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,11 @@
1
1
  require "bigdecimal"
2
2
  require "time"
3
3
 
4
+ require_relative "response_error"
5
+ require_relative "helpers/add_attribute"
6
+ require_relative "helpers/attribute_to_hash"
7
+ require_relative "helpers/define_dsl_methods"
8
+ require_relative "namespace"
4
9
  require_relative "rowset"
5
10
 
6
11
  module Greeve
@@ -8,6 +13,10 @@ module Greeve
8
13
  # objects. This class is designed to be subclassed by classes representing
9
14
  # the specific EVE API resources.
10
15
  class BaseItem
16
+ extend Greeve::Helpers::AddAttribute
17
+ extend Greeve::Helpers::DefineDSLMethods
18
+ include Greeve::Helpers::AttributeToHash
19
+
11
20
  # A DSL method to map an XML attribute to a Ruby object.
12
21
  #
13
22
  # @param name [Symbol] the Ruby name for this attribute
@@ -20,39 +29,30 @@ module Greeve
20
29
  # @example
21
30
  # attribute :character_id, xpath: "characterID/?[0]", type: :integer
22
31
  def self.attribute(name, opts = {})
23
- name = name.to_sym
24
32
  @attributes ||= {}
25
33
 
26
- raise "Attribute `#{name}` defined more than once" if @attributes[name]
27
- raise "`:xpath` not specified for `#{name}`" unless opts[:xpath]
34
+ add_attribute(name, opts)
35
+ define_attribute_method(:class, name, opts)
36
+ end
28
37
 
29
- @attributes[name] = {
30
- xpath: opts[:xpath],
31
- type: opts[:type],
32
- }
38
+ # A DSL method to nest a set of attributes within a namespace.
39
+ #
40
+ # @param name [Symbol] the Ruby name for this namespace
41
+ #
42
+ # @option opts [Symbol] :xpath the xpath string used to locate the namespace
43
+ # in the XML element
44
+ #
45
+ # @example
46
+ # namespace :general_settings, xpath: "eveapi/result/generalSettings" do
47
+ # attribute :usage_flags, xpath: "usageFlags/?[0]", type: :integer
48
+ # end
49
+ def self.namespace(name, opts = {}, &block)
50
+ @attributes ||= {}
33
51
 
34
- define_method(name) do
35
- ivar = instance_variable_get(:"@#{name}")
36
- return ivar unless ivar.nil?
52
+ opts[:type] = :namespace
37
53
 
38
- value = @xml_element.locate(opts[:xpath]).first
39
-
40
- unless value.nil?
41
- value =
42
- case opts[:type]
43
- when :integer
44
- value.to_i
45
- when :numeric
46
- BigDecimal.new(value)
47
- when :string
48
- value.to_s
49
- when :datetime
50
- Time.parse(value + " UTC")
51
- end
52
- end
53
-
54
- instance_variable_set(:"@#{name}", value)
55
- end
54
+ add_attribute(name, opts)
55
+ define_namespace_method(:class, name, opts, &block)
56
56
  end
57
57
 
58
58
  # A DSL method to map an XML rowset to a Ruby object.
@@ -70,16 +70,11 @@ module Greeve
70
70
  # attribute :start_date, xpath: "@startDate", type: :datetime
71
71
  # end
72
72
  def self.rowset(name, opts = {}, &block)
73
- name = name.to_sym
74
73
  @attributes ||= {}
75
74
 
76
- raise "Attribute `#{name}` defined more than once" if @attributes[name]
77
- raise "`:xpath` not specified for `#{name}`" unless opts[:xpath]
75
+ opts[:type] = :rowset
78
76
 
79
- @attributes[name] = {
80
- xpath: opts[:xpath],
81
- type: :rowset,
82
- }
77
+ add_attribute(name, opts)
83
78
 
84
79
  define_method(name) do
85
80
  ivar = instance_variable_get(:"@#{name}")
@@ -103,14 +98,16 @@ module Greeve
103
98
 
104
99
  # A DSL method to specify the API endpoint.
105
100
  #
106
- # @param path [String] path of the API endpoint. Doesn't need to include the
101
+ # @param path [String] path of the API endpoint. It shouldn't include the
107
102
  # leading slash `/`, or the extension `.xml.aspx`
108
103
  #
109
104
  # @example
110
105
  # endpoint "eve/CharacterInfo"
111
106
  def self.endpoint(path)
112
- # Remove leading slash and file extension.
113
- @endpoint = path.gsub(/\A\/*(.*?)(?:\.xml)?(?:\.aspx)?\z/, '\1')
107
+ raise ArgumentError, "Endpoint shouldn't start with a slash" \
108
+ if path.start_with?("/")
109
+
110
+ @endpoint = path
114
111
  end
115
112
 
116
113
  # @abstract Subclass and use the DSL methods to map API endpoints to objects
@@ -190,24 +187,10 @@ module Greeve
190
187
  .join("\n")
191
188
  end
192
189
 
193
- # @return [Hash] a hash of non-nil attributes
194
- def to_h
195
- attributes
196
- .keys
197
- .map { |name|
198
- value = __send__(name)
199
- value = value.to_a if value.is_a?(Rowset)
200
-
201
- [name, value]
202
- }
203
- .to_h
204
- .reject { |k, v| v.nil? }
205
- end
206
-
207
190
  private
208
191
 
209
192
  # @return [Hash] the hash of attributes for this object
210
- def attributes
193
+ def _attributes
211
194
  self.class.instance_variable_get(:@attributes) || {}
212
195
  end
213
196
 
@@ -221,13 +204,14 @@ module Greeve
221
204
  url = "#{Greeve::EVE_API_BASE_URL}/#{endpoint}.xml.aspx"
222
205
  response = Typhoeus.get(url, params: @query_params)
223
206
 
224
- # TODO: Use a better error class.
225
- raise TypeError, "HTTP error #{response.code}" \
226
- unless (200..299).include?(response.code.to_i)
207
+ raise ResponseError.new(
208
+ code: response.code,
209
+ status_message: response.status_message,
210
+ ) unless response.success?
227
211
 
228
212
  @xml_element = Ox.parse(response.body)
229
213
 
230
- attributes.keys.each do |name|
214
+ _attributes.keys.each do |name|
231
215
  instance_variable_set(:"@#{name}", nil)
232
216
  end
233
217
 
@@ -0,0 +1,24 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Character
5
+ # Character account balance.
6
+ #
7
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_accountbalance.html
8
+ class AccountBalance < Greeve::BaseItem
9
+ endpoint "char/AccountBalance"
10
+
11
+ rowset :accounts, xpath: "eveapi/result/rowset[@name='accounts']" do
12
+ attribute :account_id, xpath: "@accountID", type: :integer
13
+ attribute :account_key, xpath: "@accountKey", type: :integer
14
+ attribute :balance, xpath: "@balance", type: :numeric
15
+ end
16
+
17
+ # @param character_id [Integer] EVE character ID
18
+ def initialize(character_id, opts = {})
19
+ opts[:query_params] = { "characterID" => character_id }
20
+ super(opts)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Character
5
+ # Everything a character owns.
6
+ #
7
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_assetlist.html
8
+ class AssetList < Greeve::BaseItem
9
+ endpoint "char/AssetList"
10
+
11
+ rowset :assets, xpath: "eveapi/result/rowset[@name='assets']" do
12
+ attribute :item_id, xpath: "@itemID", type: :integer
13
+ attribute :location_id, xpath: "@locationID", type: :integer
14
+ attribute :type_id, xpath: "@typeID", type: :integer
15
+ attribute :quantity, xpath: "@quantity", type: :integer
16
+ attribute :flag, xpath: "@flag", type: :integer
17
+ attribute :singleton, xpath: "@singleton", type: :boolean
18
+ attribute :raw_quantity, xpath: "@rawQuantity", type: :integer
19
+ end
20
+
21
+ # @param character_id [Integer] EVE character ID
22
+ def initialize(character_id, opts = {})
23
+ opts[:query_params] = {
24
+ "characterID" => character_id,
25
+ "flat" => 1,
26
+ }
27
+
28
+ super(opts)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ require_relative "../base_item"
2
+
3
+ module Greeve
4
+ module Character
5
+ # Blueprints in a character's inventory.
6
+ #
7
+ # @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_blueprints.html
8
+ class Blueprints < Greeve::BaseItem
9
+ # Blueprint original
10
+ BPO = -1
11
+ # Blueprint copy
12
+ BPC = -2
13
+
14
+ endpoint "char/Blueprints"
15
+
16
+ rowset :blueprints, xpath: "eveapi/result/rowset[@name='blueprints']" do
17
+ attribute :item_id, xpath: "@itemID", type: :integer
18
+ attribute :location_id, xpath: "@locationID", type: :integer
19
+ attribute :type_id, xpath: "@typeID", type: :integer
20
+ attribute :type_name, xpath: "@typeName", type: :string
21
+ attribute :quantity, xpath: "@quantity", type: :integer
22
+ attribute :flag_id, xpath: "@flagID", type: :integer
23
+ attribute :time_efficiency, xpath: "@timeEfficiency", type: :integer
24
+ attribute :material_efficiency, xpath: "@materialEfficiency", type: :integer
25
+ attribute :runs, xpath: "@runs", type: :integer
26
+ end
27
+
28
+ # @param character_id [Integer] EVE character ID
29
+ def initialize(character_id, opts = {})
30
+ opts[:query_params] = { "characterID" => character_id }
31
+ super(opts)
32
+ end
33
+ end
34
+ end
35
+ end