return GotifyErrorModel in upload_application_image
This commit is contained in:
@@ -113,13 +113,17 @@ class GotifyClient(GotifySession):
|
|||||||
|
|
||||||
def upload_application_image(
|
def upload_application_image(
|
||||||
self, application_id: int, img_path: str
|
self, application_id: int, img_path: str
|
||||||
) -> Optional[GotifyApplicationModel]:
|
) -> Optional[Union[GotifyApplicationModel, GotifyErrorModel]]:
|
||||||
try:
|
try:
|
||||||
with open(img_path, "rb") as f:
|
with open(img_path, "rb") as f:
|
||||||
response = self._post(
|
response = self._post(
|
||||||
f"/application/{application_id}/image", files={"file": f}
|
f"/application/{application_id}/image", files={"file": f}
|
||||||
)
|
)
|
||||||
return response.json() if response.ok else None
|
return (
|
||||||
|
GotifyApplicationModel(response.json())
|
||||||
|
if response.ok
|
||||||
|
else GotifyErrorModel(response)
|
||||||
|
)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"GotifyClient.upload_application_image: image '{img_path}' not found."
|
f"GotifyClient.upload_application_image: image '{img_path}' not found."
|
||||||
|
|||||||
Reference in New Issue
Block a user