Skip to main content

Stock Providers

A general or special to brand provider can be defined via Provider model. The information of the stock provider defined in Whippy Ware needs to be identical to the defined information sent from the brand’s API. Otherwise, Whippy Ware will not be able to register the information received from the service into its own system.

List Providers

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

GET List-Providers

Path: /api/v1/providers/

Parameters

The following parameters can be used to get a list of provider 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/providers/"
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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"count": 1,
"next": "https://{whippy_api_url}/api/v1/providers/?page=2",
"previous": null,
"results": [
{
"id": 1,
"created_date": "2023-05-10T10:08:25.050666+03:00",
"modified_date": "2023-05-10T10:08:25.058711+03:00",
"is_active": true,
"name": "Provider",
"code": "provider_company",
"should_add_reservations": false
}
]
}

Provider Instance

This method is used to get the details of the provider object with the specified provider number.

GET Provider-Instance

Path: /api/v1/providers/{provider_no}

Parameters

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

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{provider_id}stringqueryThe ID number of the provider

Example Request

import requests

url = "https://{whippy_api_url}/api/v1/providers/{provider_id}/"
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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"id": 1,
"created_date": "2023-05-10T10:08:25.050666+03:00",
"modified_date": "2023-05-10T10:08:25.058711+03:00",
"is_active": true,
"name": "Provider",
"code": "provider_company",
"should_add_reservations": false
}

Create Provider

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

POST Create-Provider

Path: /api/v1/providers/

Parameters

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

ParameterData TypeInRequiredDescription
api_tokenstringheaderThe API key of the customer account
codestringbodyThe code of the provider
namestringbodyThe name of the provider
should_add_reservationsbooleanbodyThe status of the reservation

Example Request

import requests
import json

url = "https://{whippy_api_url}/api/v1/providers/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = payload = json.dumps({
"name": "Provider 1",
"code": "provider_1",
"is_active": True,
"should_add_reservations": False
})

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

response = requests.request("POST", 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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"id": 2,
"created_date": "2023-05-10T11:01:01.404492+03:00",
"modified_date": "2023-05-10T11:01:01.404542+03:00",
"is_active": true,
"name": "Provider 1",
"code": "provider_1",
"should_add_reservations": false
}

Example Response (400 Bad Request)

{
"name": [
"This field is required."
],
"code": [
"This field is required."
]
}

Search Providers

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

GET Search-Providers

Path: /api/v1/providers/?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>&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
codestringqueryThe code of the provider
namestringqueryThe name of the provider
is_activebooleanqueryThe activation status of the rule
created_datedatequeryThe creation date
modified_datedatequeryThe last modified date

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"
]
}
}

Example Request

import requests

url = "https://{whippy_api_url}/api/v1/providers/?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>&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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"count": 2,
"next": http://{whippy_api_url}/api/v1/providers/?name=prov&page=2,
"previous": null,
"results": [
{
"id": 1,
"created_date": "2023-05-10T10:08:25.050666+03:00",
"modified_date": "2023-05-10T10:08:25.058711+03:00",
"is_active": true,
"name": "Provider",
"code": "provider_company",
"should_add_reservations": false
},
{
"id": 2,
"created_date": "2023-05-10T11:01:01.404492+03:00",
"modified_date": "2023-05-10T11:01:01.404542+03:00",
"is_active": true,
"name": "Provider 1",
"code": "provider_1",
"should_add_reservations": false
}
]
}

Provider Partial Update

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

PATCH Provider-Partial-Update

Path: /api/v1/providers/{rule_no}/

Parameters

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

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{provider_id}stringqueryThe ID number of the provider

Example Request

import requests
import json

url = "https://{whippy_api_url}/api/v1/providers/{provider_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
"should_add_reservations": True
})
headers = {
'Content-Type': '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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"id": 1,
"created_date": "2023-05-10T10:08:25.050666+03:00",
"modified_date": "2023-05-10T11:14:19.680335+03:00",
"is_active": true,
"name": "Provider",
"code": "provider_company",
"should_add_reservations": true
}

Example Response (400 Bad Request)

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

Provider Full Update

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

PUT Provider-Full-Update

Path: /api/v1/providers/{rule_no}/

Parameters

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

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
{provider_id}stringqueryThe ID number of the provider

Example Request

import requests
import json

url = "https://{whippy_api_url}/api/v1/providers/{provider_id}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
"name": "Provider",
"code": "provider",
"is_active": "false",
"should_add_reservations": "true"
})
headers = {
'Content-Type': '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 provider
namestringThe name of the provider
codestringThe code of the provider
should_add_reservationsbooleanThe status of the reservation
created_datedateThe creation date
modified_datedateThe last modified date
is_activebooleanThe activation status of the Provider
{
"id": 1,
"created_date": "2023-05-10T10:08:25.050666+03:00",
"modified_date": "2023-05-10T12:21:28.042081+03:00",
"is_active": false,
"name": "Provider",
"code": "provider",
"should_add_reservations": true
}

Example Response (400 Bad Request)

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