filters in orders by product

This commit is contained in:
2023-11-16 03:28:36 +03:00
parent cba9d37cdb
commit 57bb4fd5e4
3 changed files with 11 additions and 5 deletions

View File

@@ -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')

View File

@@ -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()

View File

@@ -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