Apptegy plans to offer its school users a gift delivery service. The gifts will be school-branded and sent to members of the school community through a dedicated section on Thrillshare, our core product. Apptegy will create the item in-house and send it out for delivery. All the user has to do within Thrillshare is essentially choose the gift, select the recipient(s), and confirm the order.
Things you need installed:
- Ruby version,
2.7.2
- Rails version,
6.0.3
Postgresql
installed
- Clone this repo:
git clone git@github.com:Mildred14/thrillshare.git
- Install dependencies
bundle install
- Create and migrate the database
rails db:create
rails db:migrate
-
Run server
rails s
orrails server
-
Then open your browser and look into this url
http://localhost:3000/
-
Or you can use the application deployed in Heroku as a host Thrillshare in Heroku!
If everything works you'll see a message like this Yay! You’re on Rails!
This endpoint creates a user which can access the schools, recipients and orders endpoints.
Request
POST - http://localhost:3000/api/v1/signup
or https://thrillshare.herokuapp.com/api/v1/signup
Body
{
"user": {
"email": "some@email.com",
"password": "somepassword"
}
}
This endpoint will return an Authorization
header which will be used to authenticate the user in the rest of endpoints.
Request
POST - http://localhost:3000/api/v1/login
Body
{
"user": {
"email": "some@email.com",
"password": "somepassword"
}
}
Note: The response header will return the Authorization
with a Bearer
token. This must be set in all requests to authenticate the user by the API
Request
GET - http://localhost:3000/api/v1/schools
Request
POST - http://localhost:3000/api/v1/schools
Body
{
"school": {
"name": "Univesidad de Colima",
"address": "Av Universidad 123"
}
}
Request
PUT/PATCH - http://localhost:3000/api/v1/schools/1
Body
{
"school": {
"name": "Tecnologico de Colima"
}
}
Request
DELETE - http://localhost:3000/api/v1/schools/1
Request
GET - http://localhost:3000/api/v1/schools/1/recipients
Request
POST - http://localhost:3000/api/v1/schools/1/recipients
Body
{
"recipient": {
"name": "Mildred Nataly Silva",
"address": "Av Hidalgo 345"
}
}
Request
PUT/PATCH - http://localhost:3000/api/v1/schools/1/recipients/1
Body
{
"recipient": {
"address": "Av Morelos"
}
}
Request
DELETE - http://localhost:3000/api/v1/schools/1/recipients/1
Request
GET - http://localhost:3000/api/v1/schools/1/orders
Request
POST - http://localhost:3000/api/v1/schools/1/orders
Body
- You can only add this gift options: "mug", "t-shirt", "sticker" or "hoodie"
{
"order": {
"recipient_ids": ["1"],
"gifts": ["mug"],
"notify_delivery": true,
}
}
Request
PUT/PATCH - http://localhost:3000/api/v1/schools/1/orders/1
Body
{
"order": {
"gifts": ["hoodie", "t-shirt"]
}
}
An order can only transition to cancelled
if it was previously in a processing
status.
Request
POST - http://localhost:3000/api/v1/schools/1/orders/1/cancel
An order can only transition to shipped
if it was previously in a processing
status.
Request
POST - http://localhost:3000/api/v1/schools/1/orders/1/ship
An order can only transition to received
if it was previously shipped
.
Request
POST - http://localhost:3000/api/v1/schools/1/orders/1/receive