Skip to content

Commit

Permalink
Remove withCarbonOffset param (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 authored Nov 28, 2023
1 parent 582439f commit d578a73
Show file tree
Hide file tree
Showing 46 changed files with 5,061 additions and 5,851 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Next major release

- Removed `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free

## v8.2.1 (2023-10-30)

- Fixes a bug where `get_next_page` functions threw an error, preventing users from retrieving the final page of results
Expand Down
10 changes: 3 additions & 7 deletions easypost/services/shipment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ def __init__(self, client):
self._client = client
self._model_class = Shipment.__name__

def create(self, with_carbon_offset: Optional[bool] = False, **params) -> Shipment:
def create(self, **params) -> Shipment:
"""Create a Shipment."""
url = self._class_url(self._model_class)
wrapped_params = {
self._snakecase_name(self._model_class): params,
"carbon_offset": with_carbon_offset,
}

response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
Expand Down Expand Up @@ -73,12 +72,11 @@ def get_next_page(

return self.all(**params)

def regenerate_rates(self, id: str, with_carbon_offset: Optional[bool] = False) -> Shipment:
def regenerate_rates(self, id: str) -> Shipment:
"""Regenerate Rates for a Shipment."""
url = f"{self._instance_url(self._model_class, id)}/rerate"
wrapped_params = {"carbon_offset": with_carbon_offset}

response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
response = Requestor(self._client).request(method=RequestMethod.POST, url=url)

return convert_to_easypost_object(response=response)

Expand All @@ -93,13 +91,11 @@ def get_smart_rates(self, id: str) -> List[Rate]:
def buy(
self,
id: str,
with_carbon_offset: Optional[bool] = False,
end_shipper_id: Optional[str] = None,
**params,
) -> Shipment:
"""Buy a Shipment."""
url = f"{self._instance_url(self._model_class, id)}/buy"
params["carbon_offset"] = with_carbon_offset
if end_shipper_id:
params["end_shipper_id"] = end_shipper_id

Expand Down
215 changes: 107 additions & 108 deletions tests/cassettes/test_batch_add_remove_shipment.yaml

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions tests/cassettes/test_error.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 34 additions & 36 deletions tests/cassettes/test_insurance_all.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d578a73

Please sign in to comment.