Skip to content

natelee3/interiorize-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interiorize API

The Interiorize API is a RESTful API deployed to serve data to Interiorize(see frontend repo). Several public routes are denoted with * below, but the majority of the routes require a JSON Web Token only available to logged-in users.

View our database schema

Table of Contents
  1. Items Endpoints
    • GET /items*
    • GET /items/byId/:order_id
    • GET /items/single/:item_id*
    • GET /items/items-match
    • GET /items/shop-search
    • POST /items/generate-order
  2. Users Endpoints
    • GET /users
    • GET /users/:user_id
    • POST /users/add
    • POST /users/delete
  3. Avoid Endpoints
    • GET /users/avoid/:user_id
    • GET /users/avoid/string/:user_id
    • POST /users/avoid/add
    • POST /users/avoid/update
  4. Quizzes Endpoints
    • GET /quizzes/:user_id
    • POST /quizzes/add
    • POST /quizzes/update
  5. Orders Endpoints
    • GET /orders
    • GET /orders/:user_id
    • POST /orders/add

BASE URL - https://api.interiorize.design

GET /

Returns text: "Welcome to the Interiorize API!"

ITEMS ENDPOINTS

GET /items

Returns an array of all items in the database

  • id (integer)
  • item_name (string)
  • description (string)
  • img_src (string)
  • price (integer)
  • brand (string)
  • category_name (string)
  • category_id (integer)
  • color_name (string)
  • color_id (integer)
  • tags (string[])
  • tag_ids (integer[])
GET /items/byid/:order_id

params: order_id (integer)

Returns an array of all items that match the input order_id in the orders_items table

  • order_id (integer)
  • item_name (string)
  • description (string)
  • img_src (string)
  • price (integer)
  • brand (string)
GET /items/single/:item_id

Returns one item object with a matching item_id

  • id (integer)
  • item_name (string)
  • description (string)
  • img_src (string)
  • price (integer)
  • brand (string)
  • category_name (string)
  • category_id (integer)
  • color_name (string)
  • color_id (integer)
  • tags (string[])
  • tag_ids (integer[])
GET /items/items-match

body: { user_id: (integer) }

Returns an array of all items matching the quiz/avoid criteria for this user

GET /items/shop-search

Returns an array of items filtered by the checkboxes selected by the user

GET /items/generate-order

body: { user_id: (integer) }

Creates a custom order using the user's saved style quiz results

Back to Top

USERS ENDPOINTS

GET /users

Returns an array of all user objects

  • id: (integer)
  • user_sub: (string) - from Auth0
  • nickname: (string)
  • email: (string)
GET /users/:user_sub

returns one user object

POST /users/add

Adds a new user to the database

body: { user_sub: (string) - from Auth0 but slice off 'auth0|' and insert just the numbers first_name: (string) last_name: (string) email: (string) }

POST /users/delete

body: { user_sub: (string) - from Auth0 but slice off 'auth0|' and insert just the numbers }

Back to Top

AVOID ENDPOINTS

GET /users/avoid/:user_id

params: user_id (integer)

Returns an array of tag_ids that the user has chosen to avoid

GET /users/avoid/string/:user_id

params: user_id (integer)

Returns an array of tag_descriptions (string) that the user has chosen to avoid

POST /users/avoid/add

body: { user_id: (integer), avoid_tags: (integer[]) }

POST /users/avoid/update

body: { user_id: (integer), avoid_tags: (integer[]) }

First deletes exists entries for this user_id in the users_tags table. Then, adds new tags

Back to Top

QUIZZES ENDPOINTS

GET /quizzes/:user_id

params: user_id (integer)

Returns an object containing a user's quiz data

  • user_id: (integer)
  • budget: (integer)
  • colors: (integer[])
  • color1: (string)
  • color2: (string)
  • color3: (string)
  • category_id: (integer)
  • category_name: (integer)
  • style_id: (integer)
  • style_name: (string)
POST /quizzes/add

body: { user_id: (integer), budget: (integer), color_one_id: (integer), color_two_id: (integer), color_three_id: (integer), category_id: (integer), style_id: (integer) }

Adds new quiz data for a user

POST /quizzes/update

body: { user_id: (integer), budget: (integer), color_one_id: (integer), color_two_id: (integer), color_three_id: (integer), category_id: (integer), style_id: (integer) }

Updates all quiz data for a user

Back to Top

ORDERS ENDPOINTS

GET /orders

Returns an array of all order objects in the database

  • order_id: (integer)
  • user_id: (integer)
  • created_data: (timestamp)
  • items: (text[])
GET /orders/:user_id

Returns an array of all orders associated with the input user_id

    orderHistory objects
  • id: (integer) - order_id
  • created_data: (timestamp)
    orderedItems objects
  • order_id: (integer)
  • item_name: (string)
  • description: (string)
  • img_src: (string)
  • price: (integer)
  • brand: (integer)
  • POST /orders/add
    

    body: { user_id: (integer), items: (integer[]) - contains item ids for all items you wish to add to the new order }

    • Creates a new order with timestamp and order_id
    • Adds all items in the items array to that order
    • Add all items in the items array to user inventory
    • Returns the new order_id

    Back to Top

    About

    DigitalCrafts capstone project - RESTful API

    Resources

    Stars

    Watchers

    Forks