Take-Home Tea Project

Turing Backend Engineering Finale

ruby ror Postgres

Description

Rails RESTful Backend API that exposes tea subscription endpoints.

Database Schema

Screen Shot 2023-01-11 at 12 33 49 PM

Create Subscription

POST /create

{
    "customer_id": 6,
    "tea_id": 20,
    "title": "test subscription",
    "price": "12.99",
    "status": "active",
    "frequency": "weekly"
}

Example Response:

{
    "data": {
        "id": 24,
        "type": "Subscription",
        "attributes": {
            "title": "test subscription",
            "price": "12.99",
            "status": "active",
            "frequency": "weekly",
            "customer_id": 6,
            "tea_id": 20
        }
    }
}

Customer Subscriptions

GET '/index'

{
    "customer_id": 6
}

Example Response:

{
    "data": {
        "customer_id": 6,
        "customer_email": "helena_bartoletti@damore.name",
        "type": "Subscription Index",
        "subscriptions": [
            {
                "id": 11,
                "type": "Subscription",
                "attributes": {
                    "status": "cancelled",
                    "frequency": "monthly"
                }
            },
            {
                "id": 12,
                "type": "Subscription",
                "attributes": {
                    "status": "cancelled",
                    "frequency": "monthly"
                }
            },
            {
                "id": 21,
                "type": "Subscription",
                "attributes": {
                    "status": "active",
                    "frequency": "weekly"
                }
            },
            {
                "id": 22,
                "type": "Subscription",
                "attributes": {
                    "status": "active",
                    "frequency": "weekly"
                }
            },
            {
                "id": 23,
                "type": "Subscription",
                "attributes": {
                    "status": "active",
                    "frequency": "weekly"
                }
            },
            {
                "id": 24,
                "type": "Subscription",
                "attributes": {
                    "status": "active",
                    "frequency": "weekly"
                }
            }
        ]
    }
}

Cancel Subscription

PATCH '/update'

{
    "subscription_id": 24,
    "status": "cancelled"
}

Returns Status 204 Updated Successfully