Skip to main content

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

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.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
limitintegerqueryThe amount of line items returned per page
pagestringqueryThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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

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.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{location_id}stringqueryThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe stock provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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

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.

ParameterData TypeInRequiredDescription
api_tokenstringheaderThe API key of the customer account
namestringbodyThe name of the stock location
codestringbodyThe code of the stock location
providerintegerbodyThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe stock provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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

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.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
namestringqueryThe name of the stock location
codestringqueryThe code of the stock location
providerstringqueryThe stock provider ID
provider_namestringqueryThe name of the provider
created_datedatequeryThe creation date
modified_datedatequeryThe last modified date
is_activebooleanqueryThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe stock provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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

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.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{stocklocation_id}stringqueryThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe stock provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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

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.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{stocklocation_id}stringqueryThe 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.

ParameterData TypeDescription
idintegerThe primary key of the stock location
namestringThe name of the stock location
codestringThe code of the stock location
providerintegerThe stock provider ID
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe 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."
]
}