Created in an 8-hour time frame for a take-home challenge; find the project spec here.
- Fork and Clone the repo
- Install gem packages:
bundle install
- Set up the database:
rails db:{drop,create,migrate,seed}
Method | URI | Description |
---|---|---|
POST |
/api/v1/customers/:customer_id/subscriptions |
Creates a customer subscription in the database and returns the subscription attributes |
{
"data": {
"id": "9",
"type": "subscription",
"attributes": {
"title": "Kick In The Chest",
"price": 24.99,
"status": "active",
"frequency": "biannually",
"customer_id": 5,
"tea_id": 5
}
}
}
Method | URI | Description |
---|---|---|
PATCH |
/api/v1//customers/:customer_id/subscriptions/:id |
Cancels a customer subscription in the database and returns subscription attributes with the updated status |
{
"data": {
"id": "8",
"type": "subscription",
"attributes": {
"title": "Kick In The Chest",
"price": 24.99,
"status": "cancelled",
"frequency": "biannually",
"customer_id": 5,
"tea_id": 5
}
}
}
Method | URI | Description |
---|---|---|
GET |
/api/v1//customers/:customer_id/subscriptions |
Returns all tea subscriptions for a given customer |
{
"data": [
{
"id": "10",
"type": "subscription",
"attributes": {
"title": "Kick In The Chest",
"price": 24.99,
"status": "active",
"frequency": "monthly",
"customer_id": 1,
"tea_id": 5
}
},
{
"id": "13",
"type": "subscription",
"attributes": {
"title": "Send Covid Packin",
"price": 24.99,
"status": "active",
"frequency": "biweekly",
"customer_id": 1,
"tea_id": 4
}
},
{
"id": "14",
"type": "subscription",
"attributes": {
"title": "Pass The Heck Out",
"price": 24.99,
"status": "active",
"frequency": "biweekly",
"customer_id": 1,
"tea_id": 4
}
}
]
}
-
Ruby Version
$ ruby -v ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
-
[System Dependencies]
$ rails -v Rails 5.7.2
-
Database Creation
$ rails db:{drop,create,migrate,seed} Created database 'tea_time_development' Created database 'tea_time_test'
-
How to run the test suite:
$ bundle exec rspec
-
Local Deployment, for testing:
$ rails s => Booting Puma => Rails 5.2.6 application starting in development => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.6 (ruby 2.7.2-p137), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop