"""HiBob: `hibob:` for .careers.hibob.com, the whole board in one JSON answer. Written from Dixa's board (two general-application ads) and Liquidia's (14 roles) on 2026-09-29. The careers site's own API, `.careers.hibob.com/api/job-ad`, answers 401 unless the request carries the header `companyIdentifier: `. That header is the company's public subdomain and no key or token, but it is why this is a paged module, whose `page` may send headers, although it reads one page. Every ad comes with its texts, so there is no `detail`. Pay is read from the `payTransparency*` fields as they are named; no board seen so far had them filled, so the period's spelling is a guess. """ from __future__ import annotations import html import json import logging from collections.abc import Callable from typing import Any from desk.sources import strip_html from ._contract import Ask, Fields, Reads, Row from ._shared import Get, Page, label_slug_ok, num, only, parse_dt, pay_line, table_word, yearly_amount log = logging.getLogger(__name__) # One ad names one site: a company that hires at two sites posts two ads with # their own ids (Dixa's "Expression of interest" at Copenhagen and London), so # the host publishes one posting per place. READS = Reads( scope="board", listing="paged", text="listing", complete="end", places="copies", fields=Fields(pay="figures", posted="listed", remote="stated", employment="stated"), robots="read: robots.txt allows the careers site; its robots.txt is the single-page " "app's index page with no rules (checked 2026-09-29)", ) #: `employmentType`, the company's own name for it -> the app's employment #: words. "Permanent" says nothing about hours and stays unmapped. _EMPLOYMENT = {"regular full time": "full_time", "full time": "full_time", "full-time": "full_time", "regular part time": "part_time", "part time": "part_time", "part-time": "part_time", "contract": "contract", "contractor": "contract", "temporary": "temporary", "fixed term": "temporary", "intern": "internship", "internship": "internship", "freelance": "freelance"} NAME = "hibob" LABEL = "HiBob" PATTERNS = (r"https?://([a-z0-9-]+)\.careers\.hibob\.com",) #: HiBob's `workspaceTypeId` -> `store._remote`'s words. _REMOTE = {"remote": "remote", "hybrid": "hybrid", "on_site": "onsite", "onsite": "onsite"} #: The texts of an ad, in the order the ad shows them. _SECTIONS = ("description", "responsibilities", "requirements", "benefits") #: A pay period's spellings, as the word `pay_line` and `yearly_amount` take. _PERIODS = {"year": "year", "yearly": "year", "annual": "year", "annually": "year", "month": "month", "monthly": "month", "hour": "hour", "hourly": "hour", "day": "day", "daily": "day", "week": "week", "weekly": "week"} def _host(slug: str) -> str: return f"{slug.lower()}.careers.hibob.com" def slug_ok(slug: str) -> bool: return label_slug_ok(slug) def allowed(slug: str) -> Callable[[str], bool]: return only(_host(slug)) def careers_url(slug: str) -> str: return f"https://{_host(slug)}/" def page(get: Get, slug: str, cursor: Any, ask: Ask) -> Page: """The one page: every ad, and no total or cursor, so the board is complete when the answer parses. The host's robots.txt is its single-page app's index page (a 200 with no rules), which allows.""" data = json.loads(get(f"https://{_host(slug)}/api/job-ad", headers={"companyIdentifier": slug.lower(), "Accept": "application/json"})) ads = data.get("jobAdDetails") if not isinstance(ads, list): raise ValueError("not a HiBob board: no jobAdDetails") return data, [{"id": ad.get("id")} for ad in ads], None, None def parse(body: bytes, slug: str) -> list[Row]: return rows(json.loads(body), slug) def rows(data: dict[str, Any], slug: str) -> list[Row]: """One answer -> one row per ad. `location` is the site with its country (the country left off where the site already names it). `posted` is `publishedAt`, which has nanoseconds. The description joins the ad's texts, which are HTML in the ads with sections and plain text elsewhere.""" out = [] for ad in data.get("jobAdDetails") or []: title = (ad.get("title") or "").strip() ad_id = str(ad.get("id") or "").strip() if not title or not ad_id: continue site = str(ad.get("site") or "").strip() country = str(ad.get("country") or "").strip() location = f"{site}, {country}" if site and country and country.lower() not in site.lower() \ else site or country text = " ".join(strip_html(str(ad.get(key) or "")) for key in _SECTIONS) lo, hi = num(ad.get("payTransparencyMinSalary")), num(ad.get("payTransparencyMaxSalary")) currency = ad.get("payTransparencySalaryCurrency") period = _PERIODS.get(str(ad.get("payTransparencySalaryPayPeriod") or "").strip().lower(), "") salary_min, salary_max, code = yearly_amount(lo, hi, currency, period, {"year": 1, "month": 12}) remote = {"remote": True, "hybrid": False, "on_site": False, "onsite": False}.get( str(ad.get("workspaceTypeId") or "").strip().lower()) row: Row = { "source_id": ad_id, "title": title, "places": [{"text": location, "remote": remote}] if location else [], "location": location, "url": f"https://{_host(slug)}/jobs/{ad_id}", "posted": parse_dt(ad.get("publishedAt")), "department": str(ad.get("department") or "").strip(), "description": " ".join(html.unescape(text).split()), "remote": _REMOTE.get(str(ad.get("workspaceTypeId") or "").strip().lower()), "salary_text": pay_line(lo, hi, currency, period), "salary_min": salary_min, "salary_max": salary_max, "currency": code, } if employment := table_word(_EMPLOYMENT, ad.get("employmentType"), log, "employmentType"): row["employment"] = employment out.append(row) return out