diff --git a/README.md b/README.md index bf9ecfe..06ef5c4 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ pip install square_database_helper ## changelog +### v2.3.0 + +- use make_request_json_output to call api endpoints. + ### v2.2.0 - expanded apply_filters to support additional conditions: ne, lt, lte, gt, gte, like, in_. diff --git a/setup.py b/setup.py index e25a7b1..390fdae 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,12 @@ setup( name=package_name, - version="2.2.0", + version="2.3.0", packages=find_packages(), - install_requires=["requests>=2.31.0", "pydantic>=2.9.2"], + install_requires=[ + "pydantic>=2.9.2", + "square_commons>=1.0.0", + ], author="thePmSquare", author_email="thepmsquare@gmail.com", description="helper to access the database layer for my personal server.", diff --git a/square_database_helper/main.py b/square_database_helper/main.py index d9b452d..5c2f81b 100644 --- a/square_database_helper/main.py +++ b/square_database_helper/main.py @@ -1,7 +1,7 @@ from typing import Dict, Any, Optional, List -import requests from pydantic import conlist +from square_commons.api_utils import make_request_json_output from square_database_helper.pydantic_models import FiltersV0 @@ -21,12 +21,16 @@ def __init__( except Exception: raise - def _make_request(self, method, endpoint, data=None): + def _make_request(self, method, endpoint, data=None, params=None, headers=None): try: - url = f"{self.global_str_square_database_url_base}/{endpoint}" - response = requests.request(method, url, json=data) - response.raise_for_status() - return response.json() + return make_request_json_output( + method=method, + base_url=self.global_str_square_database_url_base, + endpoint=endpoint, + data=data, + params=params, + headers=headers, + ) except Exception: raise