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