reference: Project Specs and Overview
Table of Contents
- Ruby 2.7.2
- Rails 5.2.7
-
Testing: rspec-rails, simplecov, factory_bot_rails, faker, shoulda-matchers
-
API: jsonapi-serializer, figaro, faraday
-
Linting: rubocop
On your local system, open a terminal session to run the following commands:
- Clone this repository
$ git clone [email protected]:jbreit88/tea_time.git
- Navigate to the newly cloned directory
$ cd tea_time
- If bundler is not installed onm your local machine run
$ gem install bundler
- If or after bundler is installed run
$ bundle install
to install the required Gems - If errors occur, check for proper installation and versions of
bundler
,ruby
, andrails
- Set up the database locally with
$ rails db:{:drop,:create,:migrate,:seed}
- Open your text editor and check to see that
schema.rb
exists - You may also run the RSpec test suite locally with the command
$ bundle exec rspec
to ensure everything is functioning as expected.
This is a back-end project designed to implement the skills necessary to build and expose an API for a front-end team to consume.
http verb | name | description | example |
---|---|---|---|
POST | /customers | Returns newly created customer as JSON object. If customer already exists, returns existing customer. | /customers?first_name=Meredith&last_name=otwaldG&email=[email protected]&address=1234 Merry Gotty St. Boulder CO 80304 |
JSON response example
Create Customer:
{
"data": {
"id": "2",
"type": "customer",
"attributes": {
"first_name": "Meredith",
"last_name": "Gotwald",
"email": "[email protected]",
"address": "1234 Merry Gotty St. Boulder CO 80304"
}
}
}
http verb | name | description | example |
---|---|---|---|
GET | /customers/:id | Returns customer info and associated subscriptions as JSON object. | /customers/1 |
JSON response example
Show Customer:
{
"data": {
"id": "1",
"type": "customer_and_subscriptions",
"attributes": {
"first_name": "Mel",
"last_name": "Gibson",
"email": "[email protected]",
"address": "1234 Hollywood St., Los Angeles, CA, 11111",
"subscriptions": [
{
"id": 1,
"title": "Jasmine Galore",
"price": 1500,
"status": "cancelled",
"frequency": "weekly",
"customer_id": 1,
"tea_id": 1,
"created_at": "2022-04-19T17:11:40.734Z",
"updated_at": "2022-04-19T19:59:27.638Z"
},
{
"id": 2,
"title": "Jasmine Galore",
"price": 1500,
"status": "active",
"frequency": "weekly",
"customer_id": 1,
"tea_id": 1,
"created_at": "2022-04-19T17:18:40.329Z",
"updated_at": "2022-04-19T17:18:40.329Z"
},
{
"id": 3,
"title": "Jasmine Galore",
"price": 1500,
"status": "active",
"frequency": "weekly",
"customer_id": 1,
"tea_id": 1,
"created_at": "2022-04-19T17:19:27.973Z",
"updated_at": "2022-04-19T17:19:27.973Z"
}
]
}
}
}
http verb | name | description | example |
---|---|---|---|
POST | /teas | Returns newly created tea as JSON object. If tea already exists, returns existing tea. | /teas?title=Jasmine&description=A very fine tea&temperature=120&brew_time=180 |
JSON response example
Create Tea:
{
"data": {
"id": "2",
"type": "tea",
"attributes": {
"title": "Jasmine",
"description": "A very fine tea",
"temperature": 120,
"brew_time": 180
}
}
}
http verb | name | description | example |
---|---|---|---|
POST | /subscriptions | Returns newly created subscription, customer info, and tea info as JSON object. | /subscriptions?title=Jasmine Galore&price=1500&customer_id=1&tea_id=1&frequency=weekly |
JSON response example
Create Subscription:
{
"data": {
"id": "3",
"type": "subscription",
"attributes": {
"title": "Jasmine Galore",
"price": 1500,
"status": "active",
"frequency": "weekly",
"customer": {
"id": 1,
"first_name": "Mel",
"last_name": "Gibson",
"email": "[email protected]",
"address": "1234 Hollywood St., Los Angeles, CA, 11111",
"created_at": "2022-04-18T22:28:04.415Z",
"updated_at": "2022-04-18T22:28:04.415Z"
},
"tea": {
"id": 1,
"title": "Earl Grey",
"description": "This tea is delicious. Full of caffeine. Good for waking up in the morning.",
"temperature": 180,
"brew_time": 180,
"created_at": "2022-04-18T22:28:04.424Z",
"updated_at": "2022-04-18T22:28:04.424Z"
}
}
}
}
http verb | name | description | example |
---|---|---|---|
PATCH | /subscriptions | Returns updated subscription info as JSON object. | /subscriptions?id=1&status=cancelled |
- Note: You can use this endpoint to update any attributes for a Subscription as outlined in the database schema. Simply add them as params after the subscription ID (IE:
?id=1&title=Changed Title&price=1399@frequency=monthly
)
JSON response example
Update Subscription:
{
"data": {
"id": "1",
"type": "subscription",
"attributes": {
"title": "Jasmine Galore",
"price": 1500,
"status": "cancelled",
"frequency": "weekly",
"customer": {
"id": 1,
"first_name": "Mel",
"last_name": "Gibson",
"email": "[email protected]",
"address": "1234 Hollywood St., Los Angeles, CA, 11111",
"created_at": "2022-04-18T22:28:04.415Z",
"updated_at": "2022-04-18T22:28:04.415Z"
},
"tea": {
"id": 1,
"title": "Earl Grey",
"description": "This tea is delicious. Full of caffeine. Good for waking up in the morning.",
"temperature": 180,
"brew_time": 180,
"created_at": "2022-04-18T22:28:04.424Z",
"updated_at": "2022-04-18T22:28:04.424Z"
}
}
}
}
Please feel free to checkout my profiles: