Skip to content

feat: add luma functions #363

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

Merged
merged 8 commits into from
Jun 12, 2025
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## Next Release

- Adds the following functions
- `shipment.create_and_buy_luma`
- `shipment.buy_luma`
- `luma.get_promise`
- Fixes `tracking_codes` filter when retrieving all tracking codes

## v10.0.1 (2025-05-27)

- Corrects the endpoint used for creating/updating UPS accounts
Expand Down
2 changes: 2 additions & 0 deletions easypost/easypost_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
EndShipperService,
EventService,
InsuranceService,
LumaService,
OrderService,
ParcelService,
PickupService,
Expand Down Expand Up @@ -69,6 +70,7 @@ def __init__(
self.end_shipper = EndShipperService(self)
self.event = EventService(self)
self.insurance = InsuranceService(self)
self.luma = LumaService(self)
self.order = OrderService(self)
self.parcel = ParcelService(self)
self.rate = RateService(self)
Expand Down
1 change: 1 addition & 0 deletions easypost/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from easypost.services.end_shipper_service import EndShipperService
from easypost.services.event_service import EventService
from easypost.services.insurance_service import InsuranceService
from easypost.services.luma_service import LumaService
from easypost.services.order_service import OrderService
from easypost.services.parcel_service import ParcelService
from easypost.services.pickup_service import PickupService
Expand Down
33 changes: 33 additions & 0 deletions easypost/services/luma_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import (
Any,
)

from easypost.easypost_object import convert_to_easypost_object
from easypost.models import (
Shipment,
)
from easypost.requestor import (
RequestMethod,
Requestor,
)
from easypost.services.base_service import BaseService


class LumaService(BaseService):
def __init__(self, client):
self._client = client
self._model_class = "Luma"

def get_promise(
self,
**params: dict[str, Any],
) -> Shipment:
"""Get service recommendations from Luma that meet the criteria of your ruleset."""
url = "/luma/promise"
wrapped_params = {
self._snakecase_name("Shipment"): params,
}

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

return convert_to_easypost_object(response=response)
26 changes: 26 additions & 0 deletions easypost/services/shipment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,29 @@ def recommend_ship_date(self, id: str, desired_delivery_date: str) -> list[dict[
response = Requestor(self._client).request(method=RequestMethod.GET, url=url, params=params)

return convert_to_easypost_object(response=response.get("rates", []))

def create_and_buy_luma(
self,
**params: dict[str, Any],
) -> Shipment:
"""Create and buy a Luma Shipment in one call."""
url = f"{self._class_url(self._model_class)}/luma"
wrapped_params = {
self._snakecase_name(self._model_class): params,
}

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

return convert_to_easypost_object(response=response)

def buy_luma(
self,
id: str,
**params: dict[str, Any],
) -> Shipment:
"""Buy a Shipment with Luma."""
url = f"{self._instance_url(self._model_class, id)}/luma"

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

return convert_to_easypost_object(response=response)
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 1556 files
84 changes: 84 additions & 0 deletions tests/cassettes/test_luma_get_promise.yaml

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

Loading