get uprn from pashub job id

This commit is contained in:
Daniel Roth 2026-03-26 14:53:55 +00:00
parent 4770d3a3c5
commit abd0ed882f
3 changed files with 32 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import os
import re
from typing import Any, Dict, List, Mapping
from typing import Any, Dict, List, Mapping, Optional
from openpyxl import load_workbook
from backend.pashub_fetcher.job import Job
@ -80,10 +80,16 @@ def handler(event: Mapping[str, Any], context: Any) -> None:
for job in jobs:
try:
job_id = job["id"]
uprn: Optional[str] = pashub_client.get_uprn_by_job_id(job_id)
logger.info(f"Got UPRN {uprn} for job {job_id}")
job_files: List[str] = pashub_client.get_core_evidence_files_by_job_id(
job["id"]
job_id
)
# Upload files to s3
# Upload files to sharepoint
job_path = f"{BASE_PATH}/{job['address']}"

View file

@ -71,6 +71,21 @@ class PashubClient:
return saved_files
def get_uprn_by_job_id(self, job_id: str) -> Optional[str]:
logger.info(f"Getting UPRN for job ID {job_id}")
url = f"{self.base}/jobs/{job_id}"
r = self.session.get(url)
if r.status_code == 401:
raise UnauthorizedError("Token expired or invalid")
r.raise_for_status()
try:
return r.json()["uprn"]
except Exception:
return None
def _get_core_file_type(self, file: EvidenceFileData) -> Optional[CoreFiles]:
for core_file in CoreFiles:
if file.file_name.startswith(core_file.value):

View file

@ -0,0 +1,9 @@
from typing import Optional
from pydantic import BaseModel
class PashubToAraTriggerRequest(BaseModel):
pashub_job_id: str
sharepoint_url: Optional[str] = None