# Price and stock

## Update Stock

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/stock/updatestock`

Post must be made with a data arrangement containing the SKU and the associated Stock. This function will upload the data to Ventiapp and the platform will be responsible for updating all the channels where its publications are active. Up to 50 SKUs per call is supported.

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 Stock actualizado correctamente" %}

```javascript
[{
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Stock update requested"
     "sku": "33QH-QQ1",
     "quantity":50
 },{
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Stock update requested",
     "sku": "33QH-QQ2",
     "quantity":55
 }]
```

{% endtab %}
{% endtabs %}

Body parameters

```javascript
[
  {
    "sku": "34HHB-QQ1",
    "quantity": 50
  },
  {
    "sku": "34HHB-QQ2",
    "quantity": 55
  }
]
```

## Update Price

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/stock/updateprice`

Post must be made with a data arrangement containing the SKU and the associated Price. This function will upload the data to VentiApp and the platform will be responsible for updating all the channels where its publications are active. Up to 50 SKUs per call is supported.

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 Precio actualizado correctamente" %}

```javascript
[{
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Price update requested"
     "sku": "33QH-QQ1",
     "price":199.99
 },{
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Price update requested",
     "sku": "33QH-QQ2",
     "price":299.99
 }]
```

{% endtab %}
{% endtabs %}

Body parameters

```javascript
[
  {
    "sku": "34HHB-QQ1",
    "price":199.99
  },
  {
    "sku": "34HHB-QQ2",
    "price": 299.99
  }
]
```

## Update Price Stock By Channel

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/stock/updatepricestockbychannel`

This function can be used to update stock and price differentiated by channel, these fields can be optional, it is not mandatory to send both. The required field is that of the channel. This call is limited to one SKU's simultaneously.

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200
El campo sites indica si hubo alguna falla en ese canal en particular" %}

```javascript
{
    "sites": "",
    "result": "success",
    "msg": "Se ha actualizado el stock Correctamente"
}
```

{% endtab %}
{% endtabs %}

Body parameters

```javascript
{
        "sku": "34HHB-QQ1",
        "channelData": [{
                "channel": "mercadolibre",
                "quantity": 40,
                "price": 155.40,
                "availableDays":2
            },
            {
                "channel": "linio",
                "quantity":20,
            },{
                "channel": "prestashop",
                "quantity": 40,
                "price": 140.40
            }
        ]
}
```

Channels allowed

* MercadoLibre (mercadolibre)
* Linio (linio)
* Shopify (shopify)
* Claroshop (claroshop)
* Amazon (amazon)
* Walmart (walmart)
* Mercadoshops (mercadoshops)
* WooCommerce (woocommerce)
* Magento (magento)
* Walmart (walmart)
* Wish (wish)

#### Update 1.0.7

Field **availableDays** is added to indicate the availability in days of the product (This only applies to Mercado Libre as soon as they release their API)

## Get Price Stock By Channel

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/stock/getpricestockbychannel/{sku}/`

This function can be used to obtain the stock and price differentiated by channel. Simply replace the SKU of the url with the desired one. If the SKU uses characters like dots or commas, it is recommended to put the bar at the end of the query string

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 Respuesta de ejemplo" %}

```javascript
        "sku": "34HHB-QQ1",
        "channelData": [{
                "channel": "mercadolibre",
                "account_name" : "TEST1234",
                "account_id" : "555199293",
                "quantity": 40,
                "price": 155.40,
                "salePrice": null,   
            },
            {
                "channel": "mercadolibre",
                "account_name" : "TEST5678",
                "account_id" : "86818382",
                "quantity": 40,
                "price": 155.40,
                "salePrice": null,   
            },
            {
                "channel": "linio",
                "quantity":20,
                "price": 179.40,
                "salePrice": 156.2,   
            },{
                "channel": "prestashop",
                "quantity": 40,
                "price": 140.40,
                "salePrice": null
            }
        ]
}
```

{% endtab %}
{% endtabs %}

## Update Price By ErpId

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/stock/updatepricebyerpid`

This function works similar to Update Price but requires the ERP ID. This function should only be invoked if you have a custom integration of Ventiapp with your ERP.

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```javascript
[{
   "33QH-QQ1": {
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Price updated successfully"
   }
 }, {
   "33QH-QQ2": {
     "sites": "mercadoshops: OK, mercadolibre: OK",
     "status": "success",
     "msg": "Price updated successfully"
   }
 }]
```

{% endtab %}
{% endtabs %}

Body parameters

```javascript
[
  {
    "internalId": "34HHB-QQ1",
    "price":199.99
  },
  {
    "internalId": "34HHB-QQ2",
    "price": 299.99
  }
]
```

## Update Price And Stock Async

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/stock/UpdatePriceAndStockAsync`

This option should be used when you want to process large quantities of SKU's. It is recommended to run at night hours due to the time it can take to process the data.\
\
This option should be used when you want to process large amounts of SKUs or the desired channel is taking a long time to respond with a previous endpoint.\
\
This process generates a task within Ventiapp. The result of this can be consulted from the frontend, or from the GetStatusRequest endpoint

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer +token    |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "status": "sent",
    "msg": "request sent",
    "jobId": "9999"
}
```

{% endtab %}
{% endtabs %}

Body Parameters

```javascript
[
  {
    "sku": "34HHB-QQ1",
    "quantity": "10"
  },
{
    "sku": "34HHB-QQ2",
    "quantity": "15",
    "price": "99.99",
    "publishingPrice": "99.99"
  }
]
```

## Get Status Request

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/stock/GetStatusRequest`

This method returns the state of the previously generated asynchronous task

#### Path Parameters

| Name  | Type   | Description             |
| ----- | ------ | ----------------------- |
| jobId | number | Id de la tarea generada |

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer + token   |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}
