About
Tea Time is a tea subscription service that has teas, customers, and subscriptions. This application has endpoints to create a tea subscription, cancel a tea subscription, and see all of a customers tea subscriptions!
Images
Schema
End Points
An endpoint to subscribe a customer to a tea subscription
- POST http://localhost:3000/api/v1/customers/:id/subscriptions
- enum status: [:active, :cancelled]
- 0 = “active”
- 1 = “cancelled”
- enum frequency: [:weekly, :biweekly, :monthly, :bimonthly]
- 0 = “weekly”
- 1 = “biweekly”
- 2 = “monthly”
- 3 = “bimonthly”
- Example Request and Required Params:
- http://localhost:3000/api/v1/customers/1/subscriptions
params: { "title": "Bob's Peppermint Subscription", "price": 12.00, "frequency": 0, "customer_id": 1, "tea_id": 1 }
- Example Response:
{ "data": { "id": "1", "type": "subscription", "attributes": { "id": 1, "title": "Bob's Peppermint Subscription", "price": 10.0, "status": "active", "frequency": "monthly", "customer_id": 1, "tea_id": 1 } } }
An endpoint to cancel a customer’s tea subscription
- PATCH http://localhost:3000/api/v1/customers/:id/subscriptions/:id
- Example Request:
- http://localhost:3000/api/v1/customers/1/subscriptions/1
- Example Response:
{ "data": { "id": "1", "type": "subscription", "attributes": { "id": 1, "title": "Bob's Peppermint Subscription", "price": 12.0, "status": "cancelled", "frequency": "weekly", "customer_id": 1, "tea_id": 1 } } }
An endpoint to see all of a customer’s subsciptions (active and cancelled)
- GET http://localhost:3000/api/v1/customers/:id/subscriptions
- Example Request:
- http://localhost:3000/api/v1/customers/1/subscriptions
- Example Response:
{ "data": [ { "id": "1", "type": "subscription", "attributes": { "id": 1, "title": "Bob's Peppermint Subscription", "price": 12.0, "status": "cancelled", "frequency": "weekly", "customer_id": 1, "tea_id": 1 } }, { "id": "2", "type": "subscription", "attributes": { "id": 2, "title": "Robs Black Tea Subscription", "price": 10.0, "status": "active", "frequency": "monthly", "customer_id": 1, "tea_id": 1 } } ] }