Skip to content

Stocks APIs

Pavan Wadawadagi edited this page Oct 3, 2020 · 2 revisions

APIs for Daily Stocks

Create\Update Stocks

Endpoint: /stocks

HTTP Method: POST

RequestBody

{
	"type": "stock",
	"payload": { 
                   "productCode": "",
                   "stockDate": ""
                   "openingStocks": "",
	           "closingStocks": ""
	         }
}

If there is stock already with same product on same stockDate then it has update same documents else it has to create.

HTTP code: 200

Response Body

{
	"type": "stock",
        "status": "Success",
	"payload": {                  // DailyStock JSON Entity
                   "product": {
                           // Product JSON Entity
                    },
                   "stockDate": ""
                   "openingStocks": "",
	           "closingStocks": "",
                   "totalStocks": "",
                   "createdAt": "",
                   "updatedAt": ""
	}
}

Get All Daily Stocks

Endpoint: /stocks

With Filters: /stocks?productCode=1&packaging=1kg&stockDate=03-10-2020

With Start Date and End Date Filters: /stocks?productCode=1&packaging=1kg&startDate=02-10-2020&endDate=03-10-2020

All query params are optional, and when stockDate is provided then startDate and endDate are ignored

HTTP Method: GET

HTTP Code: 200

Response Body

{
	"type": "stocks",
        "status": "Success",
	"payload": [
		  {           // DailyStock JSON Entity
                   "product": {
                      // Product JSON Entity
                    },
                   "stockDate": ""
                   "openingStocks": "",
	           "closingStocks": "",
                   "totalStocks": "",
                   "createdAt": "",
                   "updatedAt": ""
	         },
		 {},
		 {},
		{}
	]
        "page" : 1,   // Paging information, this might not be required as of now
        "size" : 10,
        "lastPage" : true
}

There will be no error case for this API, only generic 500 internal server error can occur

Clone this wiki locally