From a8c5bedc5251982a8b598f9344527e232e8186a7 Mon Sep 17 00:00:00 2001 From: ka Date: Tue, 18 Jun 2024 00:06:51 -0300 Subject: [PATCH] feat: added bling api requests --- ajusta_bling/bling/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ajusta_bling/bling/__init__.py diff --git a/ajusta_bling/bling/__init__.py b/ajusta_bling/bling/__init__.py new file mode 100644 index 0000000..1af226d --- /dev/null +++ b/ajusta_bling/bling/__init__.py @@ -0,0 +1,29 @@ +import requests + +from ajusta_bling import Database + +BLING_API_URL = "https://bling.com.br/Api/v3" + +def get_inactive_products(page: int) -> any: + try: + request = requests.get("%s/produtos" % BLING_API_URL, params={"criterio": 3, "pagina": page}) + return request.json()['data'] + except requests.exceptions.RequestException as e: + print(e) + return False + +def get_product_variations(product_id: int) -> any: + try: + request = requests.get("%s/produtos/variacoes/%s" % (BLING_API_URL, product_id)) + return request.json()['data'] + except requests.exceptions.RequestException as e: + print(e) + return False + +def get_product_structure(product_id: int) -> any: + try: + request = requests.get("%s/produtos/estruturas/%s" % (BLING_API_URL, product_id)) + return request.json()['data'] + except requests.exceptions.RequestException as e: + print(e) + return False \ No newline at end of file