Skip to content

Commit

Permalink
docs(offer-indicator): add docstrings to offer indicator models
Browse files Browse the repository at this point in the history
  • Loading branch information
M4RC0Sx committed Aug 20, 2024
1 parent 3ce4cae commit 48c36f9
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions esiosapy/models/offer_indicator/offer_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,57 @@

class OfferIndicator(BaseModel):
id: int
"""The unique identifier of the offer indicator.
:type: int
"""

name: str
"""The name of the offer indicator.
:type: str
"""

description: str
"""A detailed description of the offer indicator, often in HTML format.
:type: str
"""

raw: Dict[str, Any]
"""Raw data associated with the offer indicator.
:type: Dict[str, Any]
"""

_request_helper: RequestHelper
"""A helper object for making HTTP requests.
:type: RequestHelper
"""

def __init__(self, **data: Any):
"""
Initialize the OfferIndicator instance.
:param data: Arbitrary keyword arguments that initialize the object.
:type data: Any
"""
super().__init__(**data)
self._request_helper = data["_request_helper"]

def prettify_description(self) -> str:
"""
Convert the HTML description into a prettified plain-text format.
This method uses BeautifulSoup to parse and clean the HTML content
found in the description, returning it as a plain-text string.
:return: A prettified plain-text version of the description.
:rtype: str
:raises ImportError: If the BeautifulSoup package is not installed.
"""
try:
from bs4 import BeautifulSoup # type: ignore
except ImportError:
Expand All @@ -38,6 +78,22 @@ def get_data_by_date(
target_dt: Union[datetime, str],
all_raw_data: bool = False,
) -> Any:
"""
Retrieve the indicator data for a specific date.
This method fetches the indicator data for a given date, either returning
the raw JSON response or the specific indicator values.
:param target_dt: The target date for which to retrieve data,
either as a datetime object or a string.
:type target_dt: Union[datetime, str]
:param all_raw_data: If True, returns the entire raw JSON response; otherwise,
only returns the indicator values.
:type all_raw_data: bool, optional
:return: The requested data, either as a raw JSON or
as specific indicator values.
:rtype: Any
"""
if isinstance(target_dt, datetime):
target_dt = target_dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")

Expand All @@ -59,6 +115,25 @@ def get_data_by_date_range(
target_dt_end: Union[datetime, str],
all_raw_data: bool = False,
) -> Any:
"""
Retrieve the indicator data for a specific date range.
This method fetches the indicator data for a given date range, either returning
the raw JSON response or the specific indicator values.
:param target_dt_start: The start date for the range,
either as a datetime object or a string.
:type target_dt_start: Union[datetime, str]
:param target_dt_end: The end date for the range,
either as a datetime object or a string.
:type target_dt_end: Union[datetime, str]
:param all_raw_data: If True, returns the entire raw JSON response; otherwise,
only returns the indicator values.
:type all_raw_data: bool, optional
:return: The requested data, either as a raw JSON or
as specific indicator values.
:rtype: Any
"""
if isinstance(target_dt_start, datetime):
target_dt_start = target_dt_start.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
if isinstance(target_dt_end, datetime):
Expand Down

0 comments on commit 48c36f9

Please sign in to comment.