GithubHelp home page GithubHelp logo

mini-shopping-api's Introduction

Shopping API

A part of a mini shopping app.

Installation

Windows

Python 3.8+ must be installed.

Navigate to project folder in CLI, and use

pip install -r requirements.txt

Run the service by typing

python app.py

Docker

Build the project using

docker build -t [tagname] .

Run the service using

docker run -p 5000:[port] [tagname]

where [port] could be 5000. In that case, the service will be available on //localhost:5000

Models

Product

[*] title: str
    description: str
[*] price: int
    currency: str

Cart

[*] orders: [Order]
    total: float

Order

    amount: int
[*] product_id: int

*: required

Endpoints

Create product

POST /product

Input:

Product

Example:

{
    "title": "Computeractic",
    "description": "didactic",
    "price": "17",
    "currency": "USD"
}

Response:

200 OK

product_id: int

Get product

GET /product/:id

Parameters

id: int

Response:

product_id: int
title: str
description: str
price: float
currency: str
stock: int

Get all products

GET /product

Response:

200 OK

products: [Product]

Delete product

DELETE /product/:id

Parameters

id: int

Create Cart

POST /cart

Input:

Cart

Response:

200 OK

cart_id: int
total: float

Get Cart

GET /cart/:id

Parameters

id: int

Add Order to Cart

POST /cart/:id/add

Rules:
- Every fifth item free
- Maximum 100 usd total
- Discount of 1 usd above 20

Rule violation results in Error (see Error_msg for details).

Parameters

id: int

Input:

Order

Results:

204 OK

[No Body]

400 Error

{"Error": Error_msg}

Get Orders per Cart

POST /cart/:id/orders

Parameters

id: int

mini-shopping-api's People

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.