Repository: OpenBB-finance/OpenBBTerminal
File: openbb_platform/providers/fmp/openbb_fmp/models/earnings_call_transcript.py (Python)

Code before:

from datetime import datetime
from typing import Any, Dict, List, Optional

from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.earnings_call_transcript import (
    EarningsCallTranscriptData,
    EarningsCallTranscriptQueryParams,
)
from openbb_fmp.utils.helpers import create_url, get_data_many
from pydantic import field_validator


class FMPEarningsCallTranscriptQueryParams(EarningsCallTranscriptQueryParams):
    """FMP Earnings Call Transcript Query.

    Source: https://site.financialmodelingprep.com/developer/docs/earning-call-transcript-api/
    """

    @field_validator("year", mode="before", check_fields=False)
    @classmethod
    def time_validate(cls, v: int):  # pylint: disable=E0213
        """Return the year as an integer."""
        current_year = datetime.now().year
        # Current year + 1 to account for potential fiscal year.
        return current_year if v > (current_year + 1) or v < 1950 else v


class FMPEarningsCallTranscriptData(EarningsCallTranscriptData):
    """FMP Earnings Call Transcript Data."""

    @field_validator("date", mode="before", check_fields=False)
    @classmethod
    def date_validate(cls, v: str):  # pylint: disable=E0213
        """Return the date as a datetime object."""
        return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")


class FMPEarningsCallTranscriptFetcher(
    Fetcher[
        FMPEarningsCallTranscriptQueryParams,
        List[FMPEarningsCallTranscriptData],
    ]
):
    """Transform the query, extract and transform the data from the FMP endpoints."""

    @staticmethod
    def transform_query(params: Dict[str, Any]) -> FMPEarningsCallTranscriptQueryParams:
        """Transform the query params."""
        return FMPEarningsCallTranscriptQueryParams(**params)


Review comment (refactor):
Let's just remove this validator entirely. It does not need to exist

![Screenshot 2024-06-13 at 4 07 44 PM](https://github.com/OpenBB-finance/OpenBBTerminal/assets/85772166/ee0f07cf-0ff8-4179-9507-a26d4bd3705c)



Code after:

# pylint: disable=unused-argument

from datetime import datetime
from typing import Any, Dict, List, Optional

from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.earnings_call_transcript import (
    EarningsCallTranscriptData,
    EarningsCallTranscriptQueryParams,
)
from openbb_core.provider.utils.helpers import amake_requests
from pydantic import field_validator


class FMPEarningsCallTranscriptQueryParams(EarningsCallTranscriptQueryParams):
    """FMP Earnings Call Transcript Query.

    Source: https://site.financialmodelingprep.com/developer/docs/earning-call-transcript-api/
    """

    __json_schema_extra__ = {
        "symbol": {"multiple_items_allowed": True},
        "year": {"multiple_items_allowed": True},
    }


class FMPEarningsCallTranscriptData(EarningsCallTranscriptData):
    """FMP Earnings Call Transcript Data."""

    @field_validator("date", mode="before", check_fields=False)
    @classmethod
    def date_validate(cls, v):
        """Return the date as a datetime object."""
        return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")


class FMPEarningsCallTranscriptFetcher(
    Fetcher[
        FMPEarningsCallTranscriptQueryParams,
        List[FMPEarningsCallTranscriptData],
    ]
):
    """FMP Earnings Call Transcript Fetcher."""

    @staticmethod
    def transform_query(params: Dict[str, Any]) -> FMPEarningsCallTranscriptQueryParams:
        """Transform the query params."""
        return FMPEarningsCallTranscriptQueryParams(**params)

    @staticmethod