Tea Subscription

Table of Contents

Description

Tea Subscription is a backend API service which simulates endpoints for a tea subscription service. It was created to satisfy the requirements for a Mod 4 take-home project at the Turing School of Software and Design. Project requirements can be found here.

Technical Details

This application is built with Ruby on Rails and tested with RSpec. API endpoint data is returned in json.

Getting Started

Local Installation

  1. Clone the repo
git clone git@github.com:dlayton66/tea_subscription.git
  1. Install gems
bundle install
  1. Create database and run migrations
rails db:{create,migrate}
  1. Run rails server
rails server
  1. Call the endpoints from your favorite API platform (e.g. Postman)

Endpoints

  1. Create customer subscription
POST http://localhost:3000/api/v1/customers/:customer_id/subscriptions

Example params:
{
  tea_id: 1,
  price: 10.00,
  frequency: 14
}
  1. Get customer subscriptions
GET http://localhost:3000/api/v1/customers/:customer_id/subscriptions

Example response:
{
    "data": [
        {
            "id": "1",
            "type": "subscription",
            "attributes": {
                "price": "15.0",
                "frequency": 7,
                "status": "cancelled",
                "tea": "Black"
            }
        },
        {
            "id": "2",
            "type": "subscription",
            "attributes": {
                "price": "8.0",
                "frequency": 14,
                "status": "cancelled",
                "tea": "Green"
            }
        }
    ]
}
  1. Cancel customer subscription
PATCH http://localhost:3000/api/v1/customers/:customer_id/subscriptions/:subscription_id?status=cancelled

RSpec Suite

Run the entire spec suite

bundle exec rspec

All tests should be passing.

Schema

Screenshot 2023-04-13 at 9 14 20 PM

Authors & Acknowledgments

👤 Drew Layton