listing¶
-
class
api.listing.
Listing
¶ Bases:
flask_restful.Resource
The Listing object handles API requests such as Get/Post/Delete/Put.
-
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
(ids)¶ Deletes a listing from the database.
Parameters: ids (str) – The id of the listing 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
(ids)¶ Get request, looking for all listings matching an id in ids.
Parameters: ids (str[]) – A list of ids to query with. Returns: A list of jsonified listings. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['PUT', 'POST', 'DELETE', 'GET'])¶
-
parser
= <flask_restful.reqparse.RequestParser object>¶
-
post
(ids)¶ Posts a listing to the database.
Parameters: ids (str) – The listing id of the listing being posted. Returns: What happened with the post call. Return type: message
-
provide_automatic_options
= None¶
-
put
(listing_id, price, condition, isbn, google_tok, status)¶ Either posts listing to database, or updates it.
Parameters: - listing_id (int) – An id to represent the listing, generated by the table.
- price (float) – The price of the listing.
- condition (str) – The condition of the listing.
- isbn (int) – The isbn of the listing.
- google_tok (str) – The google token of the user who made the posting.
- status (str) – The status of the listing.
Returns: A jsonified listing object representing what was put.
Return type: json
-
representations
= None¶
-
-
class
api.listing.
ListingModel
(price, condition, isbn, google_tok, status)¶ Bases:
sqlalchemy.ext.declarative.api.Model
The ListingModel object stores information about the listing, as well as the book and user objects associated with it.
-
listing_id
¶ int – An id to represent the listing, generated by the table.
-
price
¶ float – The price of the listing.
-
condition
¶ string – The condition of the listing.
-
isbn
¶ int – The isbn of the listing.
-
book
¶ BookModel – The book being represented by the listing.
-
google_tok
¶ string – The google token of the user who made the posting.
-
user
¶ UserModel – The user who made the posting.
-
status
¶ string – The status of the listing.
-
timestamp
¶ int – The time the listing was posted.
-
bare_json
()¶ Returns a json object representing the listing.
Parameters: none. – Returns: A jsonified listing. Return type: json
-
book
-
bu_bare_json
()¶ Returns a json object representing the listing. Used when going from books to users.
Parameters: none. – Returns: A jsonified listing. Return type: json
-
condition
-
delete_from_db
()¶ deletes the listing to the database.
Parameters: none. – Returns: none.
-
classmethod
find_by_isbn
(isbn)¶ Finds all listings matching an isbn.
Parameters: isbn (int) – The isbn to search with. Returns: A list of listings. Return type: ListingModel[]
-
classmethod
find_by_listing_id
(listing_id)¶ Finds all listings matching a listing id.
Parameters: listing_id (int) – The listing id to search for. Returns: A list of listings. Return type: ListingModel[]
-
google_tok
-
isbn
-
listing_id
-
listing_json_w_book
()¶ Returns the listing jsonified, with a reference to the book being represented.
Parameters: none. – Returns: A jsonified listing. Return type: json
-
listing_json_w_book_and_user
()¶ Returns the listing jsonified, with a reference to the book being represented and the user who posted it.
Parameters: none. – Returns: A jsonified listing. Return type: json
-
listing_json_w_user
()¶ Returns the listing jsonified, with a reference to the user who posted.
Parameters: none. – Returns: A jsonified listing. Return type: json
-
metadata
= MetaData(bind=None)¶
-
price
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
save_to_db
()¶ Saves the listing to the database.
Parameters: none. – Returns: none.
-
status
-
timestamp
-
user
-
-
class
api.listing.
allListings
¶ Bases:
flask_restful.Resource
The allListings object handles the entire list of listings 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 listings in database that match a search.
Parameters: search (str[]) – A list of search terms defining what to search with. Returns: A list of jsonified listings that match the search result. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['GET'])¶
-
provide_automatic_options
= None¶
-
representations
= None¶
-