## ws/orders.py/order_history_summary

### Receives

All the parameters that the service receives must be indicated in the body
      of the request.

## Returns if user is RIDER profile:

Depending on the result of the operation, this service can return two
      different JSON:

```javascript
{
         "status"
        :{' '}
        true
        ,
         "codtran"
        :{' '}
        "850c29598f8ceae89e7083d1547faa29"
        ,
         "result"
        :{' '}
        {
         "status"
        :{' '}
        "Completed"
        ,
         "delivery_time"
        :{' '}
        "13:12:55"
        ,
         "delivery_type"
        :{' '}
        "sent"
        ,
         "order_category_id"
        :{' '}
        "FL016"
        ,
         "delivery_distance"
        :{' '}
        6987
        ,
         "status_code"
        :{' '}
        1
        ,
         "order_products_codes"
        :{' '}
        
          "[\n {\n \"article_id\": 39002,\n \"custom\": []\n },\n
          {\n \"article_id\": 39002,\n \"custom\": []\n },\n {\n
          \"article_id\": 39002,\n \"custom\": []\n },\n {\n
          \"article_id\": 39002,\n \"custom\": []\n }\n]"
        
        ,
        {' '}
        "establishment_coordinates"
        :{' '}
        {
         "latitude"
        :{' '}
        40.630568688062624
        ,
         "longitude"
        :{' '}
        -3.585006931371174
         }
        ,
         "location_gps"
        :{' '}
        
          "{\n \"direction\": {\n \"street\": \"Calle Cádiz \",\n
          \"number\": \" 21\",\n \"city\": \"Fuente del Fresno\"\n },\n
          \"positioning\": {\n \"lat\": 40.5910124,\n \"lng\": -3.5886479\n
          }\n}"
        
        ,
         "delivery_price"
        :{' '}
        "1,90 €"
        ,
         "contact"
        :{' '}
        
          "{\n \"firstName\": \"Rafael\",\n \"Surname\": \"Surname1
          Surname2\",\n \"mail\": \"rafa32gr@gmail.com\",\n \"phone\":
          \"643340526\"\n}"
        
        ,
         "purchase_detail"
        :{' '}
        
          "Tortilla soup\nTortilla soup\nTortilla soup\nTortilla soup\n"
        
        ,
         "order_code"
        :{' '}
        101033
        ,
         "date"
        :{' '}
        "18/08/2021 05:17:56"
        ,
         "transaction_code"
        :{' '}
        "988569e4f38717f35e0fa5c256fe466b"
        ,
         "status_history"
        :{' '}
        [
         {
         "previous_status_code"
        :{' '}
        12
        ,
         "status_change_date"
        :{' '}
        "2021-08-18 12:17:57"
        ,
         "new_status"
        :{' '}
        "Sent to restaurant"
        ,
         "new_status_code"
        :{' '}
        0
        ,
         "previous_status"
        :{' '}
        "Nuevo pedido"
         }
        ,
         {
         "previous_status_code"
        :{' '}
        0
        ,
         "status_change_date"
        :{' '}
        "2021-08-18 12:18:51"
        ,
         "new_status"
        :{' '}
        "Being picked up"
        ,
         "new_status_code"
        :{' '}
        11
        ,
         "previous_status"
        :{' '}
        "Sent to restaurant"
         }
        ,
         {
         "previous_status_code"
        :{' '}
        11
        ,
         "status_change_date"
        :{' '}
        "2021-08-18 12:19:57"
        ,
         "new_status"
        :{' '}
        "In delivey"
        ,
         "new_status_code"
        :{' '}
        10
        ,
         "previous_status"
        :{' '}
        "Being picked up"
         }
        ,
         {
         "previous_status_code"
        :{' '}
        10
        ,
         "status_change_date"
        :{' '}
        "2021-08-18 12:20:37"
        ,
         "new_status"
        :{' '}
        "Completed"
        ,
         "new_status_code"
        :{' '}
        1
        ,
         "previous_status"
        :{' '}
        "In delivey"
         }
         ]
        ,
         "client_address"
        :{' '}
        
          "Fuente del Fresno\nCalle Cádiz Número 21\n643340526"
        
         }
        ,
         "elapsed"
        :{' '}
        0.12410902976989746
        
        }
```

## 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:` Current status of the order. `status_code` : Code of the current state 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 does the order. `location_gps:` Coordinates of the company direction. `delivery_time:` Hour established for the delivery. `delivery_type:` Type of delivery (pick up/ sent) `order_products_codes:` List of code products and its options. `purchase_detail:` List of product names with its options. `order_category_id:` Identifier of the establishment that provides the order. `contact:` Client contact. `status_history:` History of 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:` Hour and time of the status change. `delivery_price:` Price of the delivery. `delivery_distance:` Distance between the client and the establishment.
* `status:` Current status of the order.
* `status_code` : Code of the current state 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 does the order.
* `location_gps:` Coordinates of the company direction.
* `delivery_time:` Hour established for the delivery.
* `delivery_type:` Type of delivery (pick up/ sent)
* `order_products_codes:` List of code products and its options.
* `purchase_detail:` List of product names with its options.
* `order_category_id:` Identifier of the establishment that provides the order.
* `contact:` Client contact.
* `status_history:` History of 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:` Hour and time of the status change.
* `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:` Hour and time of the status change.
* `delivery_price:` Price of the delivery.
* `delivery_distance:` Distance between the client and the establishment.
* `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=14&session_id=1387-REIfL6Z3FzpGRvc9PYdbFg==&start_date=2018-01-01&end_date=2022-07-07"
        
        
        
        payload=
        {
        }
        
        headers ={' '}
        {
         '101ObexApiKey'
        :{' '}
        'FsGwQeqT9TmGmQ2ytEImM6bDAMshRI55'
        
        }
        
        
        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=14&session_id=1387-REIfL6Z3FzpGRvc9PYdbFg==&start_date=2018-01-01&end_date=2022-07-07',
         'headers': {
         '101ObexApiKey': 'FsGwQeqT9TmGmQ2ytEImM6bDAMshRI55'
         }
        
        };
        
        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",
        "FsGwQeqT9TmGmQ2ytEImM6bDAMshRI55");
        
        
        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=14&session_id=1387-REIfL6Z3FzpGRvc9PYdbFg==&start_date=2018-01-01&end_date=2022-07-07",
        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=14&session_id=1387-REIfL6Z3FzpGRvc9PYdbFg==&start_date=2018-01-01&end_date=2022-07-07'
        {' '}
        \
        
        --header{' '}
        
          '101ObexApiKey: FsGwQeqT9TmGmQ2ytEImM6bDAMshRI55'
```

## Business logic:

The objective of this service is to retrieve the completed requests of the
      riders.
