Skip to content

Commit

Permalink
Implement Character::AssetList endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
amclain committed Nov 22, 2016
1 parent ca424a8 commit 651b658
Show file tree
Hide file tree
Showing 4 changed files with 111 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 @@ -19,6 +19,7 @@
require_relative "greeve/account/characters"
require_relative "greeve/api/call_list"
require_relative "greeve/character/account_balance"
require_relative "greeve/character/asset_list"
require_relative "greeve/character/blueprints"
require_relative "greeve/character/calendar_event_attendees"
require_relative "greeve/character/character_sheet"
Expand Down
32 changes: 32 additions & 0 deletions lib/greeve/character/asset_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require_relative "../base_item"

module Greeve
module Character
# Everything a character owns.
#
# @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_assetlist.html
class AssetList < Greeve::BaseItem
endpoint "char/AssetList"

rowset :assets, xpath: "eveapi/result/rowset[@name='assets']" do
attribute :item_id, xpath: "@itemID", type: :integer
attribute :location_id, xpath: "@locationID", type: :integer
attribute :type_id, xpath: "@typeID", type: :integer
attribute :quantity, xpath: "@quantity", type: :integer
attribute :flag, xpath: "@flag", type: :integer
attribute :singleton, xpath: "@singleton", type: :boolean
attribute :raw_quantity, xpath: "@rawQuantity", type: :integer
end

# @param character_id [Integer] EVE character ID
def initialize(character_id, opts = {})
opts[:query_params] = {
"characterID" => character_id,
"flat" => 1,
}

super(opts)
end
end
end
end
47 changes: 47 additions & 0 deletions spec/cassettes/character/asset_list.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions spec/character/asset_list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
vcr_opts = {
cassette_name: "character/asset_list",
}

describe Greeve::Character::AssetList, vcr: vcr_opts do
let(:key) { "1515664" }
let(:vcode) { "QYYBHdsFMmdWjc9bkWhqqKx00NLqA1c3pNHlacqHUGpaTkrnyrzwZ0vFY9L6aei3" }
let(:character_id) { 462421468 }

let(:resource) {
Greeve::Character::AssetList.new(character_id, key: key, vcode: vcode)
}

context "resource" do
subject { resource }

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

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

its(:item_id) { should eq 1009196745972 }
its(:location_id) { should eq 60001039 }
its(:type_id) { should eq 27914 }
its(:quantity) { should eq 1 }
its(:flag) { should eq 4 }
its(:singleton) { should eq true }
its(:raw_quantity) { should eq -1 }
end
end

0 comments on commit 651b658

Please sign in to comment.