Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fmhall committed Jan 8, 2024
1 parent f43a1df commit a124ba4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions farcaster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions farcaster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
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):
username: Optional[str] = None
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):
Expand Down
17 changes: 16 additions & 1 deletion tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit a124ba4

Please sign in to comment.