Skip to content

Commit

Permalink
✨ use make_request_json_output to call api endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
thepmsquare committed Nov 13, 2024
1 parent c17bfd7 commit bcbd396
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_.
Expand Down
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
16 changes: 10 additions & 6 deletions square_database_helper/main.py
Original file line number Diff line number Diff line change
@@ -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

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

Expand Down

0 comments on commit bcbd396

Please sign in to comment.