From f4c9f3be981e6f2ebfb589d4b02abcac980d6701 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Thu, 2 Jul 2015 17:29:52 +0300 Subject: [PATCH] API: Added getCourseById --- SE_API/CourseRoutes.py | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 500d341..9331a17 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -354,6 +354,51 @@ def getCoursesByUser(token, userId): return Response(response='[]', status=200, mimetype="application/json") + +@course_routes.route('/api/courses/getCoursesById//', methods=['GET']) +@auto.doc() +def getCoursesByID(token, courseId): + """ + This Call will return A Course By ID +
+ Route Parameters
+ - seToken: 'seToken'
+ - courseId: 1234354543
+
+
+ Payload
+ - NONE
+
+
+ Response +
+ 200 - JSON Array, Example:
+ {
+ 'title': 'JCE',
+ 'email_ending': '@post.jce.ac.il',
+ 'master_user_id': 123453433341, (User that created the campus)
+ 'avatar_url': 'http://some.domain.com/imagefile.jpg',
+ 'id' : 1234567890
+ }
+
+ 403 - Invalid Token
+ """ + + user = get_user_by_token(token) + if user is None: + return bad_request("Bad user Token") + + try: + course = Course.get_by_id(int(courseId)) + except Exception as e: + return bad_request("Bad id format") + + if course is None: + return bad_request("Bad Course Id") + + return Response(response=course.to_JSON(), + status=200, + mimetype="application/json") #---------------------------------------------------------- # PUT #----------------------------------------------------------