193 lines
5.5 KiB
Markdown
193 lines
5.5 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"
|
|
,
|
|
"order_code"
|
|
:{' '}
|
|
12034
|
|
"elapsed"
|
|
:{' '}
|
|
0.06796097755432129
|
|
|
|
}
|
|
```
|
|
|
|
## Where:
|
|
|
|
* `status:` Shows if the call has been successful (true) or not (false).
|
|
* `codtran:` Operation result.
|
|
* `order_code:` Identifier of the order in the system.
|
|
* `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/ws/orders.py/new?country_code=ES&user_id=133&session_id=1688-eEqteXomKai8aDW2GkUFZQ==&purchase_transaction_code=24&client_address=Calle
|
|
sin
|
|
numero&delivery_time=12:34:43&payment_operation_code=pi_968ac76f7d898e7&order_products_codes=[34001,34002,34003]&order_category_id=1200&delivery_type=takeout&client_email_address=correo@servidor.ext&order_prices=[10.0,11.0,9.0]&delivery_price=3.5&total_amount=33.5&purchase_detail=[\"hamburguesa\",\"ensalada\",\"cocacola\"]&gps_direction={\"lat\":
|
|
40,5431311,\"lng\": -3,6302845
|
|
}&contact=Manuel&order_amount=30
|
|
€&shipping_amount=3,5 €"
|
|
|
|
|
|
|
|
payload=
|
|
{
|
|
}
|
|
|
|
headers ={' '}
|
|
{
|
|
'101ObexApiKey'
|
|
:{' '}
|
|
'WcdoRNOUS8jQLs5XWo75yjwzvEZazcSI'
|
|
|
|
}
|
|
|
|
|
|
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/ws/orders.py/new?country_code=ES&user_id=133&session_id=1688-eEqteXomKai8aDW2GkUFZQ==&purchase_transaction_code=24&client_address=Calle
|
|
sin
|
|
numero&delivery_time=12:34:43&payment_operation_code=pi_968ac76f7d898e7&order_products_codes=[34001,34002,34003]&order_category_id=1200&delivery_type=takeout&client_email_address=correo@servidor.ext&order_prices=[10.0,11.0,9.0]&delivery_price=3.5&total_amount=33.5&purchase_detail=["hamburguesa","ensalada","cocacola"]&gps_direction={"lat":
|
|
40,5431311,"lng": -3,6302845
|
|
}&contact=Manuel&order_amount=30 €&shipping_amount=3,5
|
|
€',
|
|
'headers': {
|
|
'101ObexApiKey': 'WcdoRNOUS8jQLs5XWo75yjwzvEZazcSI'
|
|
}
|
|
|
|
};
|
|
|
|
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",
|
|
"WcdoRNOUS8jQLs5XWo75yjwzvEZazcSI");
|
|
|
|
|
|
var requestOptions = {
|
|
method: 'GET',
|
|
headers: myHeaders,
|
|
redirect: 'follow'
|
|
|
|
};
|
|
|
|
|
|
fetch("http://34.121.95.179:80/ws/ws/orders.py/new?country_code=ES&user_id=133&session_id=1688-eEqteXomKai8aDW2GkUFZQ==&purchase_transaction_code=24&client_address=Calle
|
|
sin
|
|
numero&delivery_time=12:34:43&payment_operation_code=pi_968ac76f7d898e7&order_products_codes=[34001,34002,34003]&order_category_id=1200&delivery_type=takeout&client_email_address=correo@servidor.ext&order_prices=[10.0,11.0,9.0]&delivery_price=3.5&total_amount=33.5&purchase_detail=[\"hamburguesa\",\"ensalada\",\"cocacola\"]&gps_direction={\"lat\":
|
|
40,5431311,\"lng\": -3,6302845
|
|
}&contact=Manuel&order_amount=30 €&shipping_amount=3,5
|
|
€", requestOptions)
|
|
.then(response => response.text())
|
|
.then(result => console.log(result))
|
|
.catch(error => console.log('error', error));
|
|
```
|
|
|
|
### CURL:
|
|
|
|
```javascript
|
|
curl --location -g --request GET{' '}
|
|
|
|
'http://34.121.95.179:80/ws/ws/orders.py/new?country_code=ES&user_id=133&session_id=1688-eEqteXomKai8aDW2GkUFZQ==&purchase_transaction_code=24&client_address=Calle
|
|
sin
|
|
numero&delivery_time=12:34:43&payment_operation_code=pi_968ac76f7d898e7&order_products_codes=[34001,34002,34003]&order_category_id=1200&delivery_type=takeout&client_email_address=correo@servidor.ext&order_prices=[10.0,11.0,9.0]&delivery_price=3.5&total_amount=33.5&purchase_detail=["hamburguesa","ensalada","cocacola"]&gps_direction={"lat":
|
|
40,5431311,"lng": -3,6302845
|
|
}&contact=Manuel&order_amount=30
|
|
€&shipping_amount=3,5 €'
|
|
{' '}
|
|
\
|
|
|
|
--header{' '}
|
|
|
|
'101ObexApiKey: WcdoRNOUS8jQLs5XWo75yjwzvEZazcSI'
|
|
```
|
|
|
|
## Business logic:
|
|
|
|
The objective of this service is to add an order.
|