Skip to content

Commit 45494b0

Browse files
committed
Add new market code
1 parent 0567601 commit 45494b0

File tree

3 files changed

+79
-13
lines changed

3 files changed

+79
-13
lines changed

src/XIVAPI/Api/Market.php

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,67 @@
77

88
class Market
99
{
10-
public function getServer(string $server, int $itemId)
10+
public function item(int $itemId, array $servers = [], string $dc = '')
1111
{
12-
return Guzzle::get("/market/{$server}/item/{$itemId}");
12+
$options = [];
13+
14+
if ($servers) {
15+
$options['servers'] = implode(',', $servers);
16+
}
17+
18+
if ($dc) {
19+
$options['dc'] = $dc
20+
}
21+
22+
return Guzzle::get("/market/item/{$itemId}", [
23+
RequestOptions::QUERY => $options
24+
]);
1325
}
14-
15-
public function getServers(array $servers, int $itemId)
26+
27+
public function search($elasticQuery)
1628
{
17-
return Guzzle::get("/market/item/{$itemId}", [
29+
return Guzzle::get("/market/search", [
30+
RequestOptions::JSON => $elasticQuery
31+
]);
32+
}
33+
34+
public function categories()
35+
{
36+
return Guzzle::get("/market/categories");
37+
}
38+
39+
40+
public function itemPrices(string $accessKey, int $itemId, string $server)
41+
{
42+
return Guzzle::get("/private/market/item", [
1843
RequestOptions::QUERY => [
19-
'servers' => implode(',', $servers)
44+
'companion_access_key' => $accessKey,
45+
'item_id' => $itemId,
46+
'server' => $server,
2047
]
2148
]);
2249
}
23-
24-
public function getDataCenter(string $dc, int $itemId)
50+
51+
public function itemHistory(string $accessKey, int $itemId, string $server)
2552
{
26-
return Guzzle::get("/market/item/{$itemId}", [
53+
return Guzzle::get("/private/market/item/history", [
2754
RequestOptions::QUERY => [
28-
'dc' => $dc
55+
'companion_access_key' => $accessKey,
56+
'item_id' => $itemId,
57+
'server' => $server,
2958
]
3059
]);
3160
}
3261

33-
public function categories()
62+
public function manualUpdateItem(string $accessKey, int $itemId, string $server)
3463
{
35-
return Guzzle::get("/market/categories");
64+
return Guzzle::get("/private/market/item/update", [
65+
RequestOptions::QUERY => [
66+
'companion_access_key' => $accessKey,
67+
'item_id' => $itemId,
68+
'server' => $server,
69+
]
70+
]);
3671
}
72+
3773
}

src/XIVAPI/Api/Url.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace XIVAPI\Api;
4+
5+
use GuzzleHttp\RequestOptions;
6+
use XIVAPI\Guzzle\Guzzle;
7+
8+
/**
9+
* Provides more free/open queries of custom endpoints
10+
*/
11+
class Url
12+
{
13+
public function get(string $endpoint, array $options)
14+
{
15+
return Guzzle::get($endpoint, [
16+
RequestOptions::QUERY => $options
17+
]);
18+
}
19+
20+
public function post(string $endpoint, array $options)
21+
{
22+
return Guzzle::post($endpoint, [
23+
RequestOptions::QUERY => $options
24+
]);
25+
}
26+
}

src/XIVAPI/XIVAPI.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use XIVAPI\Api\PvPTeam;
1313
use XIVAPI\Api\Search;
1414
use XIVAPI\Api\Content;
15+
use XIVAPI\Api\Url;
1516
use XIVAPI\Common\Environment;
1617
use XIVAPI\Guzzle\Guzzle;
1718

@@ -23,6 +24,8 @@ class XIVAPI
2324

2425
/** @var Environment */
2526
public $environment;
27+
/** @var Url */
28+
public $url;
2629
/** @var Search */
2730
public $search;
2831
/** @var Content */
@@ -46,8 +49,9 @@ public function __construct(string $environment = self::PROD)
4649
{
4750
// set environment to use
4851
Guzzle::setEnvironment($environment);
49-
52+
5053
$this->environment = new Environment();
54+
$this->url = new Url();
5155
$this->search = new Search();
5256
$this->content = new Content();
5357
$this->character = new Character();

0 commit comments

Comments
 (0)