Skip to content

aolaria/zb

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published