-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Character::Locations endpoint
- Loading branch information
Showing
4 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require_relative "../base_item" | ||
|
||
module Greeve | ||
module Character | ||
# Location and name of specific items that belong to the character of the | ||
# api key. This call can be used to retrieve the player-set name of | ||
# containers and ships. | ||
# | ||
# @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/character/char_locations.html | ||
class Locations < Greeve::BaseItem | ||
endpoint "char/Locations" | ||
|
||
rowset :locations, xpath: "eveapi/result/rowset[@name='locations']" do | ||
attribute :item_id, xpath: "@itemID", type: :integer | ||
attribute :item_name, xpath: "@itemName", type: :string | ||
attribute :x, xpath: "@x", type: :numeric | ||
attribute :y, xpath: "@y", type: :numeric | ||
attribute :z, xpath: "@z", type: :numeric | ||
end | ||
|
||
# @param character_id [Integer] EVE character ID | ||
# | ||
# @option opts [Array<Integer>, Integer] :ids (nil) ID or array of IDs of | ||
# items belonging to the character | ||
def initialize(character_id, opts = {}) | ||
ids = opts.delete(:ids) | ||
ids = [ids] unless ids.nil? || ids.is_a?(Array) | ||
|
||
opts[:query_params] = { "characterID" => character_id } | ||
opts[:query_params]["IDs"] = ids.join(",") if ids | ||
|
||
super(opts) | ||
end | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
vcr_opts = { | ||
cassette_name: "character/locations", | ||
} | ||
|
||
describe Greeve::Character::Locations, vcr: vcr_opts do | ||
let(:key) { "1515664" } | ||
let(:vcode) { "QYYBHdsFMmdWjc9bkWhqqKx00NLqA1c3pNHlacqHUGpaTkrnyrzwZ0vFY9L6aei3" } | ||
let(:character_id) { 462421468 } | ||
|
||
let(:resource) { | ||
Greeve::Character::Locations.new(character_id, key: key, vcode: vcode) | ||
} | ||
|
||
context "resource" do | ||
subject { resource } | ||
|
||
its(:locations) { should be_a Greeve::Rowset } | ||
end | ||
|
||
context "locations" do | ||
subject { resource.locations.first } | ||
|
||
its(:item_id) { should eq 1010000493393 } | ||
its(:item_name) { should eq "Zephyr Biscuit" } | ||
its(:x) { should eq 0 } | ||
its(:y) { should eq 0 } | ||
its(:z) { should eq 0 } | ||
end | ||
end |