Add PATCH convenience method
This commit is contained in:
parent
5578fcc43e
commit
d535e879ed
@ -14,6 +14,7 @@ convenience methods:
|
|||||||
- `self.__get`
|
- `self.__get`
|
||||||
- `self.__post`
|
- `self.__post`
|
||||||
- `self.__put`
|
- `self.__put`
|
||||||
|
- `self.__patch`
|
||||||
- `self.__delete`
|
- `self.__delete`
|
||||||
|
|
||||||
## Error Handling
|
## Error Handling
|
||||||
|
@ -104,6 +104,20 @@ class ApiWrapper:
|
|||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise InvalidApiResponse('Invalid JSON received')
|
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):
|
def __delete(self, endpoint):
|
||||||
url = self.base_url + endpoint
|
url = self.base_url + endpoint
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user