Skip to content

Commit b7d71f5

Browse files
authored
Merge pull request #363 from EasyPost/luma
feat: add luma functions
2 parents 7a0cffb + e4f8a7c commit b7d71f5

File tree

12 files changed

+631
-1
lines changed

12 files changed

+631
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds the following functions
6+
- `shipment.create_and_buy_luma`
7+
- `shipment.buy_luma`
8+
- `luma.get_promise`
9+
- Fixes `tracking_codes` filter when retrieving all tracking codes
10+
311
## v10.0.1 (2025-05-27)
412

513
- Corrects the endpoint used for creating/updating UPS accounts

easypost/easypost_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
EndShipperService,
2525
EventService,
2626
InsuranceService,
27+
LumaService,
2728
OrderService,
2829
ParcelService,
2930
PickupService,
@@ -69,6 +70,7 @@ def __init__(
6970
self.end_shipper = EndShipperService(self)
7071
self.event = EventService(self)
7172
self.insurance = InsuranceService(self)
73+
self.luma = LumaService(self)
7274
self.order = OrderService(self)
7375
self.parcel = ParcelService(self)
7476
self.rate = RateService(self)

easypost/services/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from easypost.services.end_shipper_service import EndShipperService
1414
from easypost.services.event_service import EventService
1515
from easypost.services.insurance_service import InsuranceService
16+
from easypost.services.luma_service import LumaService
1617
from easypost.services.order_service import OrderService
1718
from easypost.services.parcel_service import ParcelService
1819
from easypost.services.pickup_service import PickupService

easypost/services/luma_service.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import (
2+
Any,
3+
)
4+
5+
from easypost.easypost_object import convert_to_easypost_object
6+
from easypost.models import (
7+
Shipment,
8+
)
9+
from easypost.requestor import (
10+
RequestMethod,
11+
Requestor,
12+
)
13+
from easypost.services.base_service import BaseService
14+
15+
16+
class LumaService(BaseService):
17+
def __init__(self, client):
18+
self._client = client
19+
self._model_class = "Luma"
20+
21+
def get_promise(
22+
self,
23+
**params: dict[str, Any],
24+
) -> Shipment:
25+
"""Get service recommendations from Luma that meet the criteria of your ruleset."""
26+
url = "/luma/promise"
27+
wrapped_params = {
28+
self._snakecase_name("Shipment"): params,
29+
}
30+
31+
response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
32+
33+
return convert_to_easypost_object(response=response)

easypost/services/shipment_service.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,29 @@ def recommend_ship_date(self, id: str, desired_delivery_date: str) -> list[dict[
161161
response = Requestor(self._client).request(method=RequestMethod.GET, url=url, params=params)
162162

163163
return convert_to_easypost_object(response=response.get("rates", []))
164+
165+
def create_and_buy_luma(
166+
self,
167+
**params: dict[str, Any],
168+
) -> Shipment:
169+
"""Create and buy a Luma Shipment in one call."""
170+
url = f"{self._class_url(self._model_class)}/luma"
171+
wrapped_params = {
172+
self._snakecase_name(self._model_class): params,
173+
}
174+
175+
response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
176+
177+
return convert_to_easypost_object(response=response)
178+
179+
def buy_luma(
180+
self,
181+
id: str,
182+
**params: dict[str, Any],
183+
) -> Shipment:
184+
"""Buy a Shipment with Luma."""
185+
url = f"{self._instance_url(self._model_class, id)}/luma"
186+
187+
response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=params)
188+
189+
return convert_to_easypost_object(response=response)

examples

Submodule examples updated 1556 files

tests/cassettes/test_luma_get_promise.yaml

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)