Skip to content

Commit

Permalink
Merge pull request #89 from MrCreosote/dev-post_with_json
Browse files Browse the repository at this point in the history
Add `json` kwarg to `[Async]Client.post()`
  • Loading branch information
cjh1 authored Sep 13, 2024
2 parents 0813d8f + 9cfacf8 commit c0a24bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/sfapi_client/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,15 @@ async def get(self, url: str, params: Dict[str, Any] = {}) -> httpx.Response:
wait=tenacity.wait_exponential(max=MAX_RETRY),
stop=tenacity.stop_after_attempt(MAX_RETRY),
)
async def post(self, url: str, data: Dict[str, Any]) -> httpx.Response:
async def post(
self, url: str, data: Dict[str, Any] = None, json: Dict[str, Any] = None
) -> httpx.Response:
client = await self._http_client()

r = await client.post(
f"{self._api_base_url}/{url}",
data=data,
json=json,
)
r.raise_for_status()

Expand Down
8 changes: 7 additions & 1 deletion src/sfapi_client/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,18 @@ def get(self, url: str, params: Dict[str, Any] = {}) -> httpx.Response:
wait=tenacity.wait_exponential(max=MAX_RETRY),
stop=tenacity.stop_after_attempt(MAX_RETRY),
)
def post(self, url: str, data: Dict[str, Any]) -> httpx.Response:
def post(
self,
url: str,
data: Dict[str, Any] = None,
json: Dict[str, Any] = None
) -> httpx.Response:
client = self._http_client()

r = client.post(
f"{self._api_base_url}/{url}",
data=data,
json=json,
)
r.raise_for_status()

Expand Down

0 comments on commit c0a24bc

Please sign in to comment.