This is a backend API application that stores data for a tea subscription service with three endpoints allowing a frontend team to access data needed to display to a user. The three endpoints included area GET
request for all subscriptions associated with a customer (both active and canceled), a POST
request to create a new subscription for a customer, and a DELETE
request to cancel a customer's subscriptions.
- Fork and Clone the repo
- Run
bundle install
- Set up your database with
rails db:{drop,create,migrate,seed}
- Make sure all tests are passing by running
bundle exec rspec
(there should be 26 passing tests) - Start up your local server by running
rails s
- See below for endpoints to send requests and for response examples
Response
{
"data": [
{
"id": "1",
"type": "subscription",
"attributes": {
"title": "Green Tea Subscription",
"price": "15.00",
"status": "Active",
"frequency": "Monthly",
"customer_id": 1,
"tea_id": 1
}
},
{
"id": "2",
"type": "subscription",
"attributes": {
"title": "Black Tea Subscription",
"price": "20.00",
"status": "Active",
"frequency": "Weekly",
"customer_id": 1,
"tea_id": 2
}
},
{
"id": "5",
"type": "subscription",
"attributes": {
"title": "Sweet Tea Subscription",
"price": "10.00",
"status": "Cancelled",
"frequency": "Weekly",
"customer_id": 1,
"tea_id": 3
}
}
]
}
Parameters
Name | Description |
---|---|
customer_id, integer | The id of a current customer |
tea_id, integer | The id of a current tea |
title, string | The title of the subscription service |
price, string | The price of the subscription |
status, string | The current status of the subscriptions |
frequency, string | How often the subscription is sent |
Example
{
'customer_id': "#{customer.id}",
'tea_id': "#{tea.id}",
'title': 'Tea Subscription',
'price': '15.00',
'status': 'Active',
'frequency': 'Monthly'
}
Response
{
"data": {
"id": "5",
"type": "subscription",
"attributes": {
"title": "Sweet Tea Subscription",
"price": "10.00",
"status": "Active",
"frequency": "Weekly",
"customer_id": 1,
"tea_id": 3
}
}
}
Response
{
"data": {
"id": "5",
"type": "subscription",
"attributes": {
"title": "Sweet Tea Subscription",
"price": "10.00",
"status": "Cancelled",
"frequency": "Weekly",
"customer_id": 1,
"tea_id": 3
}
}
}