Skip to content

AlexKlick/tea_subs_api

Repository files navigation

Tea Subscription API

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Queries
  5. JSON Output
  6. Acknowldgementst

About The Project

Tea Subscriptions API is a practice take home exam, done over a 4 day period with approximately 6 hours of work put into it. It is a subscription service where a customer can see their subscriptions, add subscriptions and delete old subscriptions for a tea shipment service. It uses the Tea-API for gathering data on tea that is available for purchasing subscriptions. The goal with this aspect was to simulate a vendor which sources their tea from a wholesale supplier with a changing rotation of tea.

Built With

Framework / Languages Testing / Debugging Methodology Other Gems
RubyOnRails

Getting Started

Prerequisites

In order to run this application locally, you will need:

Usage

  1. Clone the repo
    git clone https://github.com/AlexKlick/tea_subs_api.git
    
  2. Change directory
    cd tea_subs_api
    
  3. Install gems
    bundle install
    
  4. Create local DB
    rails db:create
    rails db:migrate
    
  5. Seed Database to have some users
     rails db:seed
    
  6. Running Locally
     rails s 
    
  7. Running Tests
     bundle exec rspec
    

Queries

HTTP Verb Endpoint Type Description JSON Output
GET /api/v1/customers/:customer_id/tea_subscriptions tea_subscriptions index return all tea subscriptions for a given customer Link
POST /api/v1/customers/:customer_id/tea_subscriptions tea_subscriptions create create a new subscription for a customer Link
PUT / PATCH /api/v1/customers/:customer_id/tea_subscriptions/:id tea_subscriptions update cancel a tea subscription for a customer Link

JSON Output

Tea Subscriptions Index

GET http://localhost:3000/api/v1/customers/1/tea_subscriptions

{
    "data": [
        {
            "id": "5",
            "type": "TeaSubscription",
            "attributes": {
                "title": "chamomileeverymonthly",
                "price": 10.99,
                "status": "active",
                "frequency": "monthly"
            },
            "relationships": {
                "customer": {
                    "data": {
                        "id": "1",
                        "type": "Customer"
                    }
                }
            }
        }
    ]
}

Create Subscription

POST http://localhost:3000/api/v1/customers/1/tea_subscriptions?frequency=monthly&price=10.99

  Status: 201 Created

Cancel Subscription

  Status: 202 Accepted
  
  this updates the GET request to:
  {
    "data": [
        {
            "id": "5",
            "type": "TeaSubscription",
            "attributes": {
                "title": "chamomileeverymonthly",
                "price": 10.99,
                "status": "deactivated",
                "frequency": "monthly"
            },
            "relationships": {
                "customer": {
                    "data": {
                        "id": "1",
                        "type": "Customer"
                    }
                }
            }
        }
    ]
}
  

Acknowledgements

To complete this project, I used the Tea API, created by Victoria Lo!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors