willjw2 / take_home_2208

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Endpoints

Get Customer Subscriptions

Request:

GET /api/v1/customer/#{customer_id}/subscriptions

JSON Response Example:

{
    "data": [
        {
            "id": "7",
            "type": "subscription",
            "attributes": {
                "customer_id": 7,
                "tea_id": 10,
                "price": 5.99,
                "frequency_monthly": 5,
                "cancelled": true
            }
        },
        {
            "id": "8",
            "type": "subscription",
            "attributes": {
                "customer_id": 7,
                "tea_id": 11,
                "price": 2.5,
                "frequency_monthly": 10,
                "cancelled": false
            }
        },
        {...},
        {...},
    ]
}
Cancel Subscription

Request:

DELETE /api/v1/customer/#{customer_id}/subscriptions/#{subscription_id}

JSON Response Example:

{
    "message": "The subscription was successfully cancelled"
}
Create Subscription

Request:

POST /api/v1/customer/#{customer_id}/subscriptions

Request Body Example:

{
  "tea_id": 2,
  "price": 5.99,
  "frequency_monthly": 2
}

JSON Response Example:

{
  "data":
      {
          "id": "7",
          "type": "subscription",
          "attributes": {
              "customer_id": 7,
              "tea_id": 2,
              "price": 5.99,
              "frequency_monthly": 2,
              "cancelled": false
          }
      }
}

Schema

Screenshot 2023-03-03 at 4 55 15 AM

About


Languages

Language:Ruby 99.4%Language:HTML 0.6%