From 57bb4fd5e4e54750ed6aad80ebfd6b14b4ab90c5 Mon Sep 17 00:00:00 2001 From: fakz9 Date: Thu, 16 Nov 2023 03:28:36 +0300 Subject: [PATCH] filters in orders by product --- routes/orders.py | 6 +++--- sipro/api/client.py | 4 ++-- sipro/api/orders.py | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/routes/orders.py b/routes/orders.py index dc58ad0..541e5fc 100644 --- a/routes/orders.py +++ b/routes/orders.py @@ -30,9 +30,9 @@ def get_orders(): @orders_blueprint.get('/getByProductId') def get_orders_by_supplier_product_id(): - args = request.args - product_id = args.get('productId') - return sipro.api.orders.get_orders_by_product_id(product_id) + params = dict(request.args) + # product_id = args.get('productId') + return sipro.api.orders.get_orders_from_barcode(params=params) @orders_blueprint.get('/getOrderById') diff --git a/sipro/api/client.py b/sipro/api/client.py index bc66cee..4f700b4 100644 --- a/sipro/api/client.py +++ b/sipro/api/client.py @@ -19,10 +19,10 @@ class SiproClient: self.initialized = True logger_instance.info('SiproClient successfully initialized') - def method(self, http_method: str, method: str, data: dict = None, raw=False): + def method(self, http_method: str, method: str, data: dict = None, raw=False, params: dict = None): url = self.api_url + '/assemblr' + method headers = {'Authorization': self.token} - response = requests.request(http_method, url, headers=headers, json=data) + response = requests.request(http_method, url, headers=headers, json=data, params=params) if raw: return response return response.json() diff --git a/sipro/api/orders.py b/sipro/api/orders.py index 4259fed..dbe0184 100644 --- a/sipro/api/orders.py +++ b/sipro/api/orders.py @@ -34,3 +34,9 @@ def get_orders(order_by: str, desc: int, page: int, shipment_date: str, status: method = f'{router}/getOrders?orderBy={order_by}&desc={desc}&page={page}&shipmentDate={shipment_date}&status={status}&shipmentWarehouseId={shipment_warehouse_id}' response = client.method('GET', method) return response + + +def get_orders_from_barcode(params: dict): + method = f'{router}/getByProductId' + response = client.method('GET', method, params=params) + return response