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.

1.3 KB
Raw Blame
"""ServiceM8 endpoint catalog.

Field service management API for trades businesses. Every object exposes `uuid`
(globally unique across the account), `active` (soft-delete flag), and `edit_date`
(last-modified timestamp), which is what this source syncs on.
Reference: https://developer.servicem8.com/reference
"""

from products.warehouse_sources.sources.sdk import IncrementalField, incremental_field

# Display name -> vendor object name, e.g. "Job" -> GET /api_1.0/job.json.
ENDPOINT_PATHS: dict[str, str] = {
    "Job": "job",
    "Company": "company",
    "CompanyContact": "companycontact",
    "Staff": "staff",
    "Category": "category",
    "JobActivity": "jobactivity",
    "JobMaterial": "jobmaterial",
    "JobPayment": "jobpayment",
    "Note": "note",
    "Attachment": "attachment",
    "Material": "material",
    "TaxRate": "taxrate",
    "StaffTimeEvent": "stafftimeevent",
    "Feedback": "feedback",
}

ENDPOINTS: tuple[str, ...] = tuple(ENDPOINT_PATHS)

# Every listed object supports `$filter=edit_date gt '<value>'` (see /docs/filtering).
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: [incremental_field("edit_date")] for name in ENDPOINTS}

# `uuid` is assigned per-record account-wide, not scoped to a parent, so it's unique across
# every endpoint without composing in a parent id.
PRIMARY_KEY = "uuid"