Skip to content

: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.

feat(warehouse-sources): add dingconnect region, status and description tables (#105164)

Tom Owers6e46eea16137
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.md
index 560a144e2e5a..a462df93e02b 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
@@ -2489,10 +2489,10 @@ Today (7): `Balance`, `Countries`, `Currencies`, `Products`, `Promotions`, `Prov
Diffed against: <http://web.archive.org/web/20250213144221/https://www.dingconnect.com/Api/Description>
-- [ ] `api/V1/GetRegions` — lookup for the region codes that scope providers and products; the docs call out that a provider or product may only be valid for a subset of regions (high)
-- [ ] `api/V1/GetErrorCodeDescriptions` — lookup decoding the ErrorCode/Context values returned on transfer records, so failed top-ups can be categorized (medium)
-- [ ] `api/V1/GetProviderStatus` — per-provider availability, the dimension that explains transfer failure spikes (medium)
-- [ ] `api/V1/GetProductDescriptions` — localized long-form product text keyed by LocalizationKey — resolves the descriptions deliberately split out of GetProducts (medium)
+- [x] `api/V1/GetRegions` — lookup for the region codes that scope providers and products; the docs call out that a provider or product may only be valid for a subset of regions (high) — added as `Regions`
+- [x] `api/V1/GetErrorCodeDescriptions` — lookup decoding the ErrorCode/Context values returned on transfer records, so failed top-ups can be categorized (medium) — added as `ErrorCodeDescriptions` (the endpoint returns a Code/Message pair; Context codes are documented prose, not API data)
+- [x] `api/V1/GetProviderStatus` — per-provider availability, the dimension that explains transfer failure spikes (medium) — added as `ProviderStatus` (a current-state snapshot per sync, not a history)
+- [x] `api/V1/GetProductDescriptions` — localized long-form product text keyed by LocalizationKey — resolves the descriptions deliberately split out of GetProducts (medium) — added as `ProductDescriptions`
- [ ] `api/V1/GetPromotionDescriptions` — localized promotion terms keyed by LocalizationKey, the companion to the synced promotions table (low)
Note: The live docs page returns Cloudflare 403 to non-browser clients and the swagger definition (/swagger/docs/v1) is auth-gated, so this was diffed against a Wayback capture of the official API description. The full readable method set is GetBalance, GetCountries, GetCurrencies, GetProducts, GetProductDescriptions, GetPromotions, GetPromotionDescriptions, GetProviders, GetProviderStatus, GetRegions, GetErrorCodeDescriptions, ListTransferRecords; GetAccountLookup and EstimatePrices are per-request lookups rather than tables, and SendTransfer/CancelTransfers are mutations.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/canonical_descriptions.py
index c8fd03610190..ba9f5d7a81bf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/canonical_descriptions.py
@@ -30,6 +30,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"CurrencyName": "English currency name.",
},
},
+ "Regions": {
+ "description": "A region within a country. A provider may only service a subset of a country's regions, and a product may only be valid for a subset.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "RegionCode": "The region code.",
+ "RegionName": "The region name.",
+ "CountryIso": "The country ISO code of the region.",
+ },
+ },
"Providers": {
"description": "A mobile operator or biller whose products can be sold through DingConnect.",
"docs_url": _DOCS_URL,
@@ -43,6 +52,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"RegionCodes": "Regions supported by the provider within the country.",
},
},
+ "ProviderStatus": {
+ "description": "Whether each provider can currently accept transfers. Providers can be suspended or in an error state.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "ProviderCode": "The unique provider code.",
+ "IsProcessingTransfers": "Indicates if the provider is processing transfers.",
+ "Message": "Details of operator status. Unformatted, non-localized text aimed at the distributor rather than the end customer.",
+ },
+ },
"Products": {
"description": "A sellable product (e.g. a top-up amount) offered by a provider.",
"docs_url": _DOCS_URL,
@@ -61,6 +79,17 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"RegionCode": "Region for this product.",
},
},
+ "ProductDescriptions": {
+ "description": "Localized long-form product text, keyed by the LocalizationKey carried on each product. Large blocks of text are CommonMark.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "DisplayText": "A short description of the product.",
+ "DescriptionMarkdown": "A longer description of the product.",
+ "ReadMoreMarkdown": "More detailed information about the product.",
+ "LocalizationKey": "The key that links the description back to a product.",
+ "LanguageCode": "The language this description is written in. English (en) is always present.",
+ },
+ },
"Promotions": {
"description": "A time-bound promotion applied to a provider's products.",
"docs_url": _DOCS_URL,
@@ -82,6 +111,14 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"CurrencyIso": "ISO 4217 currency code of the balance.",
},
},
+ "ErrorCodeDescriptions": {
+ "description": "Human readable descriptions for the error codes returned in the ErrorCodes array of an API response. Aimed at the distributor rather than the end customer.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "Code": "The identifying error code that was returned in the response.",
+ "Message": "Error description.",
+ },
+ },
"TransferRecords": {
"description": "A record of a transfer (top-up) that was sent through DingConnect. Only retained upstream for ~2 months.",
"docs_url": _DOCS_URL,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/settings.py
index 7a871ed75f0e..8485a5894f62 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/settings.py
@@ -24,9 +24,10 @@ class DingConnectEndpointConfig:
should_sync_default: bool = True
-# DingConnect's REST API exposes reference/catalog lookups (Countries, Currencies, Providers,
-# Products, Promotions, Balance) plus transaction history (TransferRecords). None of these expose
-# a server-side timestamp filter — the catalog endpoints are static lookups and ListTransferRecords
+# DingConnect's REST API exposes reference/catalog lookups (Countries, Currencies, Regions,
+# Providers, ProviderStatus, Products, ProductDescriptions, Promotions, Balance,
+# ErrorCodeDescriptions) plus transaction history (TransferRecords). None of these expose a
+# server-side timestamp filter — the catalog endpoints are static lookups and ListTransferRecords
# only accepts Skip/Take offset paging — so every table is full refresh. Transfer history is also
# only retained for ~2 months upstream, so each sync reflects the currently-retained window.
DING_CONNECT_ENDPOINTS: dict[str, DingConnectEndpointConfig] = {
@@ -40,16 +41,34 @@ DING_CONNECT_ENDPOINTS: dict[str, DingConnectEndpointConfig] = {
path="/api/V1/GetCurrencies",
primary_keys=["CurrencyIso"],
),
+ # RegionCode is only documented as "the region code" alongside its CountryIso, so treat it as
+ # unique within a country rather than globally.
+ "Regions": DingConnectEndpointConfig(
+ name="Regions",
+ path="/api/V1/GetRegions",
+ primary_keys=["CountryIso", "RegionCode"],
+ ),
"Providers": DingConnectEndpointConfig(
name="Providers",
path="/api/V1/GetProviders",
primary_keys=["ProviderCode"],
),
+ "ProviderStatus": DingConnectEndpointConfig(
+ name="ProviderStatus",
+ path="/api/V1/GetProviderStatus",
+ primary_keys=["ProviderCode"],
+ ),
"Products": DingConnectEndpointConfig(
name="Products",
path="/api/V1/GetProducts",
primary_keys=["SkuCode"],
),
+ # One row per product LocalizationKey per language, so both are needed to identify a row.
+ "ProductDescriptions": DingConnectEndpointConfig(
+ name="ProductDescriptions",
+ path="/api/V1/GetProductDescriptions",
+ primary_keys=["LocalizationKey", "LanguageCode"],
+ ),
# Promotions carry no unique identifier, so dedupe on the (provider, currency, start) tuple.
"Promotions": DingConnectEndpointConfig(
name="Promotions",
@@ -64,6 +83,11 @@ DING_CONNECT_ENDPOINTS: dict[str, DingConnectEndpointConfig] = {
data_selector="",
primary_keys=["CurrencyIso"],
),
+ "ErrorCodeDescriptions": DingConnectEndpointConfig(
+ name="ErrorCodeDescriptions",
+ path="/api/V1/GetErrorCodeDescriptions",
+ primary_keys=["Code"],
+ ),
"TransferRecords": DingConnectEndpointConfig(
name="TransferRecords",
path="/api/V1/ListTransferRecords",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/tests/test_ding_connect.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/tests/test_ding_connect.py
index df344504651d..f1f04091827a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/tests/test_ding_connect.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ding_connect/tests/test_ding_connect.py
@@ -92,13 +92,27 @@ class TestRowFromSingleObject:
class TestReferenceEndpoints:
+ @parameterized.expand(
+ [
+ ("Countries",),
+ ("Currencies",),
+ ("Regions",),
+ ("Providers",),
+ ("ProviderStatus",),
+ ("Products",),
+ ("ProductDescriptions",),
+ ("Promotions",),
+ ("ErrorCodeDescriptions",),
+ ]
+ )
@mock.patch(CLIENT_SESSION_PATCH)
- def test_list_endpoint_yields_items(self, MockSession) -> None:
+ def test_list_endpoint_yields_items(self, endpoint: str, MockSession) -> None:
session = MockSession.return_value
- _wire(session, [_response({"Items": [{"CountryIso": "GB"}, {"CountryIso": "US"}], "ResultCode": 1})])
+ _wire(session, [_response({"Items": [{"a": 1}, {"a": 2}], "ResultCode": 1})])
- rows = _rows(_source("Countries", _make_manager()))
- assert rows == [{"CountryIso": "GB"}, {"CountryIso": "US"}]
+ # Every bounded lookup reads its rows from the `Items` envelope, so the envelope keys never
+ # reach the table and the response is not mistaken for a single-object body like GetBalance.
+ assert _rows(_source(endpoint, _make_manager())) == [{"a": 1}, {"a": 2}]
# A bounded catalog list comes back in exactly one request.
assert session.send.call_count == 1
@@ -232,10 +246,14 @@ class TestSourceResponse:
[
("Countries", ["CountryIso"], None),
("Currencies", ["CurrencyIso"], None),
+ ("Regions", ["CountryIso", "RegionCode"], None),
("Providers", ["ProviderCode"], None),
+ ("ProviderStatus", ["ProviderCode"], None),
("Products", ["SkuCode"], None),
+ ("ProductDescriptions", ["LocalizationKey", "LanguageCode"], None),
("Promotions", ["ProviderCode", "CurrencyIso", "StartUtc"], None),
("Balance", ["CurrencyIso"], None),
+ ("ErrorCodeDescriptions", ["Code"], None),
("TransferRecords", ["TransferRef"], "StartedUtc"),
]
)