Table of Contents
Tea Subscriptions API is a practice take home exam, done over a 4 day period with approximately 6 hours of work put into it. It is a subscription service where a customer can see their subscriptions, add subscriptions and delete old subscriptions for a tea shipment service. It uses the Tea-API for gathering data on tea that is available for purchasing subscriptions. The goal with this aspect was to simulate a vendor which sources their tea from a wholesale supplier with a changing rotation of tea.
| Framework / Languages | Testing / Debugging | Methodology | Other Gems |
|---|---|---|---|
In order to run this application locally, you will need:
- rails 5.2.6
- ruby 2.7.2
- PostgreSQL
- Clone the repo
git clone https://github.com/AlexKlick/tea_subs_api.git - Change directory
cd tea_subs_api - Install gems
bundle install - Create local DB
rails db:create rails db:migrate - Seed Database to have some users
rails db:seed - Running Locally
rails s - Running Tests
bundle exec rspec
| HTTP Verb | Endpoint | Type | Description | JSON Output |
|---|---|---|---|---|
| GET | /api/v1/customers/:customer_id/tea_subscriptions | tea_subscriptions index | return all tea subscriptions for a given customer | Link |
| POST | /api/v1/customers/:customer_id/tea_subscriptions | tea_subscriptions create | create a new subscription for a customer | Link |
| PUT / PATCH | /api/v1/customers/:customer_id/tea_subscriptions/:id | tea_subscriptions update | cancel a tea subscription for a customer | Link |
GET http://localhost:3000/api/v1/customers/1/tea_subscriptions
{
"data": [
{
"id": "5",
"type": "TeaSubscription",
"attributes": {
"title": "chamomileeverymonthly",
"price": 10.99,
"status": "active",
"frequency": "monthly"
},
"relationships": {
"customer": {
"data": {
"id": "1",
"type": "Customer"
}
}
}
}
]
}
POST http://localhost:3000/api/v1/customers/1/tea_subscriptions?frequency=monthly&price=10.99
Status: 201 Created
Status: 202 Accepted
this updates the GET request to:
{
"data": [
{
"id": "5",
"type": "TeaSubscription",
"attributes": {
"title": "chamomileeverymonthly",
"price": 10.99,
"status": "deactivated",
"frequency": "monthly"
},
"relationships": {
"customer": {
"data": {
"id": "1",
"type": "Customer"
}
}
}
}
]
}
To complete this project, I used the Tea API, created by Victoria Lo!