Skip to content

EmreSoner/ysapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YS Order Service API

Instruction

docker-compose build
docker-compose run web python manage.py migrate

Dummy data(Restaurant, Product, User etc.). The command creates fixture data.

docker-compose run web python manage.py load_fixture

Running Tests

docker-compose run web python manage.py test

Running API and depended services

docker-compose up

API Doc

https://0.0.0.0:8000/

Order data can be created via interact tool in the doc.

API URL

https://0.0.0.0:8000/api/v1/

API Service Usage

Order can be created by using user and restaurant ids from fixture.

import coreapi

client = coreapi.Client()
schema = client.get("https://0.0.0.0:8000/")

action = ["orders", "create"]
params = {
    "user": 1,
    "restaurant": 1,
    "orderitem_set": [
	    {"product": 1, "quantity": 3}, 
	    {"product": 2, "quantity": 5}
	]
}

result = client.action(schema, action, params=params)

To process or cancel the order manually;

import coreapi

client = coreapi.Client()
schema = client.get("https://0.0.0.0:8000/")

action = ["orders", "process"]
params = {
    "id": 1,
    "status": "COMPLETED|REJECTED",
}
result = client.action(schema, action, params=params)

This action normally running from celery-beat by using order process service per 2 minutes for waiting orders. It can be reviewed on ysapi/celery.py file to configuration.

About

YSAPI Order Service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published