File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import click
2+
3+
4+ @click .command ()
5+ def help () -> None :
6+ print ("Help!" )
Original file line number Diff line number Diff line change 1+ from fluid .utils .http_client import AioHttpClient
2+ from dataclasses import dataclass , field
3+ from typing import Any , cast
4+ import os
5+
6+
7+ @dataclass
8+ class Fred (AioHttpClient ):
9+ url : str = "https://api.stlouisfed.org/fred"
10+ key : str = field (default_factory = lambda : os .environ .get ("FRED_API_KEY" , "" ))
11+
12+ async def categiories (self , ** kw ) -> list [dict ]:
13+ return await self .get_path ("category" , ** kw )
14+
15+ # Internals
16+ async def get_path (self , path : str , ** kw : Any ) -> list [dict ]:
17+ result = await self .get (f"{ self .url } /{ path } " , ** self .params (** kw ))
18+ return cast (list [dict ], result )
19+
20+ def params (self , params : dict | None = None , ** kw : Any ) -> dict :
21+ params = params .copy () if params is not None else {}
22+ params .update (api_key = self .key , file_type = "json" )
23+ return {"params" : params , ** kw }
You can’t perform that action at this time.
0 commit comments