From 7d9108f6a6ff1e38218ae25dac59075ad013c60d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 7 Apr 2025 17:09:06 +0200 Subject: [PATCH] wip #7454 @2 --- src/Client.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index c95bb09..dc9a557 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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 = []) -- 2.39.5