From a124ba40964a72280c890bb4bcec16c5bc105e83 Mon Sep 17 00:00:00 2001 From: Mason Hall Date: Mon, 8 Jan 2024 15:45:56 -0500 Subject: [PATCH] checkpoint --- farcaster/client.py | 2 ++ farcaster/config.py | 3 +++ tests/integration_tests.py | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/farcaster/client.py b/farcaster/client.py index 6bd0f8c2..6c32a064 100644 --- a/farcaster/client.py +++ b/farcaster/client.py @@ -68,6 +68,8 @@ def __init__( self.create_new_auth_token(expires_in=self.rotation_duration) def get_base_path(self): + if self.config.neynar_api_key: + return self.config.neynar_base_path return self.config.base_path def get_base_options(self): diff --git a/farcaster/config.py b/farcaster/config.py index 9d633285..e28b5003 100644 --- a/farcaster/config.py +++ b/farcaster/config.py @@ -3,6 +3,7 @@ from farcaster.models import * FARCASTER_API_BASE_URL = "https://api.warpcast.com/v2/" +NEYNAR_API_BASE_URL = "https://api.neynar.io/v2/farcaster/" class ConfigurationParams(BaseModel): @@ -10,6 +11,8 @@ class ConfigurationParams(BaseModel): password: Optional[str] = None base_path: str = FARCASTER_API_BASE_URL base_options: Optional[Dict[Any, Any]] = None + neynar_api_key: Optional[str] = None + neynar_base_path: str = NEYNAR_API_BASE_URL class Configuration(BaseModel): diff --git a/tests/integration_tests.py b/tests/integration_tests.py index 94fc388b..2b53c5cf 100644 --- a/tests/integration_tests.py +++ b/tests/integration_tests.py @@ -99,4 +99,19 @@ def test_stream_notifications() -> None: print(notification.model_dump()) -# test_stream_casts() +def client_from_neynar() -> None: + load_dotenv() + NEYNAR_API_KEY = os.getenv("NEYNAR_API_KEY") + assert NEYNAR_API_KEY, "PKEY env var not set" + client = Warpcast(neynar_api_key=NEYNAR_API_KEY) + # expiry = (int(time.time()) + (10 * 60)) * 1000 + # assert client.wallet + assert client.get_user_by_username("mason").username == "mason" + # assert client.access_token + # assert client.rotation_duration == 10 + # print(client.expires_at) + # print(client.access_token) + # assert client.expires_at == expiry + + +client_from_neynar()