From be9d70ef3cbc81b0f5f19f339fdd5a870d3a7473 Mon Sep 17 00:00:00 2001 From: Jordan Maynor Date: Thu, 22 Aug 2024 09:50:17 -0500 Subject: [PATCH] Added several status checks, upped version --- ezoff/members.py | 40 ++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ezoff/members.py b/ezoff/members.py index fce0ab2..59a39f5 100644 --- a/ezoff/members.py +++ b/ezoff/members.py @@ -180,6 +180,16 @@ def create_member(member: dict) -> dict: "Error, could not create member in EZOfficeInventory: " + str(e) ) + if response.status_code != 200: + print( + f"Error {response.status_code}, could not create member in EZOfficeInventory: ", + response.content, + ) + raise Exception( + f"Error {response.status_code}, could not create member in EZOfficeInventory: " + + str(response.content) + ) + return response.json() @@ -226,6 +236,16 @@ def update_member(member_id: int, member: dict) -> dict: "Error, could not update member in EZOfficeInventory: " + str(e) ) + if response.status_code != 200: + print( + f"Error {response.status_code}, could not update member in EZOfficeInventory: ", + response.content, + ) + raise Exception( + f"Error {response.status_code}, could not update member in EZOfficeInventory: " + + str(response.content) + ) + return response.json() @@ -250,6 +270,16 @@ def deactivate_member(member_id: int) -> dict: "Error, could not deactivate member in EZOfficeInventory: " + str(e) ) + if response.status_code != 200: + print( + f"Error {response.status_code}, could not deactivate member in EZOfficeInventory: ", + response.content, + ) + raise Exception( + f"Error {response.status_code}, could not deactivate member in EZOfficeInventory: " + + str(response.content) + ) + return response.json() @@ -274,6 +304,16 @@ def activate_member(member_id: int) -> dict: "Error, could not activate member in EZOfficeInventory: " + str(e) ) + if response.status_code != 200: + print( + f"Error {response.status_code}, could not activate member in EZOfficeInventory: ", + response.content, + ) + raise Exception( + f"Error {response.status_code}, could not activate member in EZOfficeInventory: " + + str(response.content) + ) + return response.json() diff --git a/setup.py b/setup.py index d1d6007..334ab33 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name="ezoff", - version="0.1.1", + version="0.1.2", description="Python package that acts as a wrapper for the EZOffice API.", long_description=long_description, long_description_content_type="text/markdown",