|
14 | 14 | ApiSuccess, |
15 | 15 | GeniusApiResponse, |
16 | 16 | ) |
| 17 | +from app.core.transport.http_client import create_http_client |
17 | 18 |
|
18 | 19 | # This token will be set when the tools are initialized |
19 | 20 | euler_token: str | None = None |
@@ -115,7 +116,7 @@ async def _make_genius_api_request( |
115 | 116 | ) |
116 | 117 |
|
117 | 118 | try: |
118 | | - async with httpx.AsyncClient(timeout=10.0) as client: |
| 119 | + async with create_http_client(timeout=10.0) as client: |
119 | 120 | response = await client.post( |
120 | 121 | GENIUS_API_URL, json=full_payload, headers=headers |
121 | 122 | ) |
@@ -344,7 +345,7 @@ async def list_offers_by_filter(params: FunctionCallParams): |
344 | 345 | f"Requesting Euler offers list from: {endpoint} | Payload: {json.dumps(payload, indent=2)}" |
345 | 346 | ) |
346 | 347 |
|
347 | | - async with httpx.AsyncClient(timeout=30.0) as client: |
| 348 | + async with create_http_client(timeout=30.0) as client: |
348 | 349 | response = await client.post(endpoint, json=payload, headers=headers) |
349 | 350 |
|
350 | 351 | if response.status_code != 200: |
@@ -736,7 +737,7 @@ async def create_euler_offer(params: FunctionCallParams): |
736 | 737 | f"Making offer creation request to: {endpoint} | Payload: {json.dumps(api_payload, indent=2)}" |
737 | 738 | ) |
738 | 739 |
|
739 | | - async with httpx.AsyncClient(timeout=10.0) as client: |
| 740 | + async with create_http_client(timeout=10.0) as client: |
740 | 741 | response = await client.post(endpoint, json=api_payload, headers=headers) |
741 | 742 |
|
742 | 743 | if response.status_code == 200: |
@@ -890,7 +891,7 @@ async def find_offer_by_code(offer_code: str) -> dict | None: |
890 | 891 | f"Searching for offer with code '{offer_code}' using endpoint: {endpoint}" |
891 | 892 | ) |
892 | 893 |
|
893 | | - async with httpx.AsyncClient(timeout=30.0) as client: |
| 894 | + async with create_http_client(timeout=30.0) as client: |
894 | 895 | response = await client.post(endpoint, json=search_payload, headers=headers) |
895 | 896 |
|
896 | 897 | if response.status_code == 200: |
@@ -983,7 +984,7 @@ async def delete_euler_offer(params: FunctionCallParams): |
983 | 984 | f"Deleting offer with ID '{offer_id}' using endpoint: {delete_endpoint}" |
984 | 985 | ) |
985 | 986 |
|
986 | | - async with httpx.AsyncClient(timeout=30.0) as client: |
| 987 | + async with create_http_client(timeout=30.0) as client: |
987 | 988 | response = await client.post( |
988 | 989 | delete_endpoint, json=delete_payload, headers=headers |
989 | 990 | ) |
@@ -1194,7 +1195,7 @@ async def update_euler_offer(params: FunctionCallParams): |
1194 | 1195 |
|
1195 | 1196 | logger.info(f"Using status-only endpoint: {status_endpoint}") |
1196 | 1197 |
|
1197 | | - async with httpx.AsyncClient(timeout=30.0) as client: |
| 1198 | + async with create_http_client(timeout=30.0) as client: |
1198 | 1199 | response = await client.post( |
1199 | 1200 | status_endpoint, json=status_payload, headers=headers |
1200 | 1201 | ) |
@@ -1544,7 +1545,7 @@ async def update_euler_offer(params: FunctionCallParams): |
1544 | 1545 | ) |
1545 | 1546 | logger.info(f"Payload: {json.dumps(api_payload, indent=2)}") |
1546 | 1547 |
|
1547 | | - async with httpx.AsyncClient(timeout=30.0) as client: |
| 1548 | + async with create_http_client(timeout=30.0) as client: |
1548 | 1549 | response = await client.put( |
1549 | 1550 | update_endpoint, json=api_payload, headers=headers |
1550 | 1551 | ) |
|
0 commit comments