5 use AsyncInterop\Promise
;
22 function __construct(API
$api, string $call) {
27 function __invoke(array $args) : Promise
{
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->when(function($error, $value) use($args) {
36 if ($this->api
->exists($this->call
."_url", $url)) {
37 $url = new Url(uri_template($url, (array)current($args)));
38 return $this->api
->withUrl($url)->get(...$args);
41 $message = Exception\
message($error);
42 $this->api
->getLogger()->error("call($this->call): " . $message, [
43 "url" => (string) $this->api
->getUrl()