diff --git a/README.md b/README.md index 5f96914..bf1779b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ convenience methods: - `self.__get` - `self.__post` - `self.__put` +- `self.__patch` - `self.__delete` ## Error Handling diff --git a/src/wrapper.py b/src/wrapper.py index 565ecc8..47594e5 100644 --- a/src/wrapper.py +++ b/src/wrapper.py @@ -104,6 +104,20 @@ class ApiWrapper: except json.JSONDecodeError: raise InvalidApiResponse('Invalid JSON received') + def __patch(self, endpoint, data=None): + url = self.base_url + endpoint + + try: + response = self.session.put(url, data=data) + response.raise_for_status() + except requests.RequestException as e: + raise ApiRequestException(f'Failed to execute PATCH request: {str(e)}') + + try: + return response.json() + except json.JSONDecodeError: + raise InvalidApiResponse('Invalid JSON received') + def __delete(self, endpoint): url = self.base_url + endpoint