user¶
-
class
api.user.
User
¶ Bases:
flask_restful.Resource
-
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
(google_tok)¶ Deletes a user from the database.
Parameters: google_tok (str) – The google token 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
(google_tok)¶ Get request, looking for all users with google token.
Parameters: google_tok (str[]) – A list of google tokens to query with. Returns: A list of jsonified users. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['POST', 'DELETE', 'GET'])¶
-
parser
= <flask_restful.reqparse.RequestParser object>¶
-
post
(google_tok)¶ Posts a user to the database.
Parameters: google_tok (str) – The google token of the user being posted. Returns: What happened with the post call. Return type: message
-
provide_automatic_options
= None¶
-
representations
= None¶
-
classmethod
-
class
api.user.
UserList
¶ Bases:
flask_restful.Resource
The UserList object handles the entire list of users 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
(tokens)¶ Gets a list of all users in database that match any token from a list of tokens..
Parameters: tokens (str[]) – A list of tokens to query with. Returns: A list of jsonified users that match the tokens. Return type: json[]
-
method_decorators
= []¶
-
methods
= set(['GET'])¶
-
provide_automatic_options
= None¶
-
representations
= None¶
-
-
class
api.user.
UserModel
(google_tok, imageURL, email, name, givenName, familyName)¶ Bases:
sqlalchemy.ext.declarative.api.Model
The UserModel object stores information about the user, as well as the listing objects that are associated with it.
-
google_tok
¶ string – The google token for the user.
-
imageURL
¶ string – The URL referencing the user’s image.
-
email
¶ string – The user’s email.
-
name
¶ string – The user’s first name.
-
givenName
¶ string – The user’s given name.
-
familyName
¶ string – The user’s last name.
-
listings
¶ ListingModel[] – All listings posted by the user,
-
bare_json
()¶ Returns a jsonified user item, with a list of listing ids.
Parameters: none. – Returns: A json item representing the user. Return type: json
-
delete_from_db
()¶ Deletes the user from the database.
Parameters: none. – Returns: none.
-
email
-
familyName
-
classmethod
find_by_email
(email)¶ Finds a user by email.
Parameters: email (str) – The email of the user we’re searching for. Returns: The user who matches the email. Return type: UserModel
-
classmethod
find_by_google_tok
(google_tok)¶ Finds a user by google token.
Parameters: google_tok (str) – The google token of the user we’re looking for. Returns: The user who matches the google token.. Return type: UserModel
-
get_listings
()¶ Get a list of book listing jsons posted by the user.
Parameters: none. – Returns: A list of jsonified listings. Return type: json[]
-
givenName
-
google_tok
-
imageURL
-
listings
-
metadata
= MetaData(bind=None)¶
-
name
-
query_class
¶ alias of
flask_sqlalchemy.BaseQuery
-
save_to_db
()¶ Saves the user to the database.
Parameters: none. – Returns: A json item representing the user. Return type: json
-
user_json_w_listings
()¶ Returns a jsonified user item, with a list of jsonified listings.
Parameters: none. – Returns: A json item representing the user. Return type: json
-
user_json_wo_listings
()¶ Returns a jsonified user item.
Parameters: none. – Returns: A json item representing the user. Return type: json
-