Lmcourt / tea_subscription_api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tea Subscription API

This is a REST API for a tea subscription service to:

  • View a customer's active and cancelled subscriptions
  • Create a tea subscription for a customer
  • Cancel a subscription

Primary Technologies

  • Ruby 2.7.2
  • Rails 5.2.6
  • PostgreSQL

Local Set-Up

Fork and clone this repository to your local machine then

bundle install

rails db:{create,migrate,seed}

Testing

Testing is done with RSpec with coverage details provided by SimpleCov.

Test Suite Execution

bundle exec rspec

Database Design

database_schema

Endpoints

GET /api/v1/customers/:customer_id/subscriptions

Response:

{
    "id": "10",
    "type": "subscription",
    "attributes": {
        "id": 10,
        "title": "est",
        "price": 8,
        "status": "cancelled",
        "frequency": "Monthly"
    }
},
{
    "id": "11",
    "type": "subscription",
    "attributes": {
        "id": 11,
        "title": "commodi",
        "price": 13,
        "status": "active",
        "frequency": "Bi-monthly"
    }
}

POST /api/v1/customers/:customer_id/subscriptions

With the required body:

{
  "title": "Lovely tea",
  "price": 5,
  "status": "active",
  "frequency": "Monthly",
  "customer_id": 1,
  "tea_id": 1
  }

Response:

{
  "title": "Lovely tea",
  "price": 5,
  "status": "active",
  "frequency": "Monthly",
  "customer_id": 1,
  "tea_id": 1
  }

PATCH /api/v1/customers/:customer_id/subscriptions/:id With the required body:

{
  "status": "cancelled"
}

Response:

{
    "id": "11",
    "type": "subscription",
    "attributes": {
        "id": 11,
        "title": "commodi",
        "price": 13,
        "status": "active",
        "frequency": "Bi-monthly"
    }
}

Contributors

Laura Court

About


Languages

Language:Ruby 99.3%Language:HTML 0.7%