Skip to content

Commit f4d8c7f

Browse files
committed
Revert "- Remove cancel claim function"
This reverts commit a659738.
1 parent a659738 commit f4d8c7f

File tree

5 files changed

+738
-13
lines changed

5 files changed

+738
-13
lines changed

easypost/services/base_service.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ def _create_resource(self, class_name: str, beta: bool = False, **params) -> Any
5151

5252
return convert_to_easypost_object(response=response)
5353

54-
def _all_resources(
55-
self, class_name: str, filters: Optional[Dict[str, Any]] = None, beta: bool = False, **params
56-
) -> Any:
54+
def _all_resources(self, class_name: str, filters: Optional[Dict[str, Any]] = None, beta: bool = False, **params) -> Any:
5755
"""Retrieve a list of EasyPostObjects from the EasyPost API."""
5856
url = self._class_url(class_name)
5957
response = Requestor(self._client).request(method=RequestMethod.GET, url=url, params=params, beta=beta)
@@ -71,9 +69,7 @@ def _retrieve_resource(self, class_name: str, id: str, beta: bool = False) -> An
7169

7270
return convert_to_easypost_object(response=response)
7371

74-
def _update_resource(
75-
self, class_name: str, id: str, method: RequestMethod = RequestMethod.PATCH, beta: bool = False, **params
76-
) -> Any:
72+
def _update_resource(self, class_name: str, id: str, method: RequestMethod = RequestMethod.PATCH, beta: bool = False, **params) -> Any:
7773
"""Update an EasyPost object via the EasyPost API."""
7874
url = self._instance_url(class_name, id)
7975
wrapped_params = {self._snakecase_name(class_name): params}

easypost/services/claim_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ def get_next_page(
5656
params.update(optional_params)
5757

5858
return self.all(**params)
59+
60+
def cancel(self, id: str) -> Claim:
61+
"""Cancel a Claim."""
62+
url = f"/claims/{id}/cancel"
63+
64+
response = Requestor(self._client).request(
65+
method=RequestMethod.POST,
66+
url=url,
67+
beta=True,
68+
)
69+
70+
return convert_to_easypost_object(response=response)

0 commit comments

Comments
 (0)