API: Doc format

This commit is contained in:
Sagi Dayan 2015-06-14 18:51:48 +03:00
parent 1305762548
commit bb8af8807c

View file

@ -45,24 +45,25 @@ def page_not_found(e):
def wellcomePage(): def wellcomePage():
return app.send_static_file('index.html') return app.send_static_file('index.html')
@app.route('/api/validation/confirm/<string:validation_token>') @app.route('/api/validation/confirm/<string:validation_token>', methods=["GET"])
@auto.doc() @auto.doc()
def confirm_user_to_campus(validation_token): def confirm_user_to_campus(validation_token):
""" """
<span class="card-title">This Function is will Activate a user and add tha campus to it</span> <span class="card-title">This Function is will Activate a user and add tha campus to it</span>
<br> <br>
<b>Route Parameters</b> <b>Route Parameters</b><br>
<ul> - validation_token: 'seToken|email_suffix'
<li> <br>
validation_token: 'seToken|email_suffix' <br>
</li> <b>Payload</b><br>
</ul> - NONE
:return: <br>
<br>
<b>Response</b>
<br>
200 - redirect to home + new cookie 200 - redirect to home + new cookie
<br>
403 - Invalid Token 403 - Invalid Token
<code>main(){
asd = 3
}</code>
""" """
#TODO #TODO
token = str(validation_token).split('|')[0] token = str(validation_token).split('|')[0]
@ -100,7 +101,8 @@ def send_activation(token):
<code>{email: 'academic@email.ac.com'}</code> <code>{email: 'academic@email.ac.com'}</code>
<br> <br>
<br> <br>
<b>Response</b><br> <b>Response</b>
<br>
200 - Email Sent - No Response<br> 200 - Email Sent - No Response<br>
400 - Bad Request<br> 400 - Bad Request<br>
403 - Invalid Token<br> 403 - Invalid Token<br>
@ -143,9 +145,34 @@ def returnHome():
@auto.doc() @auto.doc()
def getUserByToken(token): def getUserByToken(token):
''' '''
param: String - token: users se-Token <span class="card-title">This Function is will Activate a user and add tha campus to it</span>
return: JSON object of the user <br>
if no valid seToken, return message: No User Found <b>Route Parameters</b><br>
- validation_token: 'seToken|email_suffix'
<br>
<br>
<b>Payload</b><br>
- NONE
<br>
<br>
<b>Response</b>
<br>
200 - JSON Example:<br>
<code>
{<br>
'username' : 'github_username',<br>
'name' : 'Bob Dylan',<br>
'email' : 'email@domain.com',<br>
'isLecturer' : true,<br>
'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',<br>
'avatar_url' : 'http://location.domain.com/image.jpg',<br>
'isFirstLogin' : false,<br>
'campuses_id_list': ['22314','243512',...,'356'],<br>
'classes_id_list': ['22314','243512',...,'356']<br>
}
</code>
<br>
403 - Invalid Token
''' '''
query = User.all() query = User.all()
query.filter("seToken = ", token) query.filter("seToken = ", token)
@ -206,15 +233,26 @@ def oauth(oauth_token):
@auto.doc() @auto.doc()
def create_campus(token): def create_campus(token):
""" """
This call will create a new campus in the DB <span class="card-title">This call will create a new campus in the DB</span>
:param token: user seToken <br>
Payload <b>Route Parameters</b><br>
{'title': self.title, - seToken: 'seToken'
'email_ending': self.email_ending, <br>
'avatar_url': self.avatar_url <br>
} <b>Payload</b><br>
:return: - JSON Object, Example: <br>
code 200 {<br>
'title': 'Campus name',<br>
'email_ending': '@campus.ac.com',<br>
'avatar_url': 'http://location.domain.com/image.jpg'<br>
}<br>
<br>
<br>
<b>Response</b>
<br>
201 - Created
<br>
403 - Invalid Token/Forbidden
""" """
print "1\n" print "1\n"
if not request.data: if not request.data:
@ -231,7 +269,6 @@ def create_campus(token):
#todo: check legality #todo: check legality
try: try:
campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url']) campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url'])
except Exception: except Exception:
@ -242,7 +279,7 @@ def create_campus(token):
db.put(campus) db.put(campus)
db.save db.save
return Response(response=json.dumps(campus.to_JSON()), return Response(response=json.dumps(campus.to_JSON()),
status=200, status=201,
mimetype="application/json") mimetype="application/json")
@ -252,25 +289,34 @@ def create_campus(token):
@auto.doc() @auto.doc()
def get_campuses(token): def get_campuses(token):
""" """
This Call will return an array of all Campuses available <span class="card-title">This Call will return an array of all Campuses available</span>
:param token: user seToken <br>
:return: <b>Route Parameters</b><br>
code 200: - seToken: 'seToken'
[ <br>
<br>
<b>Payload</b><br>
- NONE <br>
<br>
<br>
<b>Response</b>
<br>
200 - JSON Array, Example:<br>
[<br>
{ {
'title': 'JCE', 'title': 'JCE',<br>
'email_ending': '@post.jce.ac.il', 'email_ending': '@post.jce.ac.il',<br>
'master_user_id': 123453433341, (User that created the campus) 'master_user_id': 123453433341, (User that created the campus)<br>
'avatar_url': 'http://some.domain.com/imagefile.jpg' 'avatar_url': 'http://some.domain.com/imagefile.jpg'<br>
}, },<br>
.... ....<br>
{ {<br>
... ...<br>
}req }req<br>
] ]<br>
<br>
code 403: Forbidden - Invalid Token 403 - Invalid Token<br>
code 500: internal server error 500 - Server Error
""" """
if is_user_token_valid(token): if is_user_token_valid(token):
arr = [] arr = []