thunderlane/laravel-kitaboo-client

Kitaboo library for Laravel

v0.1-alpha 2019-09-15 11:05 UTC

This package is auto-updated.

Last update: 2024-04-22 02:10:33 UTC


README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License PhpStAn

Installation

composer require thunderlane/laravel-kitaboo-client

Setup

Add the following lines to your .env file:

KITABOO_CONTEXT_URL=https://kitaboo.endpoint
KITABOO_CLIENT_ID=<CLIENT ID>
KITABOO_CONSUMER_KEY=<CONSUMER KEY>
KITABOO_CONSUMER_SECRET=<CONSUMER SECRET>

Run

php artisan vendor:publish

Example usage

use Thunderlane\Kitaboo\KitabooInterface;

class YourController
{
	/**
	* @var Thunderlane\Kitaboo\KitabooInterface
	*/
	private $kitaboo;

	public function __construct(KitabooInterface $kitaboo)
	{
		$this->kitaboo = $kitaboo;
	}	

	/**
	 * @throws \Thunderlane\Kitaboo\Exceptions\UnknownEntityException
	 */
	public function yourAction()
	{
		$userService = $this->kitaboo->getReaderServices()->getUserService();
		$userService->authenticateUser('USERNAME', 'PASSWORD');

		$token = $userService->getCurrentUserToken();
		$userService->setCurrentUserToken($token);

		$user = $userService->getCurrentUser();
		$userService->setCurrentUser($user);

		$collectionService = $this->kitaboo->getExternalServices()->getCollectionService();
		$collectionService->listCollection();
	}
}