File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1+ # re-export aio-fluid's http clients
2+ from fluid .utils .http_client import AioHttpClient , HttpxClient
3+
4+ __all__ = ["AioHttpClient" , "HttpxClient" ]
Original file line number Diff line number Diff line change 22from dataclasses import dataclass , field
33from datetime import date , timedelta
44from typing import Any , cast
5- from fluid . utils . http_client import AioHttpClient
5+ from . client import AioHttpClient
66from fluid .utils .data import compact_dict
77import pandas as pd
88from enum import StrEnum
Original file line number Diff line number Diff line change 1+ from .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 : Any ) -> 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