Skip to content

Commit

Permalink
Add multi item id query endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vekien committed May 17, 2019
1 parent 90941c3 commit 8ba2707
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/XIVAPI/Api/Market.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Market
{
public function item(int $itemId, array $servers = [], string $dc = '')
{
if (empty($servers) && empty($dc)) {
throw new \Exception('You must provide either a list of servers or a DC name');
}

$options = [];

if ($servers) {
Expand All @@ -19,11 +23,34 @@ public function item(int $itemId, array $servers = [], string $dc = '')
$options['dc'] = $dc;
}

return Guzzle::get("/market/item/{$itemId}", [
RequestOptions::QUERY => $options
]);
}

public function items(array $itemIds, array $servers, string $dc = '')
{
if (empty($itemIds)) {
throw new \Exception('You must provide a list of item ids');
}

if (empty($servers) && empty($dc)) {
throw new \Exception('You must provide either a list of servers or a DC name');
}

return Guzzle::get("/market/item/{$itemId}", [
$options = [];

$options['ids'] = implode(',', $itemIds);

if ($servers) {
$options['servers'] = implode(',', $servers);
}

if ($dc) {
$options['dc'] = $dc;
}

return Guzzle::get("/market/items", [
RequestOptions::QUERY => $options
]);
}
Expand All @@ -35,6 +62,11 @@ public function search($elasticQuery)
]);
}

public function ids()
{
return Guzzle::get("/market/ids");
}

public function categories()
{
return Guzzle::get("/market/categories");
Expand Down

0 comments on commit 8ba2707

Please sign in to comment.