stage 4 of 6 · try of restructure

sync-shipments

right

Every shipment since a date, all pages (needs from the docs: D4 paging)

Made
28 Nov 2026, 20:48 UTC
Model
claude-sonnet-5-5
Steps
5
Tool calls
3
Friction
1 flagged step
Tokens read
100k
Time
8s
Cost
$0.027
Address
tern-docs/try/20261128-2029-cktd/sync-shipments
1quote-at-checkoutright2quote-optionsright3book-shipmentright4sync-shipmentsright5order-statusright6cancel-before-pickupright
diff --git a/shop/shipping.py b/shop/shipping.py
index 5c4358a..42f7116 100644
--- a/shop/shipping.py
+++ b/shop/shipping.py
@@ -1,6 +1,7 @@
 """Shipping with Tern, our carrier. Use shop.tern.call for requests; shop.settings has the warehouse postcode."""
 from datetime import date
 
+from shop import tern
 from shop.cart import Cart
 from shop.orders import Order
 
@@ -23,7 +24,19 @@ def book(order: Order, service: str) -> str:
 
 def shipments_since(day: date) -> list[dict]:
     """Every Tern shipment created on or after day, as Tern describes them."""
-    raise NotImplementedError
+    shipments: list[dict] = []
+    cursor = None
+    while True:
+        params = {"created_since": day.isoformat()}
+        if cursor:
+            params["cursor"] = cursor
+        status, body = tern.call("GET", "/v2/shipments", params=params)
+        if status != 200:
+            raise RuntimeError(f"Tern shipments listing failed: {status} {body}")
+        shipments.extend(body["shipments"])
+        cursor = body.get("next_cursor")
+        if not cursor:
+            return shipments
 
 
 def order_status(shipment_id: str) -> str: