Log an OpenHousing job from a confirmed survey booking's deal fields 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-06 15:51:21 +00:00
parent 98674ae895
commit ce7b302c17

View file

@ -2,7 +2,9 @@ from dataclasses import dataclass
from datetime import date
from typing import Optional, Protocol, Union
from domain.abri.models import AbriRequestRejected, PlaceRef
from domain.abri.descriptions import build_job_descriptions
from domain.abri.models import AbriRequestRejected, LogJobRequest, PlaceRef
from domain.abri.slots import slot_for_confirmed_time
from infrastructure.abri.abri_client import AbriClient
from infrastructure.hubspot.deal_properties_client import HubspotDealPropertiesClient
@ -58,7 +60,7 @@ def client_ref_for_deal(deal_id: str) -> str:
re-logging after a cancellation would repeat the bare deal ID) is an open
question on issue #1478. Swap the derivation here once Abri answers.
"""
raise NotImplementedError
return deal_id
class AbriLogJobOrchestrator:
@ -79,4 +81,21 @@ class AbriLogJobOrchestrator:
self._deal_database = deal_database
def run(self, booking: ConfirmedSurveyBooking) -> LogJobOrchestrationResult:
raise NotImplementedError
descriptions = build_job_descriptions(booking.deal_name)
outcome = self._abri.log_job(
LogJobRequest(
client_ref=client_ref_for_deal(booking.deal_id),
place_ref=booking.place_ref,
appointment_date=booking.confirmed_survey_date,
appointment_time=slot_for_confirmed_time(
booking.confirmed_survey_time
),
short_description=descriptions.short_description,
long_description=descriptions.long_description,
)
)
if isinstance(outcome, AbriRequestRejected):
return outcome
return LogJobSummary(deal_id=booking.deal_id, job_no=outcome.job_no)