X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=blobdiff_plain;f=lib%2FAPI%2FCall.php;h=7eba2a80b7fbfb76f6b7748c728c06797410c357;hp=f10d6e81328f79373f168fe9e41616129b22d95e;hb=e368287b3cd2dd40945ac8d1a1946bc32268007d;hpb=626d8937c75f6d8fca463fa2b374f645068b2d6d diff --git a/lib/API/Call.php b/lib/API/Call.php index f10d6e8..7eba2a8 100644 --- a/lib/API/Call.php +++ b/lib/API/Call.php @@ -2,8 +2,8 @@ namespace seekat\API; +use AsyncInterop\Promise; use http\Url; -use React\Promise\ExtendedPromiseInterface; use seekat\API; use seekat\Exception; @@ -24,24 +24,12 @@ final class Call $this->call = $call; } - function __invoke(array $args) : ExtendedPromiseInterface { - $promise = $this->api->{$this->call}->get(...$args); - - /* fetch resource, unless already localized, and try for {$method}_url */ - if (!$this->api->exists($this->call)) { - $promise = $promise->otherwise(function($error) use($args) { - if ($this->api->exists($this->call."_url", $url)) { - $url = new Url(uri_template($url, (array)current($args))); - return $this->api->withUrl($url)->get(...$args); - } - - $message = Exception\message($error); - $this->api->getLogger()->error("call($this->call): " . $message, [ - "url" => (string) $this->api->getUrl() - ]); - - throw $error; - }); + function __invoke(array $args) : Promise { + if ($this->api->exists($this->call."_url", $url)) { + $url = new Url(uri_template($url, (array)current($args))); + $promise = $this->api->withUrl($url)->get(...$args); + } else { + $promise = $this->api->{$this->call}->get(...$args); } return $promise;