:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse_sources): add lightspeed retail promotions, gift card and stock adjustment tables (#114902)
Tom Owers29b1a9dda41f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 43c5d59fd7d0..3565542efc65 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -5174,12 +5174,12 @@ Diffed against: <https://x-series-api.lightspeedhq.com/reference/listcustomers>- [x] `consignment_products (GET /api/2.0/consignments/{id}/products)` — line items of each stock order, needed for received-vs-ordered and cost analysis (high)- [x] `suppliers (GET /api/2.0/suppliers)` — lookup resolving the supplier_id carried on products and consignments (high)- [x] `payment_types (GET /api/2.0/payment_types)` — lookup resolving payment type IDs on the sale payments we already sync (high)-- [ ] `product_categories (GET /api/2.0/product_categories)` — lookup for category IDs on products - required for any category-level sales breakdown (high)+- [x] `product_categories (GET /api/2.0/product_categories)` — lookup for category IDs on products - required for any category-level sales breakdown (high)- [ ] `brands (GET /api/2.0/brands)` — lookup resolving brand_id on products (medium)- [ ] `customer_groups (+ /customer_groups/{id}/customers)` — customer segment membership table for cohort and loyalty analysis (medium)-- [ ] `stock_adjustments (GET /api/2.0/stock_adjustments)` — inventory movement/shrinkage records that explain changes in the inventory table we sync (medium)-- [ ] `promotions (+ /promotions/{id}/products, promo codes)` — discount campaigns and their product scope; needed to attribute discounted revenue (medium)-- [ ] `gift_cards (+ gift card transactions)` — outstanding liability and gift-card redemption transactions (medium)+- [x] `stock_adjustments (GET /api/2.0/stock_adjustments)` — inventory movement/shrinkage records that explain changes in the inventory table we sync (medium)+- [x] `promotions (+ /promotions/{id}/products, promo codes)` — discount campaigns and their product scope; needed to attribute discounted revenue (medium)+- [x] `gift_cards (+ gift card transactions)` — outstanding liability and gift-card redemption transactions (medium)- [ ] `store_credits (+ transactions and balances)` — store credit liability and per-customer transaction ledger (medium)- [ ] `shifts (GET /api/2.0/shifts)` — register shift open/close records for labor and till-reconciliation analysis (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/canonical_descriptions.pyindex 52862de22dfe..f38a160839e2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/canonical_descriptions.py@@ -204,4 +204,98 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {created_at="Time at which the payment type was created.",),},+ "product_categories": {+ "description": "A product category in the Lightspeed Retail category hierarchy.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/listproductcategories",+ "columns": {+ "id": "The category ID.",+ "name": "The name of the category.",+ "parent_category_id": "ID of the parent category, or null for a root category.",+ "root_category_id": "ID of the root of the category tree. A root category references itself.",+ "leaf_category": "Whether the category has no child categories.",+ "category_path": "The categories from the root down to this category, each with its ID and name.",+ },+ },+ "stock_adjustments": {+ "description": "A manual stock adjustment for a product at an outlet in Lightspeed Retail, e.g. damage, theft or stock found.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/liststockadjustments",+ "columns": _columns(+ product_id="ID of the product that was adjusted.",+ outlet_id="ID of the outlet where the adjustment was recorded.",+ user_id="ID of the user who created the adjustment.",+ quantity="Quantity adjusted. Negative for stock removed, positive for stock added.",+ reason="Reason for the adjustment: DAMAGE, EXPIRY, INTERNAL_USE, THEFT, DONATION, STOCK_FOUND, SAMPLE_FOR_SALE or CUSTOM.",+ custom_inventory_adjustment_reason_id="ID of the custom reason. Set only when reason is CUSTOM.",+ created_at="Time at which the adjustment was created.",+ updated_at="Time at which the adjustment was last updated.",+ ),+ },+ "promotions": {+ "description": "A promotion in Lightspeed Retail: the rules and discount applied to the products it covers.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/listpromotions",+ "columns": {+ "id": "Unique identifier for the promotion.",+ "name": "The name of the promotion.",+ "description": "A short description of the promotion.",+ "status": "The status of the promotion.",+ "start_time": "Time the promotion begins, in UTC.",+ "end_time": "Time the promotion ends, in UTC.",+ "condition": "Condition a sale must meet for the promotion to apply, with the product filters it includes and excludes.",+ "action": "Discount the promotion applies (type and value), with the product filters it includes and excludes.",+ "channels": "Channels the promotion applies to: Register, Ecommerce.",+ "outlet_ids": "IDs of the outlets the promotion applies at.",+ "customer_group_ids": "IDs of the customer groups the promotion applies to.",+ "online_channel_ids": "IDs of the online channels the promotion applies to.",+ "use_promo_code": "Whether the promotion requires a promo code.",+ "promo_code_summary": "Totals for the promotion's promo codes, including the redeemed amount.",+ "combinable_with_coupon": "Whether the promotion can be combined with an online coupon.",+ "loyalty_multiplier": "The loyalty multiplier for the promotion.",+ },+ },+ "promo_codes": {+ "description": "A promo code that unlocks a Lightspeed Retail promotion.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/getpromotionpromocodes",+ "columns": {+ "id": "Unique identifier for the promo code.",+ "promotion_id": "ID of the promotion the code unlocks.",+ "code": "The code a customer enters.",+ "group_name": "Name of the group the code belongs to.",+ "limit": "Redemption limit for the code.",+ "redeemed": "Number of times the code has been redeemed.",+ "created_user_id": "ID of the user who created the code.",+ "created_at": "Time at which the code was created.",+ },+ },+ "gift_cards": {+ "description": "A Lightspeed Retail gift card with its balance and transaction history.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/listgiftcards",+ "columns": {+ "id": "Unique identifier for the gift card.",+ "number": "The gift card number.",+ "status": "Status of the gift card: ACTIVE, INACTIVE, REDEEMED, VOIDED or EXPIRED.",+ "balance": "Remaining balance on the gift card.",+ "total_sold": "Amount loaded onto the gift card when activated or reloaded.",+ "total_redeemed": "Amount redeemed with the gift card.",+ "sale_id": "ID of the sale that created the gift card. Null when it was created through the API.",+ "sale_source": "System the gift card was created in (e.g. x-series, e-series).",+ "gift_card_transactions": "The gift card's transactions.",+ "expires_at": "Time at which the gift card expires, in UTC.",+ "created_at": "Time at which the gift card was created, in UTC.",+ },+ },+ "gift_card_transactions": {+ "description": "A transaction on a Lightspeed Retail gift card, such as an activation, redemption or reload.",+ "docs_url": "https://x-series-api.lightspeedhq.com/reference/listgiftcards",+ "columns": {+ "id": "Unique identifier for the transaction.",+ "gift_card_id": "ID of the gift card the transaction belongs to.",+ "type": "Transaction type: ACTIVATION, REDEEMING, IMPORTING, VOIDING, EXPIRING, REVERSING or RELOADING.",+ "amount": "Transaction amount. Redemptions are negative.",+ "client_id": "Unique transaction identifier from the client system that created it.",+ "source": "Source of the transaction.",+ "source_id": "Identifier of the transaction in the source system.",+ "user_id": "ID of the user associated with the transaction.",+ "created_at": "Time at which the transaction was created, in UTC.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/lightspeed_retail.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/lightspeed_retail.pyindex 47865b29d26f..5d4995341e44 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/lightspeed_retail.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/lightspeed_retail.py@@ -13,14 +13,18 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (build_dependent_resource,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import BasePaginator+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (+ BasePaginator,+ JSONResponseCursorPaginator,+ SinglePagePaginator,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfigfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.lightspeed_retail.settings import (LIGHTSPEED_RETAIL_ENDPOINTS,- PAGE_SIZE,+ LightspeedRetailEndpointConfig,)@@ -33,6 +37,8 @@ class LightspeedRetailResumeConfig:# Fan-out endpoints checkpoint the `build_dependent_resource` shape instead: which parent# consignments finished and where the current one stopped.fanout_state: Optional[dict[str, Any]] = None+ # Endpoints without a record version page on an id cursor instead.+ cursor: Optional[str] = Nonedef _clean_domain_prefix(domain_prefix: str) -> str:@@ -116,6 +122,80 @@ class LightspeedRetailPaginator(BasePaginator):self._has_next_page = True+class LightspeedRetailAfterCursorPaginator(JSONResponseCursorPaginator):+ """`after=<page_info.last_seen>` pagination, stopping when `page_info.has_next` is false."""++ def __init__(self) -> None:+ super().__init__(cursor_path="page_info.last_seen", cursor_param="after")++ def update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:+ if not (response.json().get("page_info") or {}).get("has_next"):+ self._has_next_page = False+ return+ super().update_state(response, data)+++class LightspeedRetailBeforeIdPaginator(BasePaginator):+ """Newest-to-oldest pagination: `before=<id of the last item on the current page>`."""++ def __init__(self) -> None:+ super().__init__()+ self._before: Optional[str] = None++ def _apply_before(self, request: Request) -> None:+ if self._before is not None:+ if request.params is None:+ request.params = {}+ request.params["before"] = self._before++ def init_request(self, request: Request) -> None:+ self._apply_before(request)++ def update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:+ items = data or []+ last_id = items[-1].get("id") if items else None+ if not last_id or str(last_id) == self._before:+ self._has_next_page = False+ return+ self._before = str(last_id)+ self._has_next_page = True++ def update_request(self, request: Request) -> None:+ self._apply_before(request)++ def get_resume_state(self) -> Optional[dict[str, Any]]:+ if self._has_next_page and self._before is not None:+ return {"cursor": self._before}+ return None++ def set_resume_state(self, state: dict[str, Any]) -> None:+ cursor = state.get("cursor")+ if cursor is not None:+ self._before = str(cursor)+ self._has_next_page = True+++def _make_paginator(config: LightspeedRetailEndpointConfig) -> BasePaginator:+ if config.pagination == "after_cursor":+ return LightspeedRetailAfterCursorPaginator()+ if config.pagination == "before_id":+ return LightspeedRetailBeforeIdPaginator()+ if config.pagination == "single_page":+ return SinglePagePaginator()+ return LightspeedRetailPaginator()+++def _endpoint_params(config: LightspeedRetailEndpointConfig) -> dict[str, Any]:+ return {} if config.pagination == "single_page" else {"page_size": config.page_size}+++def _nested_rows(field_name: str, parent_key: str) -> Callable[[dict[str, Any]], list[dict[str, Any]]]:+ def _explode(item: dict[str, Any]) -> list[dict[str, Any]]:+ return [{**row, parent_key: item.get("id")} for row in item.get(field_name) or []]++ return _explode++def lightspeed_retail_source(domain_prefix: str,api_token: str,@@ -133,7 +213,7 @@ def lightspeed_retail_source("base_url": _base_url(domain_prefix, api_version),# Bearer auth via the framework so the token is redacted from logs and errors."auth": {"type": "bearer", "token": api_token},- "paginator": LightspeedRetailPaginator(),+ "paginator": _make_paginator(config),}resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None@@ -144,14 +224,19 @@ def lightspeed_retail_source(if state:resumable_source_manager.save_state(LightspeedRetailResumeConfig(fanout_state=state))+ parent_config = LIGHTSPEED_RETAIL_ENDPOINTS[config.fanout.parent_name]child = build_dependent_resource(endpoint_configs=LIGHTSPEED_RETAIL_ENDPOINTS,child_endpoint=endpoint,fanout=config.fanout,client_config=client_config,- parent_endpoint_extra={"data_selector": "data"},- child_endpoint_extra={"data_selector": "data"},- page_size_param="page_size",+ parent_endpoint_extra={+ "data_selector": parent_config.data_selector,+ "paginator": _make_paginator(parent_config),+ },+ child_endpoint_extra={"data_selector": config.data_selector},+ # The helper sends the size param to parent and child alike, so only a paged pair gets it.+ page_size_param=None if parent_config.pagination == "single_page" else "page_size",path_format_values={},team_id=team_id,job_id=job_id,@@ -169,9 +254,9 @@ def lightspeed_retail_source("name": endpoint,"endpoint": {"path": config.path,- "params": {"page_size": PAGE_SIZE},+ "params": _endpoint_params(config),# A missing `data` key is a legit empty page (stop), not an error.- "data_selector": "data",+ "data_selector": config.data_selector,},}],@@ -182,16 +267,24 @@ def lightspeed_retail_source(initial_after: Optional[int] = Noneif resume is not None:initial_after = resume.after- elif should_use_incremental_field:+ elif should_use_incremental_field and config.pagination == "version":initial_after = _to_version(db_incremental_field_last_value)- initial_paginator_state: Optional[dict[str, Any]] = {"after": initial_after} if initial_after is not None else None+ initial_paginator_state: Optional[dict[str, Any]] = None+ if initial_after is not None:+ initial_paginator_state = {"after": initial_after}+ elif resume is not None and resume.cursor is not None:+ initial_paginator_state = {"cursor": resume.cursor}def save_checkpoint(state: Optional[dict[str, Any]]) -> None:# Save AFTER a page is yielded so a crash re-yields the last page (merge# dedupes on primary key) rather than skipping it.- if state and state.get("after") is not None:+ if not state:+ return+ if state.get("after") is not None:resumable_source_manager.save_state(LightspeedRetailResumeConfig(after=int(state["after"])))+ elif state.get("cursor") is not None:+ resumable_source_manager.save_state(LightspeedRetailResumeConfig(cursor=str(state["cursor"])))resource = rest_api_resource(rest_config,@@ -201,6 +294,8 @@ def lightspeed_retail_source(resume_hook=save_checkpoint,initial_paginator_state=initial_paginator_state,)+ if config.nested_rows_field and config.nested_parent_key:+ resource.add_map(_nested_rows(config.nested_rows_field, config.nested_parent_key))return _source_response(endpoint, lambda: resource, resource.column_hints)@@ -218,8 +313,7 @@ def _source_response(partition_mode="datetime" if config.partition_key else None,partition_format="month" if config.partition_key else None,partition_keys=[config.partition_key] if config.partition_key else None,- # Keyset pagination on the monotonic version yields ascending version order.- sort_mode="asc",+ sort_mode=config.sort_mode,column_hints=column_hints,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/settings.pyindex 23d419764b6b..12daa8be0b31 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/settings.py@@ -1,5 +1,5 @@from dataclasses import dataclass, field-from typing import Optional+from typing import Literal, Optionalfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (DependentEndpointConfig,@@ -22,6 +22,13 @@ _VERSION_INCREMENTAL_FIELDS: list[IncrementalField] = []+# - "version": keyset over the record `version` (`after=<version>`), the X-Series default.+# - "after_cursor": `after=<page_info.last_seen>`, for endpoints whose records carry no version.+# - "before_id": `before=<id of the last item>`, newest to oldest.+# - "single_page": the endpoint takes no page cursor and returns the full list.+Pagination = Literal["version", "after_cursor", "before_id", "single_page"]++@dataclass(frozen=True)class LightspeedRetailEndpointConfig:name: str@@ -34,6 +41,13 @@ class LightspeedRetailEndpointConfig:fanout: Optional[DependentEndpointConfig] = Nonepage_size: int = PAGE_SIZEdefault_incremental_field: Optional[str] = None+ pagination: Pagination = "version"+ data_selector: str = "data"+ sort_mode: Literal["asc", "desc"] = "asc"+ # Emits one row per entry of this nested list, tagged with the parent record's id under+ # `nested_parent_key`, instead of one row per record.+ nested_rows_field: Optional[str] = None+ nested_parent_key: Optional[str] = NoneLIGHTSPEED_RETAIL_ENDPOINTS: dict[str, LightspeedRetailEndpointConfig] = {@@ -102,6 +116,59 @@ LIGHTSPEED_RETAIL_ENDPOINTS: dict[str, LightspeedRetailEndpointConfig] = {name="payment_types",path="/payment_types",),+ "product_categories": LightspeedRetailEndpointConfig(+ name="product_categories",+ path="/product_categories",+ incremental_fields=[],+ pagination="after_cursor",+ data_selector="data.categories",+ ),+ "stock_adjustments": LightspeedRetailEndpointConfig(+ name="stock_adjustments",+ path="/stock_adjustments",+ partition_key="created_at",+ ),+ "promotions": LightspeedRetailEndpointConfig(+ name="promotions",+ path="/promotions",+ incremental_fields=[],+ # `page_size` is the only paging param and caps the list, so it is not sent.+ pagination="single_page",+ ),+ "promo_codes": LightspeedRetailEndpointConfig(+ name="promo_codes",+ path="/promotions/{promotion_id}/promocodes",+ primary_key=["promotion_id", "id"],+ incremental_fields=[],+ partition_key="created_at",+ pagination="single_page",+ fanout=DependentEndpointConfig(+ parent_name="promotions",+ resolve_param="promotion_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "promotion_id"},+ ),+ ),+ "gift_cards": LightspeedRetailEndpointConfig(+ name="gift_cards",+ path="/gift_cards",+ incremental_fields=[],+ partition_key="created_at",+ pagination="before_id",+ sort_mode="desc",+ ),+ "gift_card_transactions": LightspeedRetailEndpointConfig(+ name="gift_card_transactions",+ path="/gift_cards",+ primary_key=["gift_card_id", "id"],+ incremental_fields=[],+ partition_key="created_at",+ pagination="before_id",+ sort_mode="desc",+ nested_rows_field="gift_card_transactions",+ nested_parent_key="gift_card_id",+ ),}ENDPOINTS = tuple(LIGHTSPEED_RETAIL_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail.pyindex 23bc4ba0dc58..641b9ed114d1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail.py@@ -227,3 +227,88 @@ class TestGetRows:rows = [item for batch in batches for item in batch]assert [(row["consignment_id"], row["product_id"]) for row in rows] == expected_rowsassert all("_consignments_id" not in row for row in rows)+++def _body_response(body: dict[str, Any]) -> Response:+ resp = Response()+ resp.status_code = 200+ resp._content = json.dumps(body).encode()+ return resp+++_GIFT_CARD_PAGES = [+ {"data": [{"id": "g3", "gift_card_transactions": [{"id": "t3"}]}, {"id": "g2", "gift_card_transactions": []}]},+ {"data": [{"id": "g1", "gift_card_transactions": [{"id": "t1"}, {"id": "t2"}]}]},+ {"data": []},+]+++class TestUnversionedEndpoints:+ @pytest.mark.parametrize(+ "endpoint, bodies, resume_state, expected_requests, expected_rows",+ [+ (+ "gift_cards",+ _GIFT_CARD_PAGES,+ None,+ [+ ("/gift_cards", {"page_size": 200}),+ ("/gift_cards", {"page_size": 200, "before": "g2"}),+ ("/gift_cards", {"page_size": 200, "before": "g1"}),+ ],+ [{"id": "g3"}, {"id": "g2"}, {"id": "g1"}],+ ),+ (+ "gift_card_transactions",+ _GIFT_CARD_PAGES[1:],+ LightspeedRetailResumeConfig(cursor="g2"),+ [+ ("/gift_cards", {"page_size": 200, "before": "g2"}),+ ("/gift_cards", {"page_size": 200, "before": "g1"}),+ ],+ [{"id": "t1", "gift_card_id": "g1"}, {"id": "t2", "gift_card_id": "g1"}],+ ),+ (+ "product_categories",+ [+ {"data": {"categories": [{"id": "c1"}]}, "page_info": {"has_next": True, "last_seen": "c1"}},+ {"data": {"categories": [{"id": "c2"}]}, "page_info": {"has_next": False, "last_seen": "c2"}},+ ],+ None,+ [+ ("/product_categories", {"page_size": 200}),+ ("/product_categories", {"page_size": 200, "after": "c1"}),+ ],+ [{"id": "c1"}, {"id": "c2"}],+ ),+ (+ "promo_codes",+ [+ {"data": [{"id": "pr1"}, {"id": "pr2"}]},+ {"data": [{"id": "code1", "promotion_id": "pr1"}]},+ {"data": [{"id": "code2", "promotion_id": "pr2"}]},+ ],+ None,+ [+ ("/promotions", {}),+ ("/promotions/pr1/promocodes", {}),+ ("/promotions/pr2/promocodes", {}),+ ],+ [{"id": "code1", "promotion_id": "pr1"}, {"id": "code2", "promotion_id": "pr2"}],+ ),+ ],+ )+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_pages_without_record_versions(+ self, mock_session, endpoint, bodies, resume_state, expected_requests, expected_rows+ ):+ session = mock_session.return_value+ params = _wire(session, [_body_response(body) for body in bodies])++ manager = _make_manager(resume_state)+ batches = _run(manager, endpoint=endpoint)++ paths = [call.args[0].url.split("/api/2026-01")[1] for call in session.prepare_request.call_args_list]+ assert list(zip(paths, params)) == expected_requests+ rows = [item for batch in batches for item in batch]+ assert [{key: row.get(key) for key in expected_rows[0]} for row in rows] == expected_rows