This repository is a Rails API for a Tea Subscription Service that satisfies the following requirements:
An endpoint to subscribe a customer to a tea subscription An endpoint to cancel a customer’s tea subscription An endpoint to see all of a customer’s subsciptions (active and cancelled)
Project specifications can be found here.
- Fork and clone this repository
cd
into the root directiorybundle install
rails db:{drop,create,migrate,seed}
- Run the test suite with
bundle exec rspec
- Start the local server by running
rails s
- Visit the app on
http://127.0.0.1:3000
in your web browser
POST /api/v1/customers/:customer_id/teas/:tea_id/subscriptions
Details
Parameters:
{
"frequency": string,
"price": integer
}
Code | Description |
---|---|
201 | CREATED |
Example Value:
{
"data": {
"id": "4",
"type": "subscription",
"attributes": {
"price": 10,
"status": "active",
"frequency": "monthly"
}
}
}
PATCH /api/v1/subscriptions/:id
Details
Parameters:
none
Code | Description |
---|---|
200 | OK |
Example Value:
{
"data": {
"id": "1",
"type": "subscription",
"attributes": {
"price": 10,
"status": "inactive",
"frequency": "monthly"
}
}
}
GET /api/v1/customers/:id/subscriptions
Details
Parameters:
none
Code | Description |
---|---|
200 | OK |
Example Value:
{
"data": [
{
"id": "1",
"type": "subscription",
"attributes": {
"price": 10,
"status": "inactive",
"frequency": "monthly"
}
},
{
"id": "2",
"type": "subscription",
"attributes": {
"price": 10,
"status": "active",
"frequency": "monthly"
}
},
{
"id": "3",
"type": "subscription",
"attributes": {
"price": 10,
"status": "active",
"frequency": "monthly"
}
},
{etc},
{etc}
]
}
Onyva returns the following status codes in its API:
Status Code | Description |
---|---|
200 | OK |
201 | CREATED |
400 | BAD REQUEST |
404 | NOT FOUND |
500 | INTERNAL SERVER ERROR |