This is a REST API for a tea subscription service to:
- View a customer's active and cancelled subscriptions
- Create a tea subscription for a customer
- Cancel a subscription
- Ruby 2.7.2
- Rails 5.2.6
- PostgreSQL
Fork and clone this repository to your local machine then
bundle install
rails db:{create,migrate,seed}
Testing is done with RSpec with coverage details provided by SimpleCov.
bundle exec rspec
GET /api/v1/customers/:customer_id/subscriptions
Response:
{
"id": "10",
"type": "subscription",
"attributes": {
"id": 10,
"title": "est",
"price": 8,
"status": "cancelled",
"frequency": "Monthly"
}
},
{
"id": "11",
"type": "subscription",
"attributes": {
"id": 11,
"title": "commodi",
"price": 13,
"status": "active",
"frequency": "Bi-monthly"
}
}
POST /api/v1/customers/:customer_id/subscriptions
With the required body:
{
"title": "Lovely tea",
"price": 5,
"status": "active",
"frequency": "Monthly",
"customer_id": 1,
"tea_id": 1
}
Response:
{
"title": "Lovely tea",
"price": 5,
"status": "active",
"frequency": "Monthly",
"customer_id": 1,
"tea_id": 1
}
PATCH /api/v1/customers/:customer_id/subscriptions/:id
With the required body:
{
"status": "cancelled"
}
Response:
{
"id": "11",
"type": "subscription",
"attributes": {
"id": 11,
"title": "commodi",
"price": 13,
"status": "active",
"frequency": "Bi-monthly"
}
}
Laura Court