Coder Social home page Coder Social logo

tea_subscription_service's Introduction

Tea Subscription Service

forthebadge forthebadge

Summary

This repository is a Rails API for a Tea Subscription Service that satisfies the following requirements:

An endpoint to subscribe a customer to a tea subscription An endpoint to cancel a customer’s tea subscription An endpoint to see all of a customer’s subsciptions (active and cancelled)

Project specifications can be found here.

Installation

  1. Fork and clone this repository
  2. cd into the root directiory
  3. bundle install
  4. rails db:{drop,create,migrate,seed}
  5. Run the test suite with bundle exec rspec
  6. Start the local server by running rails s
  7. Visit the app on http://127.0.0.1:3000 in your web browser

RESTful Endpoints

Subscribe a customer to a tea subscription

POST /api/v1/customers/:customer_id/teas/:tea_id/subscriptions
Details

Parameters:

{
    "frequency": string,
    "price": integer
}
Code Description
201 CREATED

Example Value:

{
    "data": {
        "id": "4",
        "type": "subscription",
        "attributes": {
            "price": 10,
            "status": "active",
            "frequency": "monthly"
        }
    }
}

Cancel a customer’s tea subscription

PATCH /api/v1/subscriptions/:id
Details

Parameters:

none
Code Description
200 OK

Example Value:

{
    "data": {
        "id": "1",
        "type": "subscription",
        "attributes": {
            "price": 10,
            "status": "inactive",
            "frequency": "monthly"
        }
    }
}

View all of a customer’s subsciptions (active and cancelled)

GET /api/v1/customers/:id/subscriptions
Details

Parameters:

none
Code Description
200 OK

Example Value:

{
    "data": [
        {
            "id": "1",
            "type": "subscription",
            "attributes": {
                "price": 10,
                "status": "inactive",
                "frequency": "monthly"
            }
        },
        {
            "id": "2",
            "type": "subscription",
            "attributes": {
                "price": 10,
                "status": "active",
                "frequency": "monthly"
            }
        },
        {
            "id": "3",
            "type": "subscription",
            "attributes": {
                "price": 10,
                "status": "active",
                "frequency": "monthly"
            }
        },
        {etc},
        {etc}
    ]
}

Status Codes

Onyva returns the following status codes in its API:

Status Code Description
200 OK
201 CREATED
400 BAD REQUEST
404 NOT FOUND
500 INTERNAL SERVER ERROR

Schema Design

Screen Shot 2023-04-21 at 10 10 18 AM

tea_subscription_service's People

Contributors

kaylahrose avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.