assistance-engine/docs/developer.avapframework.com/last_order_summary.md

345 lines
8.4 KiB
Markdown

## ws/orders.py/last_order_summary
### Receives
All the parameters that the service receives must be indicated in the body
of the request.
## Returns:
Depending on the result of the operation, this service can return two
different JSON:
```javascript
{
"status"
:{' '}
true
,
"codtran"
:{' '}
"f856c5db007fcaa5a00b9a4d56a9d40a"
,
"resultado"
:{' '}
[
'status': 'Being sent'
,
'status_code':{' '}
4001
,
'transaction_code':{' '}
'a556a5de007fcaa5a00b4a4d56a9d40a'
,
'order_code':{' '}
10023
,
'date':{' '}
2021
-03
-01
,
'client_address': 'Street
without number',
'establishment_coordinates'
:{' '}
{
'lat':{' '}
40
,
5431311
,
'lng':{' '}
-3
,
6302845
}
,
'location_gps':{' '}
{
'lat':{' '}
40
,
5431311
,
'lng':{' '}
-3
,
6302845
}
'delivery_time': '
12
:
03
:
01'
,
'delivery_type':{' '}
'delivery',
'order_products_codes'
:
{' '}
[
{
"article_id"
:
35003
,
"custom"
:
[
[
{' '}
"da9922e8-57a6-4440-97db-0de2a486b323"
,
{' '}
"00e9a2cc-60c8-4e98-ac9b-accf15b7373a"
,
{' '}
"a6aacb94-8fad-4394-a2f1-e328fcca9c79"
]
,
[
{' '}
"757ccbe3-d877-485d-ae10-89f0b78c133c"
]
]
}
]
,
'purchase_detail': 'Palo
Alto ( Lechuga , Tomate{' '}
, Cebolla{' '}
, Aguacate{' '}
, )'
,
'order_category_id':{' '}
'FL013',
'contact':{' '}
{
"firstName"
:
"Rafa"
,
"lastName"
:
" "
,
"mail"
:
"rafa.ruiz@waynnovate.com"
,
"phone"
:
"643340526"
}
,
'status_history':{' '}
[
{
'new_status':'Being sent'
,
'new_status_code':{' '}
4001
,
'previous_status': 'Being
picked up',
'previous_status_code':
4000
,
'status_change_date': '
2021
-02
-01{' '}
13
:
00.01'{' '}
}
]
'delivery_price':{' '}
1.9
,
'delivery_distance':{' '}
34000.34)
,
]
"elapsed"
:{' '}
0.06796097755432129
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false).
* `codtran:` Operation result.
* `result:` Data of the last order in course. `status:` Status of the order. `status_code` : Code of the actual status of the order. `transaction_code` : Code of the transaction `order_code:` Code of the order. `date:` Date of the order. `client_address:` Address of the client. `establishment_coordinates` : Coordinates of the establishment that gives the order. `location_gps:` Coordinates of the direction that receives the delivery. `delivery_time:` Hour of the delivery. `delivery_type:` Type of delivery (to pickup/ to have sent). `order_products_codes:` List of product codes and their options. `purchase_detail:` List of the names of the products with their options. `order_category_id:` Identifier of the establishment that provides the product. `contact:` Contact of the client. `status_history:` History of the status changes in the order. `new_status:` New status. `new_status_code:` Code of the new status. `previous_status:` Previous status. `previous_status_code:` Previous status code. `status_change_date:` Time and date of the change of status. `delivery_price:` Price of the delivery. `delivery_distance:` Distance between the client and the establishment that provides the order.
* `status:` Status of the order.
* `status_code` : Code of the actual status of the order.
* `transaction_code` : Code of the transaction
* `order_code:` Code of the order.
* `date:` Date of the order.
* `client_address:` Address of the client.
* `establishment_coordinates` : Coordinates of the establishment that gives the order.
* `location_gps:` Coordinates of the direction that receives the delivery.
* `delivery_time:` Hour of the delivery.
* `delivery_type:` Type of delivery (to pickup/ to have sent).
* `order_products_codes:` List of product codes and their options.
* `purchase_detail:` List of the names of the products with their options.
* `order_category_id:` Identifier of the establishment that provides the product.
* `contact:` Contact of the client.
* `status_history:` History of the status changes in the order. `new_status:` New status. `new_status_code:` Code of the new status. `previous_status:` Previous status. `previous_status_code:` Previous status code. `status_change_date:` Time and date of the change of status.
* `new_status:` New status.
* `new_status_code:` Code of the new status.
* `previous_status:` Previous status.
* `previous_status_code:` Previous status code.
* `status_change_date:` Time and date of the change of status.
* `delivery_price:` Price of the delivery.
* `delivery_distance:` Distance between the client and the establishment that provides the order.
* `elapsed:` Operation execution time.
### Answer JSON KO:
```javascript
{
"status"
:{' '}
false
,
"level"
: <string>
,
"message"
: <string>
,
"error"
: <string>
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false).
* `level:` Error importance level.
* `message:` Error message.
* `error:` Sole error code.
## Example requests:
### Python - Requests:
```javascript
import requests
url ={' '}
"http://34.121.95.179:80/ws/orders.py/last_order_summary?country_code=ES&user_id=133&session_id=1689-oocyMaFovWi1jljrF-eaSw=="
payload=
{
}
headers ={' '}
{
'101ObexApiKey'
:{' '}
'MS1phGJRa3WyLilN9dlZ7vurJDIpe0nM'
}
response = requests
.request
(
"GET"
, url
, headers
=headers
, data
=payload
)
print
(response
.text
)
```
### NodeJs - Request:
```javascript
var request = require('request');
var options = {
'method': 'GET',
'url':
'http://34.121.95.179:80/ws/orders.py/last_order_summary?country_code=ES&user_id=133&session_id=1689-oocyMaFovWi1jljrF-eaSw==',
'headers': {
'101ObexApiKey': 'MS1phGJRa3WyLilN9dlZ7vurJDIpe0nM'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
```
### JavaScript - Fetch:
```javascript
var myHeaders = new Headers();
myHeaders.append("101ObexApiKey",
"MS1phGJRa3WyLilN9dlZ7vurJDIpe0nM");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("http://34.121.95.179:80/ws/orders.py/last_order_summary?country_code=ES&user_id=133&session_id=1689-oocyMaFovWi1jljrF-eaSw==",
requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
### CURL:
```javascript
curl --location --request GET{' '}
'http://34.121.95.179:80/ws/orders.py/last_order_summary?country_code=ES&user_id=133&session_id=1689-oocyMaFovWi1jljrF-eaSw=='
{' '}
\
--header{' '}
'101ObexApiKey: MS1phGJRa3WyLilN9dlZ7vurJDIpe0nM'
```
## Business logic:
The objective of this service is to retrieve the orders that are in course
and its details.