Courses-System

Required

Ruby 2.6.7
Rails 5.2.6
Postgres 12

setup database

cp config/database.example.yml database.yml
rails db:create && rails db:migrate

addtest data

rails dev:fake_data

API

test user account.

email: test@test.com
password: test12345

login

/api/v1/login

request

curl -d '{"email":"test@test.com", "password":"password"}' -H "Content-Type: application/json" -X POST http://localhost:3000/api/v1/login

response

{
    "auth_token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE2MzQ1MzE4MzR9.B25_fZ8neon0R1b5JIfIaCm6a6E7ew3UUUQvqNek_bM",
    "status": "ok"
}

purchasing course

/api/v1/purchases

request

curl -d '{"course_id": 8}' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE2MzQ1MzQ0NDl9.q5ZeNtBkpml6qVpStrTaJioAQB_91Q1XGaN3vOVnM6g" -X POST http://localhost:3000/api/v1/purchases

response

Purchasing course successfully.

{"message":"Purchasing course successfully","status":"created"}

if without parameters will got below error.

{"error":"course_id is missing"}

view purchased courses

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE2MzQ1MzgwODN9.j41bdRXIIWk8copTBT1f50lEgHeN0hGrEnpCYTKSy8E" -X GET http://localhost:3002/api/v1/purchases?category_id=2&avaiabled=1

Admin

admin@test.com
admin12345
http://localhost:3000/login

courses

http://localhost:3000/admin/
or
http://localhost:3002/admin/courses

create course

http://localhost:3000/admin/courses/new

edit course

http://localhost:3002/admin/courses/[slug]/edit