2017 © Pedro Peláez
 

library data-client-php

Biblys Data PHP client library

image

biblys/data-client-php

Biblys Data PHP client library

  • Friday, March 25, 2016
  • by biblys
  • Repository
  • 1 Watchers
  • 4 Stars
  • 91 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Biblys Data PHP client library

Build Status, (*1)

A PHP library to fetch data from or push data to Biblys Data., (*2)

Install

With composer:, (*3)

Install with composer:, (*4)

composer require biblys/data-client-php:~0, (*5)

API

Client

$client = new Client(array options)

Initialize a new Biblys Data client., (*6)

Options: * apiKey: optional when reading data from server, only required when pushing data to server * server: optional, defaults to http://data.biblys.fr, (*7)

$client->getBook(string $isbn)

Get book infos from Biblys Data server for this ISBN., (*8)

Returns a Book object if an object was found for this ISBN, returns false otherwise., (*9)

$client->pushBook(Book $book)

Send the Book object to server. Will test if there is already a book with this ISBN with getBook(). If there is, will use the updateBook() method to update it. Else, will use the createBook() method to create it., (*10)

$client->createBook(Book $book)

Will try create the book on the server. Throws an exception if there is already a book with this ISBN., (*11)

$client->updateBook(Book $book)

Not yet implemented on the server (will fail silently)., (*12)

$client->pushPublisher(Publisher $publisher)

Send the Publisher object to server. Will test if there is already a book with this id with getPublisher(). If there is, will use the updatePublisher() method to update it. Else, will use the createPublisher() method to create it., (*13)

$client->createPublisher(Publisher $publisher)

Will try create the book on the server. Throws an exception if there is already a book with this ISBN., (*14)

$client->updatePublisher(Publisher $publisher)

Not yet implemented on the server (will fail silently)., (*15)

Book

$book = new Book()

Create a new Book object, (*16)

$book->setEan(string $isbn)

Set the book's ISBN. Throws an exception $isbn is not a valid ISBN., (*17)

$book->getEan()

Get the book's ISBN., (*18)

$book->setTitle(string $title)

Set the book's title, (*19)

$book->getTitle()

Get the book's title, (*20)

$book->setPublisher(Publisher $publisher)

Associate a Publisher resource with the book, (*21)

$book->getPublisher()

Get the book's publisher as a Publisher object, (*22)

$book->setAuthors(array $authors)

Set the book's authors (must be an array of Contributor objects), (*23)

$book->addAuthor(Author $author)

Associate a Contributor with the book as an author, (*24)

$book->getAuthors()

Get the book's authors as an array of Contributor objects, (*25)

Contributor

Multiple contributors can be associated with book as authors. Other roles (illustrator, translator, etc.) will come later., (*26)

$contributor = new Contributor()

Create a new Contributor object, (*27)

$contributor->setId(string $id)

Set the contributor's id., (*28)

$contributor->getId()

Get the contributor's id., (*29)

$contributor->setFirstName(string $firstName)

Set the contributor's first name, (*30)

$contributor->getFirstName()

Get the contributor's first name, (*31)

$contributor->setLastName(string $lastName)

Set the contributor's last name, (*32)

$contributor->getLastName()

Get the contributor's last name, (*33)

$contributor->setName(string $name)

Set the contributor's full name (first + last names), (*34)

$contributor->getName()

Get the contributor's full name (first + last names), (*35)

Publisher

A publisher resource can be associated with a book., (*36)

$publisher = new Publisher()

Create a new Publisher object, (*37)

$publisher->setId(string $id)

Set the publisher's id., (*38)

$publisher->getId()

Get the publisher's id., (*39)

$publisher->setName(string $name)

Set the publisher's name, (*40)

$publisher->getName()

Get the publisher's name, (*41)

Examples

Get a book's infos from an ISBN, (*42)

use Biblys\Data\Client;

$client = new Client();

$result = $client->getBook('9791091146134');

if (!$result) {
  // Result if false, no book was found for this ISBN
} else {
  echo $result->getTitle();
}

Push a book's infos to server, (*43)

use Biblys\Data\Client;
use Biblys\Data\Book;
use Biblys\Data\Publisher;

$client = new Client([
  "apiKey" => "YOUR_API_KEY" // required when pushing data
]);

$book = new Book();
$book->setEan('9791091146134');
$book->setTitle('Chants du cauchemar et de la nuit');

$publisher = new Publisher();
$publisher->setName('Dystopia');
$book->setPublisher($publisher);

$author = new Contributor();
$author->setFirstName('Thomas');
$author->setLastName('Ligotti');
$book->addAuthor($author);

try {
  $result = $client->push($book);  
} catch (Exception $e) {
  // Something went wrong
}

Test

Run tests with PHPUnit:, (*44)

  • composer install
  • composer test

Changelog

0.3.0 (2016-04-05) * Contributor push, create and get methods * Books must be pushed with at least one Contributor as an author, (*45)

0.2.1 (2016-03-25) * Fixed getting Publisher with Book * Require Publisher property when creating a Book, (*46)

0.2.0 (2016-03-24) * Publisher push, create and get methods * Book must be pushed with a Publisher, (*47)

0.1.0 (2016-03-05) * First release * Book push, create and get methods, (*48)

The Versions

25/03 2016

dev-master

9999999-dev https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys

25/03 2016

dev-develop

dev-develop https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys

25/03 2016

0.2.1

0.2.1.0 https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys

25/03 2016

0.3.0

0.3.0.0 https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys

05/03 2016

0.1.0

0.1.0.0 https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys

05/03 2016

0.2.0

0.2.0.0 https://github.com/biblys/biblys-data-client-php

Biblys Data PHP client library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Clement Bourgoin

book isbn bibliography biblys