Products
- Searchable lookup fields:
- EAN key
- Base product name
- Filterable field set:
base__diseases=INT
(Disease ID)
base__category=INT
(Category ID)
base__pharmaceutical_company=INT
(Pharma company ID)
is_active=BOOL
(True returns products that can be bought)
has_shortage=BOOL
(False returns products that are available and not in shortage)
min_price=DOUBLE
max_price=DOUBLE
id__in=INTs separated by commas
ean_key__in=EANs separated by commas
- Ordering fields:
created_at
This is the default by descending order
updated_at
Last updated date
base__name
By alphabetical order of name
price
By prices
Request:
curl --request GET \\
--url API_URL/api/products/ \\
--header 'Accept: application/json' \\
--header 'X-API-Key: {Client API Key}'
Response:
Status Code: 200 OK
{
"count": INT,
"next": "API_URL/api/products/?page=2",
"previous": null,
"results": [
{
"id": INT, // Product primary key
"base": {
"id": INT, // Base product primary key
"name": STRING, // Name
"pharmaceutical_company": {
"name": STRING
},
"category": {
"name": STRING
},
"medical_information": {
"active_ingredient": STRING,
"is_generic": BOOL,
"group_number": INT,
"requires_prescription": BOOL,
}
},
"price": DOUBLE,
"default_image": URL,
"is_active": BOOL,
"has_shortage": BOOL,
"ean_key": STRING,
"presentation": STRING
},
...,
]
}
Example response:
GET: API_URL/api/products/?limit=10&search=Vitamina%20E%20Caps
{
...,
"results":[
{
"id": 17917,
"base": {
"id": 8312,
"name": "Vitamina E 500 Sup Alim 30 Caps",
"pharmaceutical_company": {"id": 670,"name": "NAT HEALTH"},
"category": {"id": 270,"name": "Vitaminas y Minerales"},
"tags": [],
"medical_information": null
},
"price": "73.00",
"default_image": IMAGE_URL,
"is_active": true,
"has_shortage": false,
"ean_key": "7501853800432",
"presentation": ""
},
{
"id": 16030,
"base": {
"id": 6579,
"name": "Vitamina E 850Mg Caps C30",
"pharmaceutical_company": {"id": 555,"name": "PROGELA"},
"category": {"id": 270,"name": "Vitaminas y Minerales",},
"tags": [],
"medical_information": null
},
"price": "51.00",
"default_image": IMAGE_URL,
"is_active": true,
"has_shortage": false,
"ean_key": "7503008344617",
"presentation": ""
}]
}
Categories
- Searchable lookup fields:
- Filterable field set:
available
True/False. If True exclude Categories without any inactive/shortage products
- Ordering fields:
updated_at
This is the default by descending order
name
By alphabetical order of name
Request:
curl --request GET \\
--url API_URL/api/categories/ \\
--header 'Accept: application/json' \\
--header 'X-API-Key: {Client API Key}'
Response:
Status Code: 200 OK
{
"count": INT,
"next": "API_URL/api/categories/?page=2",
"previous": null,
"results":[
{
"id": INT, // Product primary key
"name": STRING, // Name
},...
]
Pharmaceutical Companies
- Searchable lookup fields:
- Filterable field set:
available
True/False. If True exclude Companies without any inactive/shortage products
- Ordering fields:
updated_at
This is the default by descending order
name
By alphabetical order of name
Request:
curl --request GET \\
--url API_URL/api/pharmaceutical-companies/ \\
--header 'Accept: application/json' \\
--header 'X-API-Key: {Client API Key}'
Response:
Status Code: 200 OK
{
"count": INT,
"next": "API_URL/api/pharmaceutical-companies/?page=2",
"previous": null,
"results":[
{
"id": INT, // Product primary key
"name": STRING, // Name
},...
]
Diseases
- Searchable lookup fields:
- Ordering fields:
updated_at
This is the default by descending order
name
By alphabetical order of name
Request:
curl --request GET \\
--url API_URL/api/diseases/ \\
--header 'Accept: application/json' \\
--header 'X-API-Key: {Client API Key}'
Response:
Status Code: 200 OK
{
"count": INT,
"next": "API_URL/api/diseases/?page=2",
"previous": null,
"results":[
{
"id": INT, // Product primary key
"name": STRING, // Name
"is_chronic": BOOL
},...
]
Calculate
This service calculates the purchase order totals and estimated delivery date
The products and quantities are specified inside an array of DETAIL
objects. Each detail has {"product": ID, "quantity":INT}
.
The shipping methods vary depending on the zip code, they can be seen under the array of shipping_method_options
. The structure of this object is like so:
- SHIPPING_METHOD
"id"
: The primary key of the object.
"method"
: The type of shipping method, currently available options are: "local"
, "standard"
and "express"
.
min_delivery_days
: Minimum amount of working days to deliver the order.
max_delivery_days
: Maximum amount of working days to deliver the order.
The zip code, shipping method ID, and current DateTime will be used to calculate the expected_delivery_date
.
Request:
curl --request POST \\
--url API_URL/api/orders/calculate/ \\
--header 'Accept: application/json' \\
--header 'Content-Type: application/json' \\
--header 'X-API-Key: {Client API Key}'
--data \\
{
"details":[{"product":INT,"quantity":INT} ...], REQUIRED
"store": 1, OPTIONAL // To be picked up at Vitau's store.
"zipcode": STRING, OPTIONAL // To be delivered to this zip code.
"coupon": STRING, OPTIONAL // Coupon code
"shipping_method": INT, OPTIONAL // Selected shipping method from the valid methods for this zip code.
...
}
Response:
Status Code: 201 Created
{
"subtotal": DOUBLE,
"shipping_price": DOUBLE,
"shipping_discount": DOUBLE,
"coupon": {
"code": STRING,
"value": DOUBLE // Between 0 and 1 is a percentage, else has a fixed value.
},
"discount":DOUBLE,
"iva":DOUBLE,
"total": DOUBLE,
"shipping_method_options":
[{
"id": INT,
"company": STRING,
"method": ENUM, [STANDARD, EXPRESS, LOCAL, DEFAULT]
"min_delivery_days": INT,
"max_delivery_days": INT,
"price": DOUBLE
}..],
"selected_shipping_method": INT, // When not included in request payload defaults to cheapest default method.
"errors": OBJECT, // Key value pairs of possible errors.
"expected_delivery_date": UTC DATETIME,
"max_delivery_date": UTC DATETIME,
"details":
[{
"product": INT,
"quantity": INT,
"subtotal": DOUBLE,
"discount": DOUBLE,
"iva":DOUBLE,
"total": DOUBLE
}...],
}
Error messages
Product does not exist
Status Code: 400 Bad Request
{
"details": [
{"product": ["Clave primaria {INT} inválida - objeto no existe."]}
...,
]
}
Coupon is not valid will return a 201 response but with an error object, however, it would calculate totals and deliveries excluding the desired discount.
Status Code: 201
{
"subtotal": DOUBLE,
...,
"errors": {
"coupon": "Coupon does not exist"
},
...,
}