Implemented course/{id} API
This commit is contained in:
parent
1e456059cb
commit
ca3c119adb
1 changed files with 9 additions and 1 deletions
|
@ -40,6 +40,14 @@ class TitamaApi {
|
|||
return _courses;
|
||||
}
|
||||
|
||||
|
||||
@ApiMethod(path: 'course/{id}')
|
||||
Course getCourse(int id) {
|
||||
for (Course course in _courses) {
|
||||
if (course.id == id) {
|
||||
return course;
|
||||
}
|
||||
}
|
||||
throw new NotFoundError('Could not find course \'$id\'.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue