API ini ditujukan untuk memehuni Technical Test Backend Developer Intern
Untuk menjalankan API ini diperlukan bahasa Go dan MySQL sebagai database
- buat file .env, sesuai dengan .env-example
- jalankan perintah
go run main.go
- creds akun admin :
{
"name": "Admin",
"email": "[email protected]",
"password": "admin123"
}
HTTP METHOD | POST | GET | PUT | DELETE |
---|---|---|---|---|
/users | - | List of User | UpdateUser | - |
/users/<int:id> |
- | Detail of User | - | DeleteUser |
/users/profile | - | GetProfile | - | - |
/user-courses | EnrollCourse | List of UserCourse | - | UnenrollCourse |
/user-courses/<int:id> |
- | Detail of UserCourse | - | - |
/courses | AddCourse | List of Course | - | - |
/courses/<int:id> |
- | Detail of Course | UpdateCourse | DeleteCourse |
/course-categories | AddCategoryCourse | List of CourseCategory | - | - |
/course-categories/<int:id> |
- | Detail of CourseCategory | UpdateCourseCategory | DeleteCourseCategory |
/admins | RegisterAdmin | List of Admin | - | - |
/admins/<int:id> |
- | Detail of Admin | UpdateAdmin | DeleteAdmin |
/login | LoginUser | - | - | - |
/login-admin | LoginAdmin | - | - | - |
/register | RegisterUser | - | - | - |
- Method : POST
- URL :
/login
- Token : -
- Request body :
{
"email": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"token": "string"
}
}
- Method : POST
- URL :
/login-admin
- Token : -
- Request body :
{
"email": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"token": "string"
}
}
- Method : POST
- URL :
/register
- Token : -
- Request body :
{
"email": "string",
"name": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : GET
- URL :
/users
- Token :
adminToken
- Request body : -
- Response body :
{
"message": "OK",
"data": [
{
"id": "int",
"email": "string",
"name": "string"
}
]
}
- Method : GET
- URL :
/users/profile
- Token:
token
- Request body : -
- Response body :
{
"message": "OK",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : GET
- URL :
/users/<int:id>
- Token:
tokenAdmin
- Request body : -
- Response body :
{
"message": "OK",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : PUT
- URL :
/users
- Token :
tokenUser
- Request body :
{
"email": "string",
"name": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : DELETE
- URL :
/users/<id:int>
- Token :
tokenAdmin
- Request body : -
- Response body :
{
"message": "User id `id` was deleted",
"data": {}
}
- Method : GET
- URL :
/courses
- Token :
userToken / adminToken
- Request body : -
- Response body :
{
"message": "OK",
"data": [
{
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
]
}
- Method : GET
- URL :
/courses
- Token :
userToken / adminToken
- Request body : -
- Response body :
{
"message": "OK",
"data": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
- Method : POST
- URL :
/courses/<id:int>
- Token :
adminToken
- Request body :
{
"title": "string",
"course_category_id": "int"
}
- Response body :
{
"message": "OK",
"data": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
- Method : PUT
- URL :
/courses/<id:int>
- Token :
adminToken
- Request body :
{
"title": "string",
"course_category_id": "int"
}
- Response body :
{
"message": "OK",
"data": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
-
Method : DELETE
-
URL :
/courses/<id:int>
-
Token :
adminToken
-
Request body : -
-
Response body :
{
"message": "Course id `id` was deleted",
"data": {}
}
- Method : GET
- URL :
/course-categories
- Token :
userToken / adminToken
- Request body : -
- Response body :
{
"message": "OK",
"data": [
{
"id": "int",
"name": "string"
}
]
}
- Method : GET
- URL :
/course-categories
- Token :
userToken / adminToken
- Request body : -
- Response body :
{
"message": "OK",
"data": [
{
"id": "int",
"name": "string"
}
]
}
- Method : POST
- URL :
/course-categories
- Token :
adminToken
- Request body :
{
"name": "string"
}
- Response body :
{
"message": "OK",
"data": [
{
"id": "int",
"name": "string"
}
]
}
- Method : PUT
- URL :
/course-categories/<id:int>
- Token :
adminToken
- Request body :
{
"name": "string"
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"name": "string"
}
}
-
Method : DELETE
-
URL :
/course-categories/<id:int>
-
Token :
adminToken
-
Request body : -
-
Response body :
{
"message": "Data has been deleted",
"data": {}
}
- Method : GET
- URL :
/user-courses
- Token :
adminToken
- Request body : -
- Response body :
{
"message": "string",
"data": {
"id": "int",
"user_id": "int",
"User": {
"id": "int",
"email": "string",
"name": "string"
},
"course_id": "int",
"Course": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
}
- Method : GET
- URL :
/user-courses
- Token :
adminToken
- Request body : -
- Response body :
{
"message": "string",
"data": {
"id": "int",
"user_id": "int",
"User": {
"id": "int",
"email": "string",
"name": "string"
},
"course_id": "int",
"Course": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
}
- Method : POST
- URL :
/user-courses
- Token :
token / adminToken
- Request body :
{
"user_id": 3,
"course_id": 8
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"user_id": "int",
"User": {
"id": "int",
"email": "string",
"name": "string"
},
"course_id": "int",
"Course": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
}
- Method : DELETE
- URL :
/user-courses
- Token :
token / adminToken
- Request body :
{
"user_id": 3,
"course_id": 8
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"user_id": "int",
"User": {
"id": "int",
"email": "string",
"name": "string"
},
"course_id": "int",
"Course": {
"id": "int",
"title": "string",
"course_category_id": "int",
"course_category": {
"id": "int",
"name": "string"
}
}
}
}
- Method : GET
- URL :
/admins
- Token :
adminToken
- Request body : -
- Response body :
{
"message": "string",
"data": [
{
"id": "int",
"email": "string",
"name": "string"
}
]
}
- Method : GET
- URL :
/admins/<id:int>
- Token :
adminToken
- Request body : -
- Response body :
{
"message": "string",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : POST
- URL :
/admins
- Token :
adminToken
- Request body :
{
"name": "string",
"email": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
- Method : PUT
- URL :
/admins/<id:int>
- Token :
adminToken
- Request body :
{
"name": "string",
"email": "string",
"password": "string"
}
- Response body :
{
"message": "string",
"data": {
"id": "int",
"email": "string",
"name": "string"
}
}
-
Method : DELETE
-
URL :
/admins/<id:int>
-
Token :
adminToken
-
Request body : -
-
Response body :
{
"message": "Admin id `id` was deleted",
"data": {}
}
- Yulyano Thomas Djaya - 56419764