Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix regenerate rates type #318

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v9.0.1 (2023-12-20)

- Corrects the return type of `regenerate_rates`

## v9.0.0 (2023-12-06)

See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-8x-to-90) for more details.
Expand Down
2 changes: 1 addition & 1 deletion easypost/services/shipment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_next_page(

return self.all(**params)

def regenerate_rates(self, id: str) -> Shipment:
def regenerate_rates(self, id: str) -> Dict[str, List[Rate]]:
Justintime50 marked this conversation as resolved.
Show resolved Hide resolved
"""Regenerate Rates for a Shipment."""
url = f"{self._instance_url(self._model_class, id)}/rerate"

Expand Down
8 changes: 5 additions & 3 deletions easypost/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Dict,
List,
Optional,
Union,
)

from easypost.constant import (
Expand All @@ -24,14 +25,15 @@
InvalidParameterError,
SignatureVerificationError,
)
from easypost.models.rate import Rate


def get_lowest_object_rate(
easypost_object: EasyPostObject,
easypost_object: Union[EasyPostObject, Dict[str, Any]],
carriers: Optional[List[str]] = None,
services: Optional[List[str]] = None,
rates_key: str = "rates",
):
) -> Rate:
"""Gets the lowest rate of an EasyPost object such as a Shipment, Order, or Pickup."""
carriers = carriers or []
services = services or []
Expand All @@ -53,7 +55,7 @@ def get_lowest_object_rate(
return lowest_rate


def get_lowest_smart_rate(smart_rates, delivery_days: int, delivery_accuracy: str):
def get_lowest_smart_rate(smart_rates: List[Rate], delivery_days: int, delivery_accuracy: str) -> Rate:
"""Get the lowest SmartRate from a list of SmartRates."""
valid_delivery_accuracy_values = {
"percentile_50",
Expand Down