Skip to content

Commit

Permalink
Release v0.0.36
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jul 21, 2023
1 parent 32de20b commit 5fec135
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "superagent-py"
version = "v0.0.35"
version = "v0.0.36"
description = ""
readme = "README.md"
authors = []
Expand All @@ -10,8 +10,8 @@ packages = [

[tool.poetry.dependencies]
python = "^3.7"
pydantic = "^1.9.2"
httpx = "0.23.3"
pydantic = "^1.9.2"

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
41 changes: 41 additions & 0 deletions src/superagent/resources/documents/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ def get_document(self, document_id: str) -> typing.Any:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def patch_document(self, document_id: str, *, request: typing.Dict[str, typing.Any]) -> typing.Any:
_response = httpx.request(
"PATCH",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{document_id}"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
if _response.status_code == 422:
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def delete_document(self, document_id: str) -> typing.Any:
_response = httpx.request(
"DELETE",
Expand Down Expand Up @@ -210,6 +230,27 @@ async def get_document(self, document_id: str) -> typing.Any:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def patch_document(self, document_id: str, *, request: typing.Dict[str, typing.Any]) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"PATCH",
urllib.parse.urljoin(f"{self._environment}/", f"api/v1/documents/{document_id}"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
if _response.status_code == 422:
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def delete_document(self, document_id: str) -> typing.Any:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
Expand Down

0 comments on commit 5fec135

Please sign in to comment.