diff --git a/cli b/cli index 23c42bd..6911e74 100644 --- a/cli +++ b/cli @@ -7,21 +7,10 @@ $option = isset($argv[1]) ? trim($argv[1]) : false; $arg1 = isset($argv[2]) ? trim($argv[2]) : false; // setup xivapi -$api = new \XIVAPI\XIVAPI(); +$api = new \XIVAPI\XIVAPI(\XIVAPI\XIVAPI::STAGING); $api->environment->key(''); -// using concurrent -use GuzzleHttp\Promise; +$results = $api->market->getDataCenter('chaos', 3); -$promises = [ - 'item1' => $api->async()->content->Item()->one(1675), - 'item2' => $api->async()->content->Item()->one(5), - 'item3' => $api->async()->content->Item()->one(2546), -]; - -$results = Promise\settle($promises)->wait(); -$items = $api->unwrap($results); - -print_r( $items->item1->Name . PHP_EOL); -print_r( $items->item2->Name . PHP_EOL); -print_r( $items->item3->Name . PHP_EOL); +print_r($results); +die; diff --git a/cli_async b/cli_async new file mode 100644 index 0000000..23c42bd --- /dev/null +++ b/cli_async @@ -0,0 +1,27 @@ +#!/usr/bin/env php +environment->key(''); + +// using concurrent +use GuzzleHttp\Promise; + +$promises = [ + 'item1' => $api->async()->content->Item()->one(1675), + 'item2' => $api->async()->content->Item()->one(5), + 'item3' => $api->async()->content->Item()->one(2546), +]; + +$results = Promise\settle($promises)->wait(); +$items = $api->unwrap($results); + +print_r( $items->item1->Name . PHP_EOL); +print_r( $items->item2->Name . PHP_EOL); +print_r( $items->item3->Name . PHP_EOL); diff --git a/composer.lock b/composer.lock index d7cc833..f0a09ed 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "content-hash": "16dc225c2cab8ae158ccb5470f951a8d", @@ -1696,7 +1696,7 @@ }, { "name": "Gert de Pagter", - "email": "backendtea@gmail.com" + "email": "BackEndTea@gmail.com" } ], "description": "Symfony polyfill for ctype functions", diff --git a/src/XIVAPI/Api/Market.php b/src/XIVAPI/Api/Market.php index 1400bf5..c5eecf9 100644 --- a/src/XIVAPI/Api/Market.php +++ b/src/XIVAPI/Api/Market.php @@ -7,43 +7,31 @@ class Market { - public function get(string $server, int $itemId) + public function getServer(string $server, int $itemId) { return Guzzle::get("/market/{$server}/item/{$itemId}"); } - /** - * @deprecated - use "get" - */ - public function price(string $server, int $itemId) + public function getServers(array $servers, int $itemId) { - return Guzzle::get("/market/{$server}/items/{$itemId}"); + return Guzzle::get("/market/item/{$itemId}", [ + RequestOptions::QUERY => [ + 'servers' => implode(',', $servers) + ] + ]); } - /** - * @deprecated - use "get" - */ - public function history(string $server, int $itemId) - { - return Guzzle::get("/market/{$server}/items/{$itemId}/history"); - } - - public function stock(string $server, int $categoryId) + public function getDataCenter(string $dc, int $itemId) { - return Guzzle::get("/market/{$server}/category/{$categoryId}"); + return Guzzle::get("/market/item/{$itemId}", [ + RequestOptions::QUERY => [ + 'dc' => $dc + ] + ]); } public function categories() { return Guzzle::get("/market/categories"); } - - public function tokens($password) - { - return Guzzle::get("/companion/tokens", [ - RequestOptions::QUERY => [ - 'password' => $password - ] - ]); - } }