JoannaCoPo / tea-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tea Time

Image
via GIPHY

A Rails API for a fictional Tea Subscription Service.

Created in an 8-hour time frame for a take-home challenge; find the project spec here.

Framework

Languages

Testing

Tools

Local Setup

  1. Fork and Clone the repo
  2. Install gem packages: bundle install
  3. Set up the database: rails db:{drop,create,migrate,seed}

-----------------------------------------------------

Endpoints

Create a tea subscription for a customer

Method URI Description
POST /api/v1/customers/:customer_id/subsricptions Creates a customer subscription in the database and returns the subscription attributes
Example:
{
    "data": {
        "id": "9",
        "type": "subscription",
        "attributes": {
            "title": "Sun Moon Lake",
            "price": 24.99,
            "status": "active",
            "frequency": "biannually",
            "customer_id": 5,
            "tea_id": 5
        }
    }
}

Cancel a customer’s tea subscription

Method URI Description
PATCH /api/v1//customers/:customer_id/subscriptions/:id Cancels a customer subscription in the database and returns subscription attributes with the updated status
Example:
{
    "data": {
        "id": "8",
        "type": "subscription",
        "attributes": {
            "title": "Sun Moon Lake",
            "price": 24.99,
            "status": "cancelled",
            "frequency": "biannually",
            "customer_id": 5,
            "tea_id": 5
        }
    }
}

View all of a customer’s subsciptions, of active and cancelled status

Method URI Description
GET /api/v1//customers/:customer_id/subscriptions Returns all tea subscriptions for a given customer
Example:
{
    "data": [
        {
            "id": "10",
            "type": "subscription",
            "attributes": {
                "title": "Sun Moon Lake",
                "price": 24.99,
                "status": "active",
                "frequency": "monthly",
                "customer_id": 1,
                "tea_id": 5
            }
        },
        {
            "id": "13",
            "type": "subscription",
            "attributes": {
                "title": "Black Tea Mix",
                "price": 24.99,
                "status": "active",
                "frequency": "biweekly",
                "customer_id": 1,
                "tea_id": 4
            }
        },
        {
            "id": "14",
            "type": "subscription",
            "attributes": {
                "title": "Incredibly Delicious Tea",
                "price": 24.99,
                "status": "active",
                "frequency": "biweekly",
                "customer_id": 1,
                "tea_id": 4
            }
        }
    ]
}

Project Configurations

  • Ruby Version

    $ ruby -v
    ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
  • System Dependencies

    $ rails -v
    Rails 6.1.4
  • Database Creation

    $ rails db:{drop,create,migrate,seed}
    Created database 'tea_time_development'
    Created database 'tea_time_test'
  • How to run the test suite:

    $ bundle exec rspec -fd
  • Local Deployment, for testing:

    $ rails s
    => Booting Puma
    => Rails 5.2.6 application starting in development
    => Run `rails server -h` for more startup options
    Puma starting in single mode...
    * Version 3.12.6 (ruby 2.7.2-p137), codename: Llamas in Pajamas
    * Min threads: 5, max threads: 5
    * Environment: development
    * Listening on tcp://localhost:3000
    Use Ctrl-C to stop

About


Languages

Language:Ruby 99.5%Language:HTML 0.5%