book¶
-
class
api.book.
Book
¶ Bases:
flask_restful.Resource
The Book object handles API requests such as Get/Post/Delete.
-
none.
-
classmethod
as_view
(name, *class_args, **class_kwargs)¶ Converts the class into an actual view function that can be used with the routing system. Internally this generates a function on the fly which will instantiate the
View
on each request and call thedispatch_request()
method on it.The arguments passed to
as_view()
are forwarded to the constructor of the class.
-
decorators
= ()¶
-
delete
(isbns)¶ Deletes a book from the database.
Parameters: isbns (str) – The isbn of the book being deleted. Returns: What happened with the delete call. Return type: message
-
dispatch_request
(*args, **kwargs)¶ Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.
-
get
(isbns)¶ Get request, looking for all books based on isbns.
Parameters: isbns (str[]) – A list of isbns to query with. Returns: A list of jsonified books. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['POST', 'DELETE', 'GET'])¶
-
parser
= <flask_restful.reqparse.RequestParser object>¶
-
post
(isbns)¶ Posts a book to the database.
Parameters: isbns (str) – The isbn of the book being posted. Returns: What happened with the post call. Return type: message
-
provide_automatic_options
= None¶
-
representations
= None¶
-
-
class
api.book.
BookList
¶ Bases:
flask_restful.Resource
The BookList object handles the entire list of books in the database.
-
none.
-
classmethod
as_view
(name, *class_args, **class_kwargs)¶ Converts the class into an actual view function that can be used with the routing system. Internally this generates a function on the fly which will instantiate the
View
on each request and call thedispatch_request()
method on it.The arguments passed to
as_view()
are forwarded to the constructor of the class.
-
decorators
= ()¶
-
dispatch_request
(*args, **kwargs)¶ Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.
-
get
(search)¶ Gets a list of all books in database that match a search.
Parameters: search (str) – The string to search with. Returns: A list of jsonified books that match the search result. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['GET'])¶
-
provide_automatic_options
= None¶
-
representations
= None¶
-
-
class
api.book.
BookModel
(title, subtitle, authors, isbn, categories, publishedDate, smallThumbnail, thumbnail, previewLink, infoLink, canonicalVolumeLink)¶ Bases:
sqlalchemy.ext.declarative.api.Model
- The BookModel object stores information about the book, as well as
- the listing objects that are associated with it.
-
title
¶ string – The title of the book.
-
subtitle
¶ string – The subtitle of the book.
string – The author/authors of the book.
-
isbn
¶ int – The isbn number for the book.
-
categories
¶ string – The categorise of the book.
-
puhlishedDate
¶ string – The published date of the book.
-
smallThumbnail
¶ string – A string referencing the small thumbnail of the book.
-
thumbnail
¶ string – A string referencing the thumbnail of the book.
-
previewLink
¶ string – A link to preview the book.
-
infoLink
¶ string – An info link for the book.
-
canonicalVolumeLink
¶ string – A canononical volume link for the book. listings (Listing): The current listings of the book.
-
authors
authors = relationship( “AuthorModel”, secondary=association_table1, back_populates=’works’)
-
bare_json
()¶ Returns a jsonified book item, including a list of listing ids.
Parameters: none. – Returns: A json item representing a book. Return type: json
-
book_json_w_listings
()¶ - Returns a jsonified book item, including a list of
- jsonified listings.
Parameters: none. – Returns: A json item representing a book. Return type: json
-
book_json_wo_listings
()¶ Returns a jsonified book item, not including listings.
Parameters: none. – Returns: A json item representing a book. Return type: json
-
canonicalVolumeLink
-
categories
-
delete_from_db
()¶ Deletes the book from the database.
Parameters: none. – Returns: none.
-
classmethod
find_by_isbn
(isbn)¶ Finds a book by isbn number.
Parameters: isbn (str) – The isbn number we are searching for. Returns: The book which matches the isbn. Return type: Book
-
get_listings
()¶ Get a list of book listing jsons.
Parameters: none. – Returns: A list of jsonified listings. Return type: json[]
-
infoLink
-
isbn
-
listings
¶
-
metadata
= MetaData(bind=None)¶
-
previewLink
-
publishedDate
¶
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
save_to_db
()¶ Saves the book to the database.
Parameters: none. – Returns: A json item representing the book. Return type: json
-
smallThumbnail
-
subtitle
-
thumbnail
-
title