Skip to content

Commit 8ba9fe8

Browse files
committed
- Address feedback
1 parent 21f35fa commit 8ba9fe8

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

easypost/shipment.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@
2121

2222
class Shipment(AllResource, CreateResource):
2323
@classmethod
24-
def create(cls, api_key: Optional[str] = None, carbon_offset: Optional[bool] = False, **params) -> "Shipment":
24+
def create(cls, api_key: Optional[str] = None, with_carbon_offset: Optional[bool] = False, **params) -> "Shipment":
2525
"""Create an Shipment object."""
2626
requestor = Requestor(local_api_key=api_key)
2727
url = cls.class_url()
28-
wrapped_params = {cls.snakecase_name(): params, "carbon_offset": carbon_offset}
28+
wrapped_params = {
29+
cls.snakecase_name(): params,
30+
"carbon_offset": with_carbon_offset,
31+
}
2932
response, api_key = requestor.request(method=RequestMethod.POST, url=url, params=wrapped_params)
3033
return convert_to_easypost_object(response=response, api_key=api_key)
3134

32-
def regenerate_rates(self, carbon_offset: Optional[bool] = False) -> "Shipment":
35+
def regenerate_rates(self, with_carbon_offset: Optional[bool] = False) -> "Shipment":
3336
"""Regenerate rates for a shipment."""
3437
requestor = Requestor(local_api_key=self._api_key)
3538
url = "%s/%s" % (self.instance_url(), "rerate")
3639
params = {
37-
"carbon_offset": carbon_offset,
40+
"carbon_offset": with_carbon_offset,
3841
}
3942
response, api_key = requestor.request(method=RequestMethod.POST, url=url, params=params)
4043
self.refresh_from(values=response, api_key=api_key)
@@ -47,11 +50,11 @@ def get_smartrates(self) -> List[object]:
4750
response, _ = requestor.request(method=RequestMethod.GET, url=url)
4851
return response.get("result", [])
4952

50-
def buy(self, carbon_offset: Optional[bool] = False, **params) -> "Shipment":
53+
def buy(self, with_carbon_offset: Optional[bool] = False, **params) -> "Shipment":
5154
"""Buy a shipment."""
5255
requestor = Requestor(local_api_key=self._api_key)
5356
url = "%s/%s" % (self.instance_url(), "buy")
54-
params["carbon_offset"] = carbon_offset
57+
params["carbon_offset"] = with_carbon_offset
5558

5659
response, api_key = requestor.request(method=RequestMethod.POST, url=url, params=params)
5760
self.refresh_from(values=response, api_key=api_key)

tests/test_shipment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def test_generate_form(one_call_buy_shipment, rma_form_options):
248248

249249
@pytest.mark.vcr()
250250
def test_shipment_create_with_carbon_offset(carbon_offset_shipment):
251-
shipment = easypost.Shipment.create(carbon_offset=True, **carbon_offset_shipment)
251+
shipment = easypost.Shipment.create(with_carbon_offset=True, **carbon_offset_shipment)
252252

253253
assert isinstance(shipment, easypost.Shipment)
254254
assert shipment.rates is not None
@@ -266,7 +266,7 @@ def test_shipment_buy_with_carbon_offset(carbon_offset_shipment):
266266

267267
@pytest.mark.vcr()
268268
def test_shipment_one_call_buy_with_carbon_offset(carbon_offset_shipment_one_call_buy):
269-
shipment = easypost.Shipment.create(carbon_offset=True, **carbon_offset_shipment_one_call_buy)
269+
shipment = easypost.Shipment.create(with_carbon_offset=True, **carbon_offset_shipment_one_call_buy)
270270

271271
assert isinstance(shipment, easypost.Shipment)
272272
assert all(rate.carbon_offset is not None for rate in shipment.rates)

0 commit comments

Comments
 (0)