# Product Group

## Fetch Product Groups

<mark style="color:blue;">`GET`</mark> `/wms/sku/product-group`

This api returns all or a set of ***Product Groups*** configured depending on the filter criteria passed or not. **Note** when more than one below parameters are sent the result will be filtered matching all the parameters and not any one. so filter should be applied accordingly or else result would be empty if all conditions are not met.

#### Query Parameters

| Name        | Type   | Description                                                                         |
| ----------- | ------ | ----------------------------------------------------------------------------------- |
| name        | String | Partial or full text matching the name of the Product Group like 'Travel & Leisure' |
| description | String | Partial or full text matching the description of the Product Group.                 |
| id          | String | Blowhorn assigned/supplied integer unique id for the Product Group like 12345       |

#### Headers

| Name                                       | Type   | Description                              |
| ------------------------------------------ | ------ | ---------------------------------------- |
| API\_KEY<mark style="color:red;">\*</mark> | String | API key obtained by the Customer/Partner |

{% tabs %}
{% tab title="200: OK Response for no search criteria or matching criteria" %}

```javascript
{
    "count": 1,
    "previous": null,
    "next": 0,
    "result": [
        {
            "id": 9,
            "created_date": "2021-07-30T17:39:32.787735+05:30",
            "modified_date": "2021-07-30T17:39:32.787755+05:30",
            "name": "Instants",
            "description": "Ready to cook products",
            "created_by": null,
            "modified_by": null,
            "customer": 40082
        }
    ]
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized/Validation Error" %}

```javascript
{
  "status": "FAIL",
  "message": "Unauthorized"
}
```

{% endtab %}

{% tab title="200: OK No Product Group found for the search criteria" %}

```javascript
{
    "count": 0,
    "previous": null,
    "next": 0,
    "result": []
}
```

{% endtab %}

{% tab title="500: Internal Server Error Unexpected Error" %}

```javascript
{
  "status": "FAIL",
  "message": "Unexpected error"
}
```

{% endtab %}
{% endtabs %}

## Create Product Groups

<mark style="color:green;">`POST`</mark> `/wms/sku/product-group`

This API is for creating new ***Product Groups***.

#### Headers

| Name                                       | Type   | Description                              |
| ------------------------------------------ | ------ | ---------------------------------------- |
| API\_KEY<mark style="color:red;">\*</mark> | String | API key obtained by the Customer/Partner |

#### Request Body

| Name                                   | Type   | Description                                                                                                                                                      |
| -------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark> | String | Unique text identifier of the Product Group for the client                                                                                                       |
| description                            | String | Product Group description                                                                                                                                        |
| id                                     | String | An identifier will be randomly generated by Blowhorn. You can optionally override this ID, but the ID must be unique across all products groups in your account. |

{% tabs %}
{% tab title="200: OK Successful creation of Product Group" %}

```javascript
{
    "status": "PASS",
    "message": {
        "id": 297
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request/Validation Error" %}

```javascript
{
    "status": "FAIL",
    "message": "Product Group already exists"
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized/Wrong API key" %}

```javascript
{
  "status": "FAIL",
  "message": "Unauthorized"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Unexpected Error" %}

```javascript
{
  "status": "FAIL",
  "message": "Unexpected error"
}
```

{% endtab %}

{% tab title="400: Bad Request Missing required parameters" %}

```javascript
{
    "status": "FAIL",
    "message": "Missing required parameters."
}
```

{% endtab %}
{% endtabs %}

## Update Product Groups

<mark style="color:orange;">`PUT`</mark> `/wms/sku/product-group`

This API is for updating an existing ***Product Group***. Any or all of the below mentioned attribute of the Product Group can be updated using this API.

#### Headers

| Name     | Type   | Description                              |
| -------- | ------ | ---------------------------------------- |
| API\_KEY | String | API key obtained by the Customer/Partner |

#### Request Body

| Name        | Type   | Description                                                                                                                                                                                                                                                                                                                |
| ----------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id          | String | <p>Unique identifier either generated by Blowhorn or provided at the time of <strong>Product Group</strong> creation. </p><p><strong>Note</strong>: This is conditionally optional. Either <strong>id</strong> or <strong>name</strong> should be provided for identifying the Product Group that needs to be updated.</p> |
| name        | String | <p>Unique text identifier of the <strong>Product Group</strong> for the client. </p><p><strong>Note</strong>: This is conditionally optional. Either <strong>id</strong> or <strong>name</strong> should be provided for identifying the <strong>Product Group</strong> that needs to be updated.</p>                      |
| description | String | Product Group description                                                                                                                                                                                                                                                                                                  |

{% tabs %}
{% tab title="200: OK Successful updation of Product Group" %}

```javascript
{
    "status": "PASS",
    "message": "Product Group Updated successfully."
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request/Validation Error" %}

```javascript
{
    "status": "FAIL",
    "message": "Product Group does not exists"
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized/Wrong API key" %}

```javascript
{
  "status": "FAIL",
  "message": "Unauthorized"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Unexpected error" %}

```javascript
{
  "status": "FAIL",
  "message": "Unexpected error"
}
```

{% endtab %}

{% tab title="400: Bad Request Missing required parameters" %}

```javascript
{
    "status": "FAIL",
    "message": "Missing required parameters."
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Create Product Group | Schema " %}

```json
{
    "id": 291,
    "name": "Travel & Leisure",
    "description": "This is travel & leisure related group of products."
}
```

{% endtab %}
{% endtabs %}
