Exemplo n.º 1
0
 /**
  * Gets market history for multiple types in a region asynchronously, using the passed callback functions for
  * processing CREST responses. If the market history for each type/region is only called once per day (for instance
  * when persisted in a DB), it is advisable to disable caching via argument. Otherwise it can quickly overflow the
  * cache.
  *
  * @param array $typeIds of the item types
  * @param int $regionId of the region
  * @param callable $callback a function expecting one iveeCrest\Response object as argument, called for every
  * successful response
  * @param callable $errCallback a function expecting one iveeCrest\Response object as argument, called for every
  * non-successful response
  * @param bool $cache if the individual query Responses should be cached
  *
  * @return void
  */
 public function getMultiMarketHistory(array $typeIds, $regionId, callable $callback, callable $errCallback = null, $cache = true)
 {
     //check for wormhole regions
     if ($regionId > 11000000) {
         $invalidArgumentExceptionClass = Config::getIveeClassName('InvalidArgumentException');
         throw new $invalidArgumentExceptionClass("Invalid regionId. Wormhole regions have no market.");
     }
     //Here we have to construct the URLs because there's no navigable way to reach this data from CREST root
     $hrefs = [];
     $rootUrl = $this->client->getRootEndpointUrl();
     foreach (array_unique($typeIds) as $typeId) {
         $hrefs[] = $rootUrl . 'market/' . (int) $regionId . '/types/' . (int) $typeId . '/history/';
     }
     //run the async queries
     $this->client->asyncGetMultiEndpointResponses($hrefs, $callback, $errCallback, static::MARKET_TYPE_HISTORY_COLLECTION_REPRESENTATION, $cache);
 }