# Stock Locations

A stock provider may have stock areas located in multiple locations. In order to match these stock locations with the respective stock provider, they need to be defined in Whippy Ware. The brand needs to assign a unique value to each stock location and ensuring that these values are defined both within their own system and in Whippy Ware.

### List Locations​ <a href="#list-locations" id="list-locations"></a>

This method is used to get a list of location objects.

`GET` **List-Locations**

**Path:** `/api/v1/stock-locations/`

**Parameters​**

The following parameters can be used to get a list of location objects.

| Parameter  | Data Type | In     | Description                                |
| ---------- | --------- | ------ | ------------------------------------------ |
| api\_token | string    | header | The API key of the customer account        |
| limit      | integer   | query  | The amount of line items returned per page |
| page       | string    | query  | The number of page returned                |

**Example Request​**

```
import requests

url = "https://{whippy_api_url}/api/v1/stock-locations/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The provider ID                             |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
    "count": 3,
    "next": "https://{whippy_api_url}/api/v1/stock-locations/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "created_date": "2023-05-10T12:30:30.784114+03:00",
            "modified_date": "2023-05-10T12:30:30.784158+03:00",
            "is_active": true,
            "name": "110",
            "code": "110",
            "provider": 1
        },
        {
            "id": 2,
            "created_date": "2023-05-10T12:31:46.773210+03:00",
            "modified_date": "2023-05-10T12:31:46.773249+03:00",
            "is_active": true,
            "name": "112",
            "code": "112",
            "provider": 1
        },
        {
            "id": 3,
            "created_date": "2023-05-10T12:31:56.231437+03:00",
            "modified_date": "2023-05-10T12:31:56.231468+03:00",
            "is_active": true,
            "name": "115",
            "code": "115",
            "provider": 1
        }
    ]
}
```

### Location Instance​ <a href="#location-instance" id="location-instance"></a>

This method is used to get the details of the location object with the specified location ID.

`GET` **Location-Instance**

**Path:** `/api/v1/stock-locations/{location_id}/`

**Parameters​**

The following parameters can be used to get the details of the location objects.

| Parameter      | Data Type | In     | Description                         |
| -------------- | --------- | ------ | ----------------------------------- |
| api\_token     | string    | header | The API key of the customer account |
| {location\_id} | string    | query  | The ID number of the location       |

**Example Request​**

```
import requests

url = "https://{whippy_api_url}/api/v1/stock-locations/1/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The stock provider ID                       |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
   "id": 1,
   "created_date": "2023-05-10T12:30:30.784114+03:00",
   "modified_date": "2023-05-10T12:30:30.784158+03:00",
   "is_active": true,
   "name": "110",
   "code": "110",
   "provider": 1
}
```

### Create Location​ <a href="#create-location" id="create-location"></a>

This method is used to create a location object with the request body.

`POST` **Create-Location**

**Path:** `/api/v1/stock-locations/`

**Parameters​**

The following parameters can be used to create a location object.

| Parameter  | Data Type | In     | Required | Description                         |
| ---------- | --------- | ------ | :------: | ----------------------------------- |
| api\_token | string    | header |     ✓    | The API key of the customer account |
| name       | string    | body   |     ✓    | The name of the stock location      |
| code       | string    | body   |     ✓    | The code of the stock location      |
| provider   | integer   | body   |     ✓    | The stock provider ID               |

**Example Request​**

```
import requests

url = "https://{whippy_api_url}/api/v1/stock-locations/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 Created)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The stock provider ID                       |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
    "id": 1,
    "created_date": "2023-05-10T12:30:30.784114+03:00",
    "modified_date": "2023-05-10T12:30:30.784158+03:00",
    "is_active": true,
    "name": "110",
    "code": "110",
    "provider": 1
}
```

**Example Response (400 Bad Request)​**

```
{
   "code": [
       "location with this code already exists."
   ]
}
```

### Search Locations​ <a href="#search-locations" id="search-locations"></a>

This method is used to search location objects with the specified filters.

`GET` **Search-Locations**

**Path:** `/api/v1/stock-locations/?code__icontains=<string>&code=<string>&created_date__gt=<string>&created_date__gte=<string>&created_date__lt=<string>&created_date__lte=<string>&created_date=<string>&modified_date__gt=<string>&modified_date__gte=<string>&modified_date__lt=<string>&modified_date__lte=<string>&modified_date=<string>&is_active=<string>&name=<string>&provider=<string>&provider_name=<string>&sort=<string>&page=<integer>&limit=<integer>`

**Filters​**

The following parameters can be used to filter GET request results.

| Parameter      | Data Type | In     | Description                                 |
| -------------- | --------- | ------ | ------------------------------------------- |
| api\_token     | string    | header | The API key of the customer account         |
| name           | string    | query  | The name of the stock location              |
| code           | string    | query  | The code of the stock location              |
| provider       | string    | query  | The stock provider ID                       |
| provider\_name | string    | query  | The name of the provider                    |
| created\_date  | date      | query  | The creation date                           |
| modified\_date | date      | query  | The last modified date                      |
| is\_active     | boolean   | query  | The activation status of the stock location |

The following filters can be applied via the request URL.

```
"filters": {
       "code": {
           "type": "CharFilter",
           "lookup_types": [
               "icontains",
               "exact"
           ]
       },
       "created_date": {
           "type": "IsoDateTimeFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "modified_date": {
           "type": "IsoDateTimeFilter",
           "lookup_types": [
               "gt",
               "gte",
               "lt",
               "lte",
               "exact"
           ]
       },
       "is_active": {
           "type": "BooleanFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "name": {
           "type": "CharFilter",
           "lookup_types": [
               "icontains"
           ]
       },
       "provider": {
           "type": "CharFilter",
           "lookup_types": [
               "exact"
           ]
       },
       "provider_name": {
           "type": "CharFilter",
           "lookup_types": [
               "icontains"
           ]
       }
   }
```

**Example Request​**

```
import requests

url = "https://{whippy_api_url}/api/v1/stock-locations/?code__icontains=<string>&code=<string>&created_date__gt=<string>&created_date__gte=<string>&created_date__lt=<string>&created_date__lte=<string>&created_date=<string>&modified_date__gt=<string>&modified_date__gte=<string>&modified_date__lt=<string>&modified_date__lte=<string>&modified_date=<string>&is_active=<string>&name=<string>&provider=<string>&provider_name=<string>&sort=<string>&page=<integer>&limit=<integer>"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={}
headers = {
  'Accept': 'application/json',
  'Authorization': 'Token {}'.format(api_token),
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The stock provider ID                       |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
    "count": 3,
    "next": "http://{whippy_api_url}/api/v1/stock-locations/?name=stock&page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "created_date": "2023-05-10T12:30:30.784114+03:00",
            "modified_date": "2023-05-10T12:30:30.784158+03:00",
            "is_active": true,
            "name": "110",
            "code": "110",
            "provider": 1
        },
        {
            "id": 2,
            "created_date": "2023-05-10T12:31:46.773210+03:00",
            "modified_date": "2023-05-10T12:31:46.773249+03:00",
            "is_active": true,
            "name": "112",
            "code": "112",
            "provider": 1
        },
        {
            "id": 3,
            "created_date": "2023-05-10T12:31:56.231437+03:00",
            "modified_date": "2023-05-10T12:31:56.231468+03:00",
            "is_active": true,
            "name": "115",
            "code": "115",
            "provider": 1
        }
    ]
}
```

### Location Partial Update​ <a href="#location-partial-update" id="location-partial-update"></a>

This method is used to partially update the specified location object with PATCH request.

`PATCH` **Location-Partial-Update**

**Path:** `/api/v1/stock-locations/{stocklocation_id}/`

**Parameters​**

The following parameters can be used to partially update the location object.

| Parameter           | Data Type | In     | Description                         |
| ------------------- | --------- | ------ | ----------------------------------- |
| api\_token          | string    | header | The API key of the customer account |
| {stocklocation\_id} | string    | query  | The ID number of the stock location |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stock-locations/{stocklocation_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
 "name": "118",
 "provider": 2,
})

headers = {
 'Content-Type': 'application/json',
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("PATCH", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The stock provider ID                       |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
   "id": 1,
   "created_date": "2023-05-10T12:30:30.784114+03:00",
   "modified_date": "2023-05-10T13:03:13.637252+03:00",
   "is_active": true,
   "name": "118",
   "code": "110",
   "provider": 2
}
```

**Example Response (400 Bad Request)​**

```
{
   "code": [
       "location with this code already exists."
   ]
}
```

### Location Full Update​ <a href="#location-full-update" id="location-full-update"></a>

This method is used to update all fields of the specified location object with PUT request.

`PUT` **Location-Full-Update**

**Path:** `/api/v1/stock-locations/{stocklocation_id}/`

**Parameters​**

The following parameters can be used to full update the location object.

| Parameter           | Data Type | In     | Description                         |
| ------------------- | --------- | ------ | ----------------------------------- |
| api\_token          | string    | header | The API key of the customer account |
| {stocklocation\_id} | string    | query  | The ID number of the stock location |

**Example Request​**

```
import requests
import json

url = "https://{whippy_api_url}/api/v1/stock-locations/{stocklocation_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
  "name": "<string>",
  "code": "<string>",
  "provider": "<integer>",
  "is_active": "<boolean>"
})

headers = {
 'Content-Type': 'application/json',
 'Accept': 'application/json',
 'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)​**

The response includes the following parameters.

| Parameter      | Data Type | Description                                 |
| -------------- | --------- | ------------------------------------------- |
| id             | integer   | The primary key of the stock location       |
| name           | string    | The name of the stock location              |
| code           | string    | The code of the stock location              |
| provider       | integer   | The stock provider ID                       |
| created\_date  | date      | The creation date                           |
| modified\_date | date      | The last modified date                      |
| is\_active     | boolean   | The activation status of the stock location |

```
{
   "id": 1,
   "created_date": "2023-05-10T12:30:30.784114+03:00",
   "modified_date": "2023-05-10T13:03:13.637252+03:00",
   "is_active": true,
   "name": "118",
   "code": "110",
   "provider": 2
}
```

**Example Response (400 Bad Request)​**

```
{
   "code": [
       "location with this code already exists."
   ]
}
---
{
   "name": [
       "This field is required."
   ],
   "code": [
       "This field is required."
   ],
   "provider": [
       "This field is required."
   ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/omnitron/whippy-ware/stock-locations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
