/Bangazon-API

Bangazon-corp's employees, products and users database

Primary LanguageJavaScript

Bangazon API

This is Bangazon Corp.'s employees, products and users API. Users of the API can GET/POST/PUT/DELETE information to and from the database for selected categories.

Table of Contents

  1. Software Requirements
  2. Installation
  3. Get Started
  4. Helper Applications
  5. Usage Directions
  6. Third Party Libraries
  7. Credits
  8. Contribute to the API

Software Requirements

Installation

  • to clone the project down, run git clone [repo link]
  • run npm install from the root of the directory to install all of the dependencies

Get Started

  • set up the database using npm run db:reset command in terminal
  • if you wish to set a custom port number, create your own .env file at the root of the project using the .env.example file as a guide
  • run nodemon app.js from the terminal

Helper Applications

Usage directions

  • go to api/v1/ to view route and method layout, see additional details below

Enitity Relationship Diagram

Bangazon API ERD

Http Request Methods

  • GET - will let you retrieve all the data or a specific data depending on the url

    • route: api/v1/orders - get all orders
    • route: api/v1/orders/1 - get single order with order_id 1
  • POST - will let you add data to the tables

    • you can use postman to do a POST at the given url
    • you will need to use the example body given for each table
    • route: api/v1/orders - post an order
  • PUT - will let you edit a specific chunk of data

    • you can use postman to do a PUT at given url
    • you will need to use the keys from example body for all the fields you would like to edit
    • route: api/v1/orders/1 - edit order with order_id = 1
  • DELETE - will let you delete a specific chunk of data

    • you can use postman to DELETE at given url
    • route: api/v1/orders/1 - deletes order with order_id = 1

    NOTE: Each Table's DELETE works differently depending on the entity relationships and dependencies. See specific table for detailed delete functionality.

Employees

http methods supported: GET, POST, PUT example body:

{
	"id": "INT: include on PUT only",
	"department_id": "INT",
	"first_name": "TEXT: NOT NULL",
	"last_name": "TEXT: NOT NULL",
	"phone_number": "TEXT",
	"job_title": "TEXT",
	"street_address": "TEXT",
	"city_address": "TEXT",
	"state_code": "TEXT",
	"zip_code": "INT"
}

Departments

http methods supported: GET, POST, PUT example body:

{
	"id": "INT: include on PUT only",
	"supervisor_employee_id": "INT",
	"expense_budget": "INT: NOT NULL",
	"name": "TEXT: NOT NULL"
}

Computers

http methods supported: GET, POST, PUT, DELETE

NOTE: deleting a computer will delete the associated entry on the employeeComputer join table example body:

{
	"id": "INT: on put only",
	"purchase_date": "TEXT NOT NULL",
	"decommission_date": "TEXT",
	"serial_number": "TEXT NOT NULL"
}

Training-Programs

http methods supported: GET, POST, PUT, DELETE

NOTE: deleting a training program will delete the associated entry on the employeeTraining join table example body:

{
	"id": "INT: include on PUT only",
	"start_date": "TEXT",
	"end_date": "TEXT",
	"max_attendance": "INT",
	"title": "TEXT"
}

Users

http methods supported: GET, POST, PUT example body:

{
	"id": "INT: put only",
	"first_name": "TEXT",
	"last_name": "TEXT",
	"account_created_date": "TEXT NOT NULL",
	"last_login_date": "TEXT NOT NULL",
	"street_address": "TEXT",
	"city_address": "TEXT",
	"state_code": "TEXT",
	"zip_code": "TEXT"
}

Product Types

http methods supported: GET, POST, PUT, DELETE NOTE: you cannot delete a product type if there are products associated with that product type example body:

{
	"id": "INT: PUT only",
	"name": "TEXT"
}

Products

http methods supported: GET, POST, PUT, DELETE

NOTE: deleting a product will delete the associated entry on the orderProduct join table example body:

{
	"id": "INT: PUT only",
	"product_type_id": "INTEGER",
	"price": "REAL",
	"title": "TEXT",
	"description": "TEXT",
	"original_quantity": "INTEGER",
	"seller_user_id": "INTEGER"
}

Orders

http methods supported: GET, POST, PUT, DELETE

NOTE: deleting an order will delete the associated entry/entries on the orderProduct join table example body:

{
"id": "INT",
"product_id": "INT: required for POST",
"quantity": "INT: optional for POST/PUT, defaults to 1",
"customer_user_id": "INTEGER: required for PUT/POST",
"payment_type_id": "INTEGER: completes order",
"order_date": "TEXT: only include on payment update/order finalize",
"Products": "GET only - an array of products on order"
}

Payment Types

http methods supported: GET, POST, PUT, DELETE

NOTE: you cannot delete a payment type if there are orders associated with that payment type example body:

{
	"id": "INT: PUT only",
	"customer_user_id": "INTEGER",
	"type": "TEXT",
	"account_number": "INTEGER"
}

Inactive Customers

http methods supported: GET route: api/v1/users/?active=false

Third Party Libraries

Credits

Project Manager

API Developers

Contribute to API

  • fork - issue tickets and pull requests are welcome
  • use airbnb style
  • follow the template for PR requests
  • tab size 2

© 2017 Delicate-Butterflys