- /**
- * Progress observer
- *
- * Import the response's data on success and resolve the promise.
- *
- * @param SplSubject $client The observed HTTP client
- * @param Request $request The request which generated the update
- * @param object $progress The progress information
- */
- function update(SplSubject $client, Request $request = null, $progress = null) {
- if ($request !== $this->request) {
- return;
- }
-
- $this->notify((object) compact("client", "request", "progress"));
-
- if ($progress->info === "finished") {
- $this->response = $this->client->getResponse();
- $this->complete(
- [$this, "resolve"],
- [$this, "reject"]
- );
- }
- }
-
- /**
- * Completion callback
- * @param callable $resolve
- * @param callable $reject
- */
- private function complete(callable $resolve, callable $reject) {
- $this->client->detach($this);
-
- if ($this->response) {
- try {
- $resolve($this->api->import($this->response));
- } catch (Exception $e) {
- $reject($e);
- }
+ function __invoke(array $args) {
+ if ($this->api->exists($this->call."_url", $url)) {
+ $url = new Url(uri_template($url, (array) current($args)));
+ $promise = $this->api->withUrl($url)->get(...$args);