: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
from typing import cast
from products.warehouse_sources.sources.clip._config import ClipSourceConfig
from products.warehouse_sources.sources.clip.canonical_descriptions import CANONICAL_DESCRIPTIONS
from products.warehouse_sources.sources.clip.clip import (
ClipResumeConfig,
clip_source,
parse_start_date,
validate_credentials,
)
from products.warehouse_sources.sources.clip.settings import AUTH_ERROR, ENDPOINTS, INCREMENTAL_FIELDS, PERMISSION_ERROR
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
build_endpoint_schemas,
detect,
)
@SourceRegistry.register
class ClipSource(ResumableSource[ClipSourceConfig, ClipResumeConfig]):
codebase_detection = detect(script_hosts=("sdk.clip.mx",))
lists_tables_without_credentials = True
api_docs_url = "https://developer.clip.mx/reference/transactions"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.CLIP
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {"401 Client Error": AUTH_ERROR, "403 Client Error": PERMISSION_ERROR}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: ClipSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
return build_endpoint_schemas(
ENDPOINTS,
INCREMENTAL_FIELDS,
names,
merge_only={"transactions"},
should_sync_default={"settlements": False, "settlement_payments": False},
)
def validate_credentials(
self,
config: ClipSourceConfig,
team_id: int,
schema_name: str | None = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
try:
parse_start_date(config.start_date)
except ValueError as error:
return False, str(error)
return validate_credentials(config)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[ClipResumeConfig]:
return ResumableSourceManager(inputs, ClipResumeConfig)
def source_for_pipeline(
self,
config: ClipSourceConfig,
resumable_source_manager: ResumableSourceManager[ClipResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return clip_source(config, inputs, resumable_source_manager)
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.CLIP,
category=DataWarehouseSourceCategory.PAYMENTS___BILLING,
label="Clip (PayClip S. de R.L. de C.V.)",
iconPath="/static/services/clip.png",
caption=(
"Create an API key and secret key in the [Clip developer dashboard](https://dashboard.clip.mx/dashboard). "
"Transactions sync from the start date. Incremental sync uses the creation date; "
"use a full refresh to capture changes to older transactions. "
"Deposit tables contain the last 90 days and require deposits API access. "
"Clip accounts with Cuenta Digital cannot use the deposits API."
),
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="api_key",
label="API key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
SourceFieldInputConfig(
name="secret_key",
label="Secret key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
SourceFieldInputConfig(
name="start_date",
sync_setting=True,
label="Start date",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="YYYY-MM-DD",
secret=False,
),
],
),
releaseStatus=ReleaseStatus.BETA,
)