def process_list_order_response()

in order/utils/order_actions.py [0:0]


def process_list_order_response(orders_response_json:Dict):
    ''' Build list of orders and their order items from response of first commerce_orders request

    params:
    orders_response_json: json of the response of commerce_orders GET call
    returns:
    results: complete list of orders with their order items
    '''

    if 'data' not in orders_response_json or not orders_response_json['data']:
        print("process_list_order_response found no orders to process")
        print(orders_response_json)
        return []

    orders = orders_response_json['data']
    results = []
    results += pageinate_orders(orders)
    paging = 'paging' in orders_response_json and orders_response_json['paging']
    if paging:
        while 'next' in paging:
            res = requests.get(results['paging']['next'])
            res = res.json()
            orders = res['data']
            paging = res['paging']
            results += pageinate_orders(orders)
    return results