6 use React\Promise\ExtendedPromiseInterface
;
22 function __construct(API
$api, string $call) {
27 function __invoke(array $args) : ExtendedPromiseInterface
{
28 $promise = $this->api
->{$this->call
}->get(...$args);
30 /* fetch resource, unless already localized, and try for {$method}_url */
31 if (!$this->api
->exists($this->call
)) {
32 $promise = $promise->otherwise(function($error) use($args) {
33 if ($this->api
->exists($this->call
."_url", $url)) {
34 $url = new Url(uri_template($url, (array)current($args)));
35 return $this->api
->withUrl($url)->get(...$args);
38 $message = Exception\
message($error);
39 $this->api
->getLogger()->error("call($this->call): " . $message, [
40 "url" => (string) $this->api
->getUrl()