@@ -19,10 +19,10 @@ def __init__( # pylint: disable=too-many-arguments
1919 Args:
2020 endpoint (str): The API endpoint to connect to.
2121 headers (dict, optional): The headers to use for the API request. Defaults to None.
22- retry_strategy (Strategies, optional): Defaults to Strategies.NoRetryStrategy .
22+ retry_strategy (Strategies, optional): Defaults to Strategies.NO_RETRY_STRATEGY .
2323 retries (int): The number of times to retry a failed request. Defaults to 3.
2424 initial_delay (int): The delay between retries in seconds. Defaults to 1.
25- connection_timeout (int): The timeout for the connection in seconds. Defaults to 2 .
25+ connection_timeout (int): The timeout for the connection in seconds. Defaults to 1 .
2626
2727 Raises:
2828 ValueError: If endpoint is an empty string.
@@ -58,8 +58,12 @@ def get_api_data(self):
5858 """
5959 Retrieves data from the API using the defined endpoint and retry strategy.
6060
61+ This function sends a request to the API using the endpoint, headers, and
62+ connection timeout specified in the instance attributes. It uses the
63+ defined retry strategy to handle potential failures and retries.
64+
6165 Returns:
62- dict: The response from the API.
66+ dict: The JSON response from the API as a dictionary .
6367 """
6468 response = GetData .get_response (
6569 endpoint = self .endpoint ,
@@ -69,16 +73,21 @@ def get_api_data(self):
6973
7074 return response .json ()
7175
72- def _get_raw_api_data (self ):
73- response = GetData .get_response (
74- endpoint = self .endpoint ,
75- headers = self .headers ,
76- connection_timeout = self .connection_timeout ,
77- )
78- return response
79-
8076 @staticmethod
8177 def api_to_dataframe (response : dict ):
78+ """
79+ Converts an API response to a DataFrame.
80+
81+ This function takes a dictionary response from an API,
82+ uses the `to_dataframe` function from the `GetData` class
83+ to convert it into a DataFrame, and logs the operation as successful.
84+
85+ Args:
86+ response (dict): The dictionary containing the API response.
87+
88+ Returns:
89+ DataFrame: A pandas DataFrame containing the data from the API response.
90+ """
8291 df = GetData .to_dataframe (response )
8392 log ("serialized to dataframe: OK" , LogLevel .INFO )
8493 return df
0 commit comments