rename cotality client to pashub client

This commit is contained in:
Daniel Roth 2026-03-24 14:57:08 +00:00
parent 441dce9726
commit 8e1aacf846
2 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
import time
from typing import Any, List, Mapping
from backend.pashub_fetcher.cotality_client import CotalityClient, UnauthorizedError
from backend.pashub_fetcher.pashub_client import PashubClient, UnauthorizedError
from backend.pashub_fetcher.token_getter import get_token_from_local_storage
from utils.logger import setup_logger
@ -20,7 +20,7 @@ def handler(event: Mapping[str, Any], context: Any) -> None:
logger.error("Error getting auth token from Pas Hub")
raise
client = CotalityClient(token=token)
pashub_client = PashubClient(token=token)
jobs = [
"5abf6e27-e4c4-4ba8-b69d-9e34939e0002",
@ -30,17 +30,19 @@ def handler(event: Mapping[str, Any], context: Any) -> None:
saved_files: List[str] = []
for job_id in jobs:
try:
saved_files.extend(client.get_core_envidence_files_by_job_id(job_id))
saved_files.extend(pashub_client.get_core_envidence_files_by_job_id(job_id))
# Upload files to sharepoint
except UnauthorizedError:
logger.warning("Token expired — refreshing")
token = get_token_from_local_storage(pas_hub_email, pas_hub_password)
client = CotalityClient(token=token)
pashub_client = PashubClient(token=token)
# retry once
saved_files.extend(client.get_core_envidence_files_by_job_id(job_id))
saved_files.extend(pashub_client.get_core_envidence_files_by_job_id(job_id))
time.sleep(10) # Simulate manual download

View file

@ -17,7 +17,7 @@ class UnauthorizedError(Exception):
pass
class CotalityClient:
class PashubClient:
def __init__(self, token: str):
self.token = token