Git Product home page Git Product logo

zb's Introduction

ZB Test - Alejandro Olaria


Description


This project was built as part of a test, it is a simple API made for storing products and its attributes, it expects to have two different types of users, admins & anonymous.


Build


  1. Clone this Project
  2. cd to zb_test
  3. run docker-compose up --build

Test


  • Run unit tests:
    1. cd to zb_test
    2. run: docker-compose exec zb_web python manage.py test .
  • Using postman:
    1. cd to zb_test/utils/postman
    2. import those files to your postman

Login


(POST) requests JWT

Url: /login/

payload:

{
    "username": string,
    "password": string
}

response (200):

{
    "id": integer,
    "username": string,
    "access": string,
    "refresh": string
}

Products


(POST) creates product instance

Url: /products/

payload:

{
    "name": string,
    "price": float,
    "brand": string
}

parameters:

  • name: product's name

  • price: product's price

  • brand: product's brand name


response (201):

{
    "sku": string,
    "price": float,
    "name": string,
    "brand": {
        "name": string
    }
}

(GET) retrieve product instance

Url: /products/{SKU}/details

parameters:

SKU: alphanumeric product's SKU


response (200)

{
    "sku": string,
    "price": float,
    "name": string,
    "brand": {
        "name": string
    },
    "watch_record": integer
}

watch_record: how many times an anonymous user retrieve that product


(PUT) updates product instance

Url: /products/{SKU}

payload:

{
    "name": string,
    "price": float,
    "brand": string
}

parameters:

  • SKU: alphanumeric product's SKU

  • name: product's name (OPTIONAL)

  • price: product's price (OPTIONAL)

  • brand: product's brand name (OPTIONAL)


response (204)


(DELETE) deletes product instance

Url: /products/{SKU}

parameters:

  • SKU: alphanumeric product's SKU

Admins:


(POST) creates "admin" instance

Url: /admins/

payload:

{
    "username": string,
    "password": float,
    "email": string
}

response (200):

{
    "id": integer,
    "username": string
}

(PUT) updates "admin" instance

Url: /admins/{ID}/

payload:

{
    "username": string (optional),
    "password": float (optional),
    "email": string (optional)
}

parameters:

  • ID: Admin's ID

response (204)


(DELETE) deletes "admin" instance

Url: /admins/{ID}/

parameters:

  • ID: Admin's ID

response (204)


made with ❤️ by Alejandro Olaria.

zb's People

Contributors

aolaria avatar

Watchers

 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.