"""Recruitee: `recruitee:`, the whole board in one JSON answer from the company's own subdomain of recruitee.com. Written from one real board on 2026-09-23; jobhunt-hq did not read Recruitee. """ from __future__ import annotations import json from collections.abc import Callable from typing import Any from desk.sources import strip_html from ._shared import Row, is_web_url, label_slug_ok, num, only, parse_dt, pay_line, yearly_amount NAME = "recruitee" LABEL = "Recruitee" PATTERNS = (r"https?://([a-z0-9-]+)\.recruitee\.com",) def slug_ok(slug: str) -> bool: return label_slug_ok(slug) def allowed(slug: str) -> Callable[[str], bool]: """The company's own subdomain, so one company's slug cannot pass for another's.""" return only(f"{slug}.recruitee.com") def careers_url(slug: str) -> str: return f"https://{slug}.recruitee.com" def feed_url(slug: str) -> str: return f"https://{slug}.recruitee.com/api/offers/" def probe_url(slug: str) -> str: return feed_url(slug) def probe_ok(body: bytes) -> bool: return b'"offers":[' in body and b'"offers":[]' not in body def _salary_text(salary: dict[str, Any]) -> str: """One line from Recruitee's `salary` object; `period` is already a plain word ("year", "month").""" period = str(salary.get("period") or "").strip().lower() return pay_line(num(salary.get("min")), num(salary.get("max")), salary.get("currency"), period) def parse(body: bytes, slug: str) -> list[Row]: data = json.loads(body) rows = [] for j in data.get("offers") or []: title = (j.get("title") or "").strip() url = (j.get("careers_url") or "").strip() if not title or not is_web_url(url): continue salary = j.get("salary") if isinstance(j.get("salary"), dict) else {} salary_min, salary_max, currency = yearly_amount( salary.get("min"), salary.get("max"), salary.get("currency"), salary.get("period"), {"year": 1, "month": 12}) rows.append({ "source_id": str(j.get("id") or ""), "title": title, "location": (j.get("location") or j.get("city") or "").strip(), "url": url, "posted": parse_dt(j.get("published_at") or j.get("created_at")), "department": (j.get("department") or "").strip(), "description": strip_html(j.get("description") or ""), "remote": j.get("remote"), "salary_text": _salary_text(salary), "salary_min": salary_min, "salary_max": salary_max, "currency": currency, }) return rows