CollectionsCollections Database

Google Books Javascript library

The Google Books Javascript library is a wrapper for the the Google Books API.

The source code is available in the GitHub repository.

app.api.googleBooks
The library is accessible from the app.api.googleBooks object.
search(query app.query object) array of search results
The function searches volumes and returns an array of search results.
getVolume(id string) volume
The function gets a volume by ID. It returns a volume or undefined if it doesn't exist.
volumeClass class
Set a custom class for the volume, the class must extend app.classes.api.googleBooks.volume
// Google Books search (1.0)
// https://github.com/risolvipro/collections

let results = app.api.googleBooks.search(app.query);
app.result(results);

Volume

app.classes.api.googleBooks.volume
This class manages a volume.
data json
The json data returned by Google Books.
title string
Title of the volume.
requestImage() image
Request the cover image with the best resolution. It returns an image object or undefined if the request fails.
publisher string
Publisher of the volume.
publishedDate date
Published date of the volume as a Date object.
authors array of document builders
Get the authors as an array of document builders.
categories array of list item suggestions
Get the categories as an array of list item suggestions.
ISBN_13 string
ISBN 13 code of the volume.
// Google Books document (1.0)
// https://github.com/risolvipro/collections

let volume = app.api.googleBooks.getVolume(app.params.id);

if(volume == undefined) {
    app.fail();
}

let builder = app.document.builder();

builder.setString(volume.title, "title");
builder.setDocuments(volume.authors, "authors");
builder.setImage(volume.requestImage(), "cover");
builder.setListItems(volume.categories(app.params.categories), "genre");
builder.setString(volume.publisher, "publisher");
builder.setDate(volume.publishedDate, "published-date");
builder.setInteger(volume.pageCount, "page-count");
builder.setString(volume.ISBN_13, "isbn");

app.result(builder);