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;
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()]]));
}
/**
}
$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 = [])