This commit is contained in:
Igor Radovanovic
2023-08-24 11:33:49 +02:00
parent ee454af937
commit 1154a49865
4 changed files with 19 additions and 24 deletions

View File

@@ -20,7 +20,6 @@ class BasicResponse:
def __init__(self, response: StringIO):
"""Initialize the BasicResponse class."""
# Find a way to get the status code
self.status_code = 200
response.seek(0)
@@ -28,21 +27,21 @@ class BasicResponse:
def json(self) -> dict:
"""Return the response as a dictionary."""
return json.loads(self.text)
def request(url: str) -> BasicResponse:
"""
Request function for PyScript. Pass in Method and make sure to await!
"""Request function for PyScript.
Parameters:
-----------
Pass in Method and make sure to await!
Parameters
----------
url: str
URL to make request to
Return:
-------
Return
------
response: BasicRequest
BasicRequest object with status_code and text attributes
"""
@@ -55,7 +54,6 @@ def request(url: str) -> BasicResponse:
def get_data(url: str, **kwargs: Any) -> Union[list, dict]:
"""Get data from FMP endpoint."""
try:
r: Union[requests.Response, BasicResponse] = helpers.make_request(url, **kwargs)
except SSLError:
@@ -86,8 +84,8 @@ def create_url(
) -> str:
"""Return a URL for the FMP API.
Parameters:
-----------
Parameters
----------
version: int
The version of the API to use.
endpoint: str
@@ -99,11 +97,10 @@ def create_url(
exclude: List[str]
The keys to be excluded from the querystring.
Returns:
--------
Returns
-------
str
The querystring.
"""
the_dict = {} if not query else query.dict(by_alias=True)
query_string = get_querystring(the_dict, exclude or [])
@@ -116,15 +113,15 @@ def get_data_many(
) -> List[dict]:
"""Get data from FMP endpoint and convert to list of schemas.
Parameters:
-----------
Parameters
----------
url: str
The URL to get the data from.
sub_dict: Optional[str]
The sub-dictionary to use.
Returns:
--------
Returns
-------
List[dict]
Dictionary of data.
"""
@@ -138,7 +135,6 @@ def get_data_many(
def get_data_one(url: str, **kwargs: Any) -> dict:
"""Get data from FMP endpoint and convert to schema."""
data = get_data(url, **kwargs)
if isinstance(data, list):
if len(data) == 0:

View File

@@ -30,6 +30,7 @@ YIELD_CURVE_SERIES_REAL = {
def all_cpi_options(harmonized: bool = False) -> List[dict]:
"""Get all CPI options."""
data = []
current_dir = os.path.dirname(os.path.realpath(__file__))
@@ -44,6 +45,7 @@ def all_cpi_options(harmonized: bool = False) -> List[dict]:
def get_cpi_options(harmonized: bool = False) -> List[dict]:
"""Get CPI options."""
series = all_cpi_options(harmonized)
for item in series:
item.pop("series_id")
@@ -51,10 +53,7 @@ def get_cpi_options(harmonized: bool = False) -> List[dict]:
def process_projections(data: Dict) -> List[Dict]:
""".
Process projection data
"""
"""Process projection data."""
# Get dates first
dates = []
for key, value in data.items():

View File

@@ -3,6 +3,7 @@ from openbb_provider import helpers
def get_data(url: str, **kwargs) -> dict:
"""Get data from Polygon endpoint."""
r = helpers.make_request(url, **kwargs)
if r.status_code != 200:
data = r.json()

View File

@@ -1,7 +1,6 @@
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###
from openbb_core.app.static.container import Container