Backend API for the Medi-Book health appointment platform
This app uses a Rails back-end as an API to send doctor details and appointment data to the frontend for scheduling appointments
- Ruby
- Ruby on Rails
- PostgreSQL
- Heroku
- Rspec
- Rswag
To get a local copy up and running follow these simple example steps. In your terminal, navigate to your current directory and run this code
git clone https://github.com/medi-book/medibook-api
Then run:
cd medibook-api
Open in your preferred text editor. Run code .
to open VScode.
This guide assumes you have already installed the necessary dependencies to use a postgreSQL database and Ruby on Rails.
- Add all ruby gems to your Gemfile (
bundle install
) - Create a .env file in the root of your project and add the following lines:
PASSWORD_DB = your_password
- Run
rails db:create db:migrate db:seed
to create the database and run migrations.
- Run
rails s
to start the server. - To create a new user, send a POST request to
http://localhost:3000/signup
with the following body:
{
"user": {
"username": "John Doe",
"password": "password",
"password_confirmation": "password"
}
}
- To create an admin user use the rails console and run:
User.create(username: "admin", password: "password", password_confirmation: "password", role: "admin")
- To login, send a POST request to
http://localhost:3000/authenticate
with the following body:
{
"user": {
"username": "John Doe",
"password": "password"
}
}
Response: The token would be used in the Authorization header for all subsequent requests.
{
"username": "John Doe",
"token" : "token",
"role": "regular"
}
- To create a new appointment, send a POST request to
http://localhost:3000/appointments
with the following body:
{
"appointment": {
"doctor_id": 1,
"date": "2023-01-01 00:00:00",
"duration": 5,
}
}
headers:
{
"Authorization": "token"
}
Response:
{
"message": "appointment added",
"status": "created",
}
- To get all appointments, send a GET request to
http://localhost:3000/appointments
with the following headers:
{
"Authorization": "token"
}
Response:
{
[
{
"id": 1,
"name": "John Doe",
"total": "000",
"duration": 5,
"date": "2023-01-01 00:00:00",
},
{
"id": 2,
"name": "John Doe",
"total": "000",
"duration": 5,
"date": "2023-01-01 00:00:00",
}
]
}
- To cancel an appointment, send a DELETE request to
http://localhost:3000/appointments/1
with the following headers:
{
"Authorization": "token"
}
Response:
{
"message": "appointment deleted",
"status": "ok"
}
- To get all doctors, send a GET request to
http://localhost:3000/doctors
with the following headers:
{
"Authorization": "token"
}
Response:
{
[
{
"id": 1,
"name": "John Doe",
"specialization": "specialty",
"hourly_rate": "$$",
"picture": "image.png",
"created_at": "created_at",
"updated_at": "updated_at"
},
{
"id": 2,
"name": "John Doe",
"specialization": "specialty",
"hourly_rate": "$$",
"picture": "image.png",
"created_at": "created_at",
"updated_at": "updated_at"
}
]
}
Run migrations for test database: rails db:migrate RAILS_ENV=test
rspec spec/models
rspec spec/requests
👤 Sodiq Aderibigbe
- GitHub: @deyemiobaa
- Twitter: @deyemiobaa
- LinkedIn: Sodiq Aderibigbe
👤 Anicet Murhula
- GitHub: @AnicetFantomas
- Twitter: @FantomasAnicet
- LinkedIn: Anicet Murhula
👤 Ifza Rasool
- GitHub: [@ifzarasool](https://github.com/IfzaRasool
- Twitter: @ifzaarain
- LinkedIn: [@ifza-arain]https://www.linkedin.com/in/ifza-arain/
👤 Oybek Kayumov
- GitHub: @OybekKayumov
- Twitter: @KayumovOybek
- LinkedIn: Oybek Kayumov
👤 Saningo Lekalantula
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
This project is MIT licensed.