Skip to content

Commit 265a2f3

Browse files
committed
Add support for new market endpoints
1 parent cba262b commit 265a2f3

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

cli

+4-15
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,10 @@ $option = isset($argv[1]) ? trim($argv[1]) : false;
77
$arg1 = isset($argv[2]) ? trim($argv[2]) : false;
88

99
// setup xivapi
10-
$api = new \XIVAPI\XIVAPI();
10+
$api = new \XIVAPI\XIVAPI(\XIVAPI\XIVAPI::STAGING);
1111
$api->environment->key('');
1212

13-
// using concurrent
14-
use GuzzleHttp\Promise;
13+
$results = $api->market->getDataCenter('chaos', 3);
1514

16-
$promises = [
17-
'item1' => $api->async()->content->Item()->one(1675),
18-
'item2' => $api->async()->content->Item()->one(5),
19-
'item3' => $api->async()->content->Item()->one(2546),
20-
];
21-
22-
$results = Promise\settle($promises)->wait();
23-
$items = $api->unwrap($results);
24-
25-
print_r( $items->item1->Name . PHP_EOL);
26-
print_r( $items->item2->Name . PHP_EOL);
27-
print_r( $items->item3->Name . PHP_EOL);
15+
print_r($results);
16+
die;

cli_async

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env php
2+
<?php
3+
// composer auto loader
4+
require __DIR__ . '/vendor/autoload.php';
5+
6+
$option = isset($argv[1]) ? trim($argv[1]) : false;
7+
$arg1 = isset($argv[2]) ? trim($argv[2]) : false;
8+
9+
// setup xivapi
10+
$api = new \XIVAPI\XIVAPI();
11+
$api->environment->key('');
12+
13+
// using concurrent
14+
use GuzzleHttp\Promise;
15+
16+
$promises = [
17+
'item1' => $api->async()->content->Item()->one(1675),
18+
'item2' => $api->async()->content->Item()->one(5),
19+
'item3' => $api->async()->content->Item()->one(2546),
20+
];
21+
22+
$results = Promise\settle($promises)->wait();
23+
$items = $api->unwrap($results);
24+
25+
print_r( $items->item1->Name . PHP_EOL);
26+
print_r( $items->item2->Name . PHP_EOL);
27+
print_r( $items->item3->Name . PHP_EOL);

src/XIVAPI/Api/Market.php

+13-25
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,31 @@
77

88
class Market
99
{
10-
public function get(string $server, int $itemId)
10+
public function getServer(string $server, int $itemId)
1111
{
1212
return Guzzle::get("/market/{$server}/item/{$itemId}");
1313
}
1414

15-
/**
16-
* @deprecated - use "get"
17-
*/
18-
public function price(string $server, int $itemId)
15+
public function getServers(array $servers, int $itemId)
1916
{
20-
return Guzzle::get("/market/{$server}/items/{$itemId}");
17+
return Guzzle::get("/market/item/{$itemId}", [
18+
RequestOptions::QUERY => [
19+
'servers' => implode(',', $servers)
20+
]
21+
]);
2122
}
2223

23-
/**
24-
* @deprecated - use "get"
25-
*/
26-
public function history(string $server, int $itemId)
27-
{
28-
return Guzzle::get("/market/{$server}/items/{$itemId}/history");
29-
}
30-
31-
public function stock(string $server, int $categoryId)
24+
public function getDataCenter(string $dc, int $itemId)
3225
{
33-
return Guzzle::get("/market/{$server}/category/{$categoryId}");
26+
return Guzzle::get("/market/item/{$itemId}", [
27+
RequestOptions::QUERY => [
28+
'dc' => $dc
29+
]
30+
]);
3431
}
3532

3633
public function categories()
3734
{
3835
return Guzzle::get("/market/categories");
3936
}
40-
41-
public function tokens($password)
42-
{
43-
return Guzzle::get("/companion/tokens", [
44-
RequestOptions::QUERY => [
45-
'password' => $password
46-
]
47-
]);
48-
}
4937
}

0 commit comments

Comments
 (0)