fond-of-oryx / stock-product-api
The StockProductApi module provides a REST API for simple product stock updates.
1.0.0.beta.1
2023-03-20 07:43 UTC
Requires
- php: >=8.0
- spryker/api: ^0.4.0
- spryker/api-extension: ^0.1.0
- spryker/api-query-builder: ^0.1
- spryker/stock: ^8.0.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-27 13:03:09 UTC
README
The StockProductApi module provides a REST API for simple product stock updates.
Package ported from fond-of-spryker/stock-api
Installation
composer require fond-of-oryx/stock-product-api
Register Plugins in ApiDependencyProvider
/**
* @return \Spryker\Zed\Api\Dependency\Plugin\ApiResourcePluginInterface[]
*/
protected function getApiResourcePluginCollection(): array
{
return [
...
new StockProductApiResourcePlugin(),
];
}
/**
* @return \Spryker\Zed\Api\Dependency\Plugin\ApiValidatorPluginInterface[]
*/
protected function getApiValidatorPluginCollection(): array
{
return [
...
new StockProductApiValidatorPlugin(),
];
}
API
Update stock of a concrete product. sku
, stock_type
, and quantity
are mandatory fields.
PATCH /api/rest/stock-products/{id_stock_product}
Example
curl -X PATCH "http://zed.yourdomain.com/api/rest/stock-products/{id_stock_product}" \ -H 'Content-Type: application/json' \ -d $'{ "data": { "sku": "SKU", "stock_type": "EU", "quantity": 10, "is_never_out_of_stock": true } }'
Create stock of a concrete product. sku
, stock_type
, and quantity
are mandatory fields.
POST /api/rest/stock-products
Example
curl -X POST "http://zed.yourdomain.com/api/rest/stock-products" \ -H 'Content-Type: application/json' \ -d $'{ "data": { "sku": "SKU", "stock_type": "EU", "quantity": 10, "is_never_out_of_stock": true } }'
Find stock concrete product by sku
and stock_type
(name)
GET /api/rest/stock-products?filter={"condition":"AND","rules":[{"id":"name","field":"name","type":"string","input":"text","operator":"equal","value":"EU"},{"id":"sku","field":"sku","type":"string","input":"text","operator":"equal","value":"SKU"}]}
Example
curl -X GET "http://zed.yourdomain.com/api/rest/stock-products?filter=$'{"condition":"AND","rules":[{"id":"name","field":"name","type":"string","input":"text","operator":"equal","value":"EU"},{"id":"sku","field":"sku","type":"string","input":"text","operator":"equal","value":"SKU"}]}'" \ -H 'Content-Type: application/json'
Get stock product by idStockProduct
GET /api/rest/stock-products/{id_stock_product}
Example
curl -X GET "http://zed.yourdomain.com/api/rest/stock-products/{id_stock_product}" \ -H 'Content-Type: application/json'