Skip to content

Commit

Permalink
Implement Corporation::AccountBalance endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
amclain committed Sep 22, 2016
1 parent 29310ca commit 13d8ab3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/greeve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require_relative "greeve/character/skill_queue"
require_relative "greeve/character/skills"
require_relative "greeve/character/standings"
require_relative "greeve/corporation/account_balance"
require_relative "greeve/corporation/member_tracking"
require_relative "greeve/eve/character_info"
require_relative "greeve/map/fac_war_systems"
Expand Down
18 changes: 18 additions & 0 deletions lib/greeve/corporation/account_balance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_relative "../base_item"

module Greeve
module Corporation
# Corporation account balances.
#
# @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/corporation/corp_accountbalance.html
class AccountBalance < Greeve::BaseItem
endpoint "corp/AccountBalance"

rowset :accounts, xpath: "eveapi/result/rowset[@name='accounts']" do
attribute :account_id, xpath: "@accountID", type: :integer
attribute :account_key, xpath: "@accountKey", type: :integer
attribute :balance, xpath: "@balance", type: :numeric
end
end
end
end
26 changes: 26 additions & 0 deletions spec/corporation/account_balance_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe Greeve::Corporation::AccountBalance do
let(:base_endpoint) { "#{Greeve::EVE_API_BASE_URL}/corp/AccountBalance.xml.aspx" }
let(:xml_filename) { "corporation/account_balance" }

before {
stub_endpoint(base_endpoint, xml_filename)

invalidate_remaining_endpoints
}

let(:resource) { Greeve::Corporation::AccountBalance.new }

context "resource" do
subject { resource }

its(:accounts) { should be_a Greeve::Rowset }
end

context "accounts" do
subject { resource.accounts.first }

its(:account_id) { should eq 45584084 }
its(:account_key) { should eq 1000 }
its(:balance) { should eq BigDecimal.new("7231642205.17") }
end
end
16 changes: 16 additions & 0 deletions spec/xml/corporation/account_balance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2016-09-22 20:36:51</currentTime>
<result>
<rowset name="accounts" key="accountID" columns="accountID,accountKey,balance">
<row accountID="45584084" accountKey="1000" balance="7231642205.17" />
<row accountID="45584281" accountKey="1001" balance="369354707.30" />
<row accountID="45584282" accountKey="1002" balance="643412103.27" />
<row accountID="45584283" accountKey="1003" balance="0.00" />
<row accountID="45584284" accountKey="1004" balance="0.10" />
<row accountID="45584285" accountKey="1005" balance="0.92" />
<row accountID="45584286" accountKey="1006" balance="53939224.41" />
</rowset>
</result>
<cachedUntil>2016-09-22 20:49:35</cachedUntil>
</eveapi>

0 comments on commit 13d8ab3

Please sign in to comment.