Skip to content

Commit

Permalink
docs(client): add docstrings to client module
Browse files Browse the repository at this point in the history
  • Loading branch information
M4RC0Sx committed Aug 19, 2024
1 parent 8a5b8b0 commit bb45129
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions esiosapy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@


class ESIOSAPYClient:
"""
A client for interacting with the ESIOS API.
This client provides access to various managers that handle specific
types of requests to the ESIOS API, such as archives, indicators, and
offer indicators. It simplifies the process of making requests by
managing authentication and constructing the necessary URLs.
"""

def __init__(self, token: str, base_url: str = ESIOS_API_URL):
"""
Initializes the ESIOSAPYClient with an API token and a base URL.
:param token: The API token used for authentication.
:type token: str
:param base_url: The base URL for the ESIOS API. Defaults to ESIOS_API_URL.
:type base_url: str, optional
"""
self.token = token
self.base_url = base_url
self.request_helper = RequestHelper(base_url, token)
Expand All @@ -26,6 +43,22 @@ def __init__(self, token: str, base_url: str = ESIOS_API_URL):
def raw_request(
self, url: str, headers: Optional[Dict[str, str]] = None
) -> requests.Response:
"""
Makes a raw GET request to a specified URL with optional headers.
This method allows for making a direct GET request to a specified URL.
It adds default headers to the request and handles URL construction
if the provided URL is relative.
:param url: The URL to which the GET request is made. If the URL is
relative, it will be joined with the base URL.
:type url: str
:param headers: Optional headers to include in the request. If not provided,
default headers will be added. Defaults to None.
:type headers: Optional[Dict[str, str]], optional
:return: The response object resulting from the GET request.
:rtype: requests.Response
"""
if headers is None:
headers = {}
headers = self.request_helper.add_default_headers(headers)
Expand Down

0 comments on commit bb45129

Please sign in to comment.