Giter Club home page Giter Club logo

tea_time-1's Introduction

Mod4 Solo Project: Tea Time

reference: Project Specs and Overview

Table of Contents
  1. Getting Started
  2. Available Endpoints and Examples
  3. Built By

Getting Started

Versions

  • Ruby 2.7.2
  • Rails 5.2.7

Dependencies


Set Up

On your local system, open a terminal session to run the following commands:

  1. Clone this repository $ git clone [email protected]:jbreit88/tea_time.git
  2. Navigate to the newly cloned directory $ cd tea_time
  3. If bundler is not installed onm your local machine run $ gem install bundler
  4. If or after bundler is installed run $ bundle install to install the required Gems
  5. If errors occur, check for proper installation and versions of bundler, ruby, and rails
  6. Set up the database locally with $ rails db:{:drop,:create,:migrate,:seed}
  7. Open your text editor and check to see that schema.rb exists
  8. You may also run the RSpec test suite locally with the command $ bundle exec rspec to ensure everything is functioning as expected.

Project Description

This is a back-end project designed to implement the skills necessary to build and expose an API for a front-end team to consume.

Screen Shot 2022-04-18 at 1 33 03 PM


Available Endpoints and Examples

Run in Postman

Create Customer

http verb name description example
POST /customers Returns newly created customer as JSON object. If customer already exists, returns existing customer. /customers?first_name=Meredith&last_name=otwaldG&email=[email protected]&address=1234 Merry Gotty St. Boulder CO 80304
JSON response example

Create Customer:

  {
    "data": {
        "id": "2",
        "type": "customer",
        "attributes": {
            "first_name": "Meredith",
            "last_name": "Gotwald",
            "email": "[email protected]",
            "address": "1234 Merry Gotty St. Boulder CO 80304"
        }
    }
}

Show Customer

http verb name description example
GET /customers/:id Returns customer info and associated subscriptions as JSON object. /customers/1
JSON response example

Show Customer:

 {
    "data": {
        "id": "1",
        "type": "customer_and_subscriptions",
        "attributes": {
            "first_name": "Mel",
            "last_name": "Gibson",
            "email": "[email protected]",
            "address": "1234 Hollywood St., Los Angeles, CA, 11111",
            "subscriptions": [
                {
                    "id": 1,
                    "title": "Jasmine Galore",
                    "price": 1500,
                    "status": "cancelled",
                    "frequency": "weekly",
                    "customer_id": 1,
                    "tea_id": 1,
                    "created_at": "2022-04-19T17:11:40.734Z",
                    "updated_at": "2022-04-19T19:59:27.638Z"
                },
                {
                    "id": 2,
                    "title": "Jasmine Galore",
                    "price": 1500,
                    "status": "active",
                    "frequency": "weekly",
                    "customer_id": 1,
                    "tea_id": 1,
                    "created_at": "2022-04-19T17:18:40.329Z",
                    "updated_at": "2022-04-19T17:18:40.329Z"
                },
                {
                    "id": 3,
                    "title": "Jasmine Galore",
                    "price": 1500,
                    "status": "active",
                    "frequency": "weekly",
                    "customer_id": 1,
                    "tea_id": 1,
                    "created_at": "2022-04-19T17:19:27.973Z",
                    "updated_at": "2022-04-19T17:19:27.973Z"
                }
            ]
        }
    }
}

Create Tea

http verb name description example
POST /teas Returns newly created tea as JSON object. If tea already exists, returns existing tea. /teas?title=Jasmine&description=A very fine tea&temperature=120&brew_time=180
JSON response example

Create Tea:

  {
    "data": {
        "id": "2",
        "type": "tea",
        "attributes": {
            "title": "Jasmine",
            "description": "A very fine tea",
            "temperature": 120,
            "brew_time": 180
        }
    }
}

Create Subscription

http verb name description example
POST /subscriptions Returns newly created subscription, customer info, and tea info as JSON object. /subscriptions?title=Jasmine Galore&price=1500&customer_id=1&tea_id=1&frequency=weekly
JSON response example

Create Subscription:

{
    "data": {
        "id": "3",
        "type": "subscription",
        "attributes": {
            "title": "Jasmine Galore",
            "price": 1500,
            "status": "active",
            "frequency": "weekly",
            "customer": {
                "id": 1,
                "first_name": "Mel",
                "last_name": "Gibson",
                "email": "[email protected]",
                "address": "1234 Hollywood St., Los Angeles, CA, 11111",
                "created_at": "2022-04-18T22:28:04.415Z",
                "updated_at": "2022-04-18T22:28:04.415Z"
            },
            "tea": {
                "id": 1,
                "title": "Earl Grey",
                "description": "This tea is delicious. Full of caffeine. Good for waking up in the morning.",
                "temperature": 180,
                "brew_time": 180,
                "created_at": "2022-04-18T22:28:04.424Z",
                "updated_at": "2022-04-18T22:28:04.424Z"
            }
        }
    }
}

Update Subscription

http verb name description example
PATCH /subscriptions Returns updated subscription info as JSON object. /subscriptions?id=1&status=cancelled
  • Note: You can use this endpoint to update any attributes for a Subscription as outlined in the database schema. Simply add them as params after the subscription ID (IE: ?id=1&title=Changed Title&price=1399@frequency=monthly)
JSON response example

Update Subscription:

{
    "data": {
        "id": "1",
        "type": "subscription",
        "attributes": {
            "title": "Jasmine Galore",
            "price": 1500,
            "status": "cancelled",
            "frequency": "weekly",
            "customer": {
                "id": 1,
                "first_name": "Mel",
                "last_name": "Gibson",
                "email": "[email protected]",
                "address": "1234 Hollywood St., Los Angeles, CA, 11111",
                "created_at": "2022-04-18T22:28:04.415Z",
                "updated_at": "2022-04-18T22:28:04.415Z"
            },
            "tea": {
                "id": 1,
                "title": "Earl Grey",
                "description": "This tea is delicious. Full of caffeine. Good for waking up in the morning.",
                "temperature": 180,
                "brew_time": 180,
                "created_at": "2022-04-18T22:28:04.424Z",
                "updated_at": "2022-04-18T22:28:04.424Z"
            }
        }
    }
}

Built By: Brad Breiten

Please feel free to checkout my profiles:

tea_time-1's People

Contributors

jbreit88 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.