mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Abri amend_job amends an OpenHousing appointment and returns the echoed booking 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
2cfed0c33d
commit
c542a57ae5
1 changed files with 40 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ from domain.abri.models import (
|
|||
AbriRequestRejected,
|
||||
AmendJobRequest,
|
||||
AmendJobResult,
|
||||
AppointmentAmended,
|
||||
JobLogged,
|
||||
LogJobRequest,
|
||||
LogJobResult,
|
||||
|
|
@ -48,7 +49,20 @@ class AbriClient:
|
|||
return self._parse_job_logged(outcome)
|
||||
|
||||
def amend_job(self, request: AmendJobRequest) -> AmendJobResult:
|
||||
raise NotImplementedError
|
||||
outcome = self._exchange(
|
||||
request_type="amendoptiappt",
|
||||
parameters=[
|
||||
("job_no", request.job_no),
|
||||
("action", "amend"),
|
||||
("appointment_date", request.appointment_date.strftime("%d/%m/%Y")),
|
||||
("appointment_time", request.appointment_time),
|
||||
],
|
||||
)
|
||||
|
||||
if isinstance(outcome, AbriRequestRejected):
|
||||
return outcome
|
||||
|
||||
return self._parse_appointment_amended(outcome)
|
||||
|
||||
def _exchange(
|
||||
self, request_type: str, parameters: List[Tuple[str, str]]
|
||||
|
|
@ -106,6 +120,31 @@ class AbriClient:
|
|||
|
||||
return JobLogged(job_no=job_no, logged_info=logged_info)
|
||||
|
||||
@staticmethod
|
||||
def _parse_appointment_amended(root: ET.Element) -> AppointmentAmended:
|
||||
amended = root.find("AmendOptiAppt")
|
||||
|
||||
if amended is None:
|
||||
raise AbriResponseParseError(
|
||||
"AmendOptiAppt element missing from relay response"
|
||||
)
|
||||
|
||||
job_no = amended.get("job_no")
|
||||
appointment_date = amended.get("appointment_date")
|
||||
appointment_time = amended.get("appointment_time")
|
||||
|
||||
if job_no is None or appointment_date is None or appointment_time is None:
|
||||
raise AbriResponseParseError(
|
||||
"AmendOptiAppt element missing job_no, appointment_date "
|
||||
"or appointment_time"
|
||||
)
|
||||
|
||||
return AppointmentAmended(
|
||||
job_no=job_no,
|
||||
appointment_date=appointment_date,
|
||||
appointment_time=appointment_time,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _parse_rejection(root: ET.Element) -> AbriRequestRejected:
|
||||
success = root.findtext("success")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue