mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
get uprn from pashub job id
This commit is contained in:
parent
4770d3a3c5
commit
abd0ed882f
3 changed files with 32 additions and 2 deletions
|
|
@ -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']}"
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
9
backend/pashub_fetcher/pashub_to_ara_trigger_request.py
Normal file
9
backend/pashub_fetcher/pashub_to_ara_trigger_request.py
Normal 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
|
||||
Loading…
Add table
Reference in a new issue