promise refactoring++
[pharext/pharext.org] / app / Github / API / Hooks / DeleteHook.php
index a94f2855c086bfc7d28ec92629c03db85478beb6..3635f6e65ae274f0a9fcab727483ef0852f160a3 100644 (file)
@@ -5,21 +5,22 @@ namespace app\Github\API\Hooks;
 use app\Github\API\Call;
 use app\Github\Exception\RequestException;
 use http\Client\Request;
+use http\Client\Response;
 
 class DeleteHook extends Call
 {
-       function enqueue(callable $callback) {
+       function request() {
                $url = $this->url->mod(uri_template("./repos/{+repo}/hooks{/id}", $this->args));
                $request = new Request("DELETE", $url, [
                        "Authorization" => "token " . $this->api->getToken(),
                        "Accept" => $this->config->api->accept,
                ]);
-               $this->api->getClient()->enqueue($request, function($response) use($callback) {
-                       if ($response->getResponseCode() >= 400) {
-                               throw new RequestException($response);
-                       }
-                       $callback();
-                       return true;
-               });
+               return $request;
+       }
+       
+       function response(Response $response) {
+               if ($response->getResponseCode() >= 400) {
+                       throw new RequestException($response);
+               }
        }
 }