"""Teamtailor career sites publish a JSON Feed at `/jobs.json` on the career-site host (`.teamtailor.com` or a custom `career..com`): {version, title, home_page_url, items:[{id, title, url, date_published, _jobposting:{identifier:{value}, datePosted, jobLocation:[{address:{addressLocality, addressRegion, addressCountry}}], employmentType?, jobLocationType?}}]}. Verified 2026-09-12 against https://career.teamtailor.com/jobs.json (fixture trimmed to 20 items, descriptions removed). When a career site has no feed (404) discovery keeps the HTML careers sensor instead.""" from __future__ import annotations import re from collections.abc import Mapping from typing import Any from companyatlas.connectors._ats_base import AtsConnector from companyatlas.connectors._util import country_code, dig, parse_date, text_of from companyatlas.sdk.connector import ConnectorMeta, register from companyatlas.sdk.models import ExtractedJob from companyatlas.taxonomy import FetchMode, Surface @register class TeamtailorConnector(AtsConnector): vendor = "teamtailor" token_re = re.compile(r"https?://([a-z0-9-]+)\.teamtailor\.com/jobs\.json", re.IGNORECASE) meta = ConnectorMeta(connector_id="teamtailor-v1", name="Teamtailor jobs feed", version="1", category=Surface.JOBS_BOARD, fetch_mode=FetchMode.JSON, default_interval_s=6 * 3600, url_pattern=r"/jobs\.json(\?|$)", pattern_required=True, priority=45, accept="application/feed+json,application/json", description="Teamtailor career-site JSON Feed (/jobs.json)") def parse_jobs(self, data: Any, sensor: Mapping[str, Any]) -> list[ExtractedJob]: out: list[ExtractedJob] = [] for it in (data.get("items") if isinstance(data, dict) else []) or []: if not isinstance(it, dict) or not it.get("title"): continue jp = it.get("_jobposting") or {} locs = jp.get("jobLocation") or [] if isinstance(locs, dict): locs = [locs] addr = dig(locs[0], "address", default={}) if locs and isinstance(locs[0], dict) else {} city, region, country = text_of(addr.get("addressLocality")), text_of(addr.get("addressRegion")), addr.get("addressCountry") ident = dig(jp, "identifier", "value") loc_type = (jp.get("jobLocationType") or "").lower() out.append(ExtractedJob( title=str(it["title"]), url=it.get("url"), external_id=str(ident or it.get("id") or ""), location_text=", ".join(x for x in (city, country_code(country) or text_of(country)) if x) or None, city=city, region=region if region and region.lower() not in ("europe", "emea", "apac", "americas") else None, country=country_code(country), remote=True if loc_type == "telecommute" else None, employment_type=text_of(jp.get("employmentType")), posted_at=parse_date(jp.get("datePosted") or it.get("date_published")), raw={"locations": len(locs)}, )) return out