Abandon a job through the relay canceljob route 🟩

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-07 15:32:13 +00:00
parent c206a76b22
commit 03f0f4d490

View file

@ -98,7 +98,19 @@ class AbriClient:
return self._parse_appointment_amended(outcome)
def abandon_job(self, request: AbandonJobRequest) -> AbandonJobResult:
raise NotImplementedError
outcome = self._exchange(
request_type="canceljob",
parameters=[
("job_no", request.job_no),
("abandon_reason", request.reason.value),
("date_abandoned", _format_appointment_date(request.date_abandoned)),
],
)
if isinstance(outcome, AbriRequestRejected):
return outcome
return self._parse_job_abandoned(outcome)
def get_tenant_data(self, place_ref: PlaceRef) -> GetTenantDataResult:
outcome = self._exchange(
@ -197,6 +209,22 @@ class AbriClient:
appointment_time=appointment_time,
)
@staticmethod
def _parse_job_abandoned(root: ET.Element) -> JobAbandoned:
job_cancelled = root.find(".//JobCancelled")
if job_cancelled is None:
raise AbriResponseParseError(
"JobCancelled element missing from relay response"
)
job_no = job_cancelled.get("job_no")
if job_no is None:
raise AbriResponseParseError("JobCancelled element missing job_no")
return JobAbandoned(job_no=job_no)
@staticmethod
def _parse_tenancy_data(root: ET.Element) -> TenancyData:
tenancies = root.findall("Tenancy")