Skip to content

Commit cb9d1de

Browse files
feature: Added Headers param
1 parent e407a97 commit cb9d1de

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/api_to_dataframe/controller/client_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class ClientBuilder:
66
def __init__(self,
77
endpoint: str,
8+
headers: dict = {},
89
retry_strategy: RetryStrategies = RetryStrategies.NoRetryStrategy,
910
timeout: int = 5):
1011
"""
@@ -24,6 +25,7 @@ def __init__(self,
2425
self.endpoint = endpoint
2526
self.retry_strategy = retry_strategy
2627
self.timeout = timeout
28+
self.headers = headers
2729

2830
def get_api_data(self):
2931
"""
@@ -32,7 +34,7 @@ def get_api_data(self):
3234
Returns:
3335
dict: The response from the API.
3436
"""
35-
response = GetData.get_response(self.endpoint, self.retry_strategy, self.timeout)
37+
response = GetData.get_response(self.endpoint, self.headers, self.retry_strategy, self.timeout)
3638
return response
3739

3840
@staticmethod

src/api_to_dataframe/models/get_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
class GetData:
99
@staticmethod
10-
def get_response(endpoint: str, retry_strategies: RetryStrategies, timeout: int):
10+
def get_response(endpoint: str, headers: dict, retry_strategies: RetryStrategies, timeout: int):
1111
try:
12-
response = requests.get(endpoint, timeout=timeout)
12+
response = requests.get(endpoint, timeout=timeout, headers=headers)
1313
response.raise_for_status()
1414
except HTTPError as http_err:
1515
print(f'HTTP error occurred: {http_err}')

0 commit comments

Comments
 (0)