Tea Time is an API application that tracks Teas, Customers, and Customer Subscriptions to Teas, allowing customers to recieve subscriptions to teas at different frequencies.
This is a Ruby on Rails application which establishes API endpoints. To run the application locally, clone the application and you will be able to call endpoints after this setup:
To install gems, run:
bundle install
Then to establish a database, run:
rails db:create
Because this is the back end repository, database migration is also necessary, run:
rails db:migrate
Inspect the /db/schema.rb
and compare to the 'Schema' section below to ensure this migration has been done successfully.
Once tea-time
is correctly installed, run tests locally to ensure the repository works as intended.
To test the entire spec suite, run:
bundle exec rspec
All tests should be passing if installation is successful.
- APIs can be called locally using a program like Postman.
Note: Necessary parameters marked with {}
Note: pass first_name
, last_name
, address
, & email
in request body
POST '/api/v1/customers'
Response:
{
"data":
{
"id":"CUSTOMER_ID",
"type":"customer",
"attributes":
{
"first_name":"CUSTOMER_FIRST_NAME",
"last_name":"CUSTOMER_LAST_NAME",
"email":"CUSTOMER_EMAIL",
"address":"CUSTOMER_ADDRESS"
}
}
}
Note: pass title
, description
, temperature
, & brew_time
in request body
POST '/api/v1/teas'
Response:
{
"data":
{
"id":"TEA_ID",
"type":"tea",
"attributes":
{
"title":"TEA_TITLE",
"description":"TEA_DESCRIPTION",
"temperature":"TEA_TEMPERATURE",
"brew_time":"TEA_BREW_TIME"
}
}
}
Note: pass title
, price
, frequency
, customer_id
, & tea_id
in request body
Note: status
will automatically be set to active
, if this subscription is not active, please specify status: inactive
in request body
Note: frequency
is weeks between deliveries, and temperature
is in degrees Fahrenheit
POST '/api/v1/subscriptions'
Response:
{
"data":
{
"id":"SUBSCRIPTION_ID",
"type":"subscription",
"attributes":
{
"title":"SUBSCRIPTION_TITLE",
"price":"SUBSCRIPTION_PRICE",
"status":"SUBSCRIPTION_STATUS",
"frequency":"SUBSCRIPTION_FREQUENCY"
"customer_id":"SUBSCRIPTION_CUSTOMER_ID"
"tea_id":"SUBSCRIPTION_TEA_ID"
}
}
}
Note: pass status
in request body
PATCH '/api/v1/subscriptions/{SUBSCRIPTION_ID}'
Response:
{
"data":
{
"id":"SUBSCRIPTION_ID",
"type":"subscription",
"attributes":
{
"title":"SUBSCRIPTION_TITLE",
"price":"SUBSCRIPTION_PRICE",
"status":"SUBSCRIPTION_STATUS",
"frequency":"SUBSCRIPTION_FREQUENCY"
"customer_id":"SUBSCRIPTION_CUSTOMER_ID"
"tea_id":"SUBSCRIPTION_TEA_ID"
}
}
}
GET '/api/v1/customers/{customer_id}/subscriptions'
Response:
{
"data":
[{
"id":"SUBSCRIPTION_ID",
"type":"subscription",
"attributes":
{
"title":"SUBSCRIPTION_TITLE",
"price":"SUBSCRIPTION_PRICE",
"status":"SUBSCRIPTION_STATUS",
"frequency":"SUBSCRIPTION_FREQUENCY"
"customer_id":"SUBSCRIPTION_CUSTOMER_ID"
"tea_id":"SUBSCRIPTION_TEA_ID"
},
},
...
]
}
Tea Time was produced to satisfy the requirements of the Turing School of Software and Design's Module 4 Solo Project, Take Home. See official project requirements.
- A strong understanding of Rails
- Ability to create restful routes
- Demonstration of well-organized code, following OOP
- Test Driven Development
- Clear documentation
👤 Samuel Cox