Skip to content

Commit 535d16c

Browse files
committed
refactor OBPClient to use HTTP verbs
1 parent 5c3b4d7 commit 535d16c

6 files changed

Lines changed: 232 additions & 124 deletions

File tree

src/auth/admin_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def get_admin_client() -> OBPClient:
160160
>>>
161161
>>> # Later, anywhere in the app
162162
>>> admin_client = get_admin_client()
163-
>>> response = await admin_client.async_obp_requests("GET", "/obp/v6.0.0/banks", "")
163+
>>> response = await admin_client.get("/obp/v6.0.0/banks")
164164
"""
165165
return _admin_manager.get_client()
166166

src/auth/auth.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,8 @@ async def create_admin_direct_login_auth(
459459
version = os.getenv('OBP_API_VERSION', 'v6.0.0')
460460

461461
try:
462-
response_json = await obp_client.async_obp_requests(
463-
"GET",
464-
f"/obp/{version}/my/entitlements",
465-
""
462+
response_json = await obp_client.get(
463+
f"/obp/{version}/my/entitlements"
466464
)
467465

468466
if not response_json:

src/checkpointer/entities.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional
33
from pydantic import BaseModel, Field
44
from src.client.obp_client import OBPClient
5+
import json
56

67
class OpeyCheckpointEntity(BaseModel):
78
"""OBP Dynamic Entity representation of a LangGraph checkpoint."""
@@ -73,26 +74,21 @@ def __init__(self, obp_client: OBPClient, endpoint_url: str):
7374

7475

7576
async def create(self, entity: OpeyCheckpointEntity | OpeyCheckpointWriteEntity):
76-
await self.client.async_obp_requests(
77-
method="POST",
78-
body=str(entity.model_dump()),
79-
path=self.endpoint_url
77+
await self.client.post(
78+
path=self.endpoint_url,
79+
body=entity.model_dump()
8080
)
8181

8282
async def delete(self, entity_id: str):
83-
await self.client.async_obp_requests(
84-
method="DELETE",
85-
body="",
83+
await self.client.delete(
8684
path=f"{self.endpoint_url}/{entity_id}"
8785
)
8886

8987
async def read(self, entity_id: str) -> dict:
90-
response = await self.client.async_obp_requests(
91-
method="GET",
92-
body="",
88+
response = await self.client.get(
9389
path=f"{self.endpoint_url}/{entity_id}"
9490
)
95-
return response
91+
return json.loads(response) if isinstance(response, str) else response
9692

9793
opey_checkpoint_entity = {
9894
"hasPersonalEntity": True,

0 commit comments

Comments
 (0)