git clone
cd lunch_and_learn
ruby -v
The ouput should start with something like ruby 2.7.2
If not, install the correct ruby version using rbenv:
rbenv install 2.7.2
Using Bundler
bundle install
rails db:{drop,create,migrate,seed}
bundle exec rspec
rails s
You should now be able to hit the API endpoints using Postman or a similar tool.
Default host is http://localhost:3000
- Request
POST /api/v1/customers
Content-Type: application/json
Accept: application/json
{
"first_name": "Ahsoka",
"last_name": "Tano",
"email": "[email protected]",
"address": "Jedi Temple, Coruscant"
}
- Response
{
"data": {
"id": "1",
"type": "customer",
"attributes": {
"first_name": "Ahsoka",
"last_name": "Tano",
"email": "[email protected]",
"address": "Jedi Temple, Coruscant"
}
}
}
- Request
POST /api/v1/customers/1/subscription
Content-Type: application/json
Accept: application/json
{
"title": "Ashwagandha",
"price": 20,
"status": "active",
"tea_id": 3
}
- Response
{
"data": {
"id": "3",
"type": "subscription",
"attributes": {
"title": "Ashwagandha",
"status": "active",
"price": 20,
"customer_id": 1,
"tea_id": 3
}
}
}
- Request
GET /api/v1/customers/1/subscriptions/7/?update=cancelled
Content-Type: application/json
Accept: application/json
- Response
{
"data": {
"id": "3",
"type": "subscription",
"attributes": {
"title": "Ashwagandha",
"status": "cancelled",
"price": 20,
"customer_id": 1,
"tea_id": 3
}
}
}
- Request
GET /api/v1/customers/1/subscriptions
Content-Type: application/json
Accept: application/json
- Response
{
"data": [
{
"id": "1",
"type": "subscription",
"attributes": {
"title": "Yerba Mate Blend",
"status": "active",
"price": 15,
"customer_id": 2,
"tea_id": 1
}
},
{
"id": "2",
"type": "subscription",
"attributes": {
"title": "Green Tea",
"status": "active",
"price": 17,
"customer_id": 2,
"tea_id": 2
}
},
{
"id": "3",
"type": "subscription",
"attributes": {
"title": "Ashwagandha",
"status": "cancelled",
"price": 20,
"customer_id": 2,
"tea_id": 3
}
}
]
}