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

This package is auto-updated.

Last update: 2024-10-27 12:47:27 UTC


README

license

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'