]> _ Git - fluidbook_toolboxapiclient.git/commitdiff
wip #7454 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Apr 2025 15:09:06 +0000 (17:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Apr 2025 15:09:06 +0000 (17:09 +0200)
src/Client.php

index c95bb091631520d455e22173338b06a5a330dc19..dc9a557a24fa1af176f357fde19b72bd44977a9d 100644 (file)
@@ -7,7 +7,7 @@ use Psr\Http\Message\ResponseInterface;
 
 class Client
 {
-    const BASE_URI = 'https://https://toolbox.fluidbook.com/api/';
+    const BASE_URI = 'https://toolbox.fluidbook.com/api/';
     protected $_apiToken;
     /** @var \GuzzleHttp\Client */
     protected $_client;
@@ -19,7 +19,7 @@ class Client
         if (null === $uri) {
             $uri = self::BASE_URI;
         }
-        $this->setClient(new \GuzzleHttp\Client(['base_uri' => $uri]));
+        $this->setClient(new \GuzzleHttp\Client(['base_uri' => $uri, 'headers' => ['Authorization' => 'Bearer ' . $this->getApiToken()]]));
     }
 
     /**
@@ -60,7 +60,17 @@ class Client
         }
         $multipart[] = ['name' => 'file', 'contents' => Utils::tryFopen($file->getPathname(), 'r'), 'filename' => $file->getFilename()];
 
-        return $this->_request('post', '/fluidbook-publication/create', ['multipart' => $multipart]);
+        return $this->_request('post', 'fluidbook-publication/create', ['multipart' => $multipart]);
+    }
+
+    public function getFluidbookByReference(string $reference)
+    {
+        return $this->_request('get', 'fluidbook-publication/findbyreference/' . rawurlencode($reference));
+    }
+
+    public function deployFluidbook(int $id, $version = 'online', $action = 'install')
+    {
+        return $this->_request('post', 'fluidbook-publication/' . $id . '/download/' . $version . '/' . $action);
     }
 
     protected function _request($method, $uri, $options = [])