Skip to content

optoro/quality_inventory

Repository files navigation

README


Heroku

https://quality-inventory.herokuapp.com

Setup

Ruby version

ruby-2.5.5

Configuration

bundle install

Database creation

bundle exec rake db:create
bundle exec rake db:migrate

Database initialization

bundle exec rake db:seed

How to run the test suite

bundle exec rspec

Deployment instructions

bundle exec rails s

Database Tables

Product Table

Product Table
- has many Units

Fields:
title - required; must not be blank
manufacturer - required; must not be blank

Unit Table

Unit Table
- belongs to Product

Fields:
product_id - required; must exist
status - required; either "active" or "inactive"
condition - required; either "new" or "used"
price_cents - must be greater than 0

API

Products

GET /products

[
    {
        "id": 1,
        "title": "Synergistic Iron Watch",
        "manufacturer": "Wolff and Sons"
    },
    {
        "id": 2,
        "title": "fake titles",
        "manufacturer": "fake manufacturers"
    }
]

200 OK

GET /products/:id

{
    "id": 1,
    "title": "Synergistic Iron Watch",
    "manufacturer": "Wolff and Sons"
}

200 OK

GET /products/:id/units

{
    "id": 1,
    "title": "Synergistic Iron Watch",
    "manufacturer": "Wolff and Sons",
    "units": [
        {
            "id": 1,
            "status": "active",
            "condition": "new",
            "price_cents": 999,
            "product_id": 1
        },
        {
            "id": 2,
            "status": "inactive",
            "condition": "used",
            "price_cents": 899,
            "product_id": 1
        }
    ]
}

200 OK

POST /products

HEADERS Content-Type: application/json
REQUEST BODY
{
    "title": "fake title",
    "manufacturer": "fake manufacturer"
}

201 Created

PUT /products/:id

HEADERS Content-Type: application/json
REQUEST BODY
{
    "title": "fake title",
    "manufacturer": "fake manufacturer"
}

200 OK

Units

GET /units

[
    {
        "id": 1,
        "status": "active",
        "condition": "new",
        "price_cents": 999,
        "product_id": 1
    },
    {
        "id": 2,
        "status": "inactive",
        "condition": "used",
        "price_cents": 899,
        "product_id": 1
    }
]

200 OK

POST /units

HEADERS Content-Type: application/json
REQUEST BODY
{
    "id": 1,
    "status": "active",
    "condition": "new",
    "price_cents": 999,
    "product_id": 1
}

201 Created

About

QE Applicant Take Home Test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published