forked from cartsnitch/api
b7e6f637a7
Consolidate API gateway service into monorepo. Squashed from https://github.com/cartsnitch/api main (89bacb1). Co-Authored-By: Paperclip <noreply@paperclip.ing>
24 lines
698 B
Python
24 lines
698 B
Python
"""HTTP client for ShrinkRay internal API."""
|
|
|
|
from typing import Any, cast
|
|
|
|
import httpx
|
|
|
|
from cartsnitch_api.config import settings
|
|
|
|
|
|
class ShrinkRayClient:
|
|
def __init__(self) -> None:
|
|
self.base_url = settings.shrinkray_url
|
|
self.headers = {"X-Service-Key": settings.service_key}
|
|
|
|
async def get_shrinkflation_alerts(self, user_id: str) -> list[dict]:
|
|
async with httpx.AsyncClient() as client:
|
|
resp = await client.get(
|
|
f"{self.base_url}/alerts",
|
|
headers=self.headers,
|
|
params={"user_id": user_id},
|
|
)
|
|
resp.raise_for_status()
|
|
return cast(list[dict[str, Any]], resp.json())
|