blockfrost / blockfrost-python

Python 3 SDK for the Blockfrost.io API.
https://blockfrost.io/
Apache License 2.0
67 stars 18 forks source link

Duplicate epoch_latest_parameters #19

Closed mateusap1 closed 2 years ago

mateusap1 commented 2 years ago

In api/cardano/epochs.py we have the method epoch_latest_parameters defined two times, the first one with the right definition:

@request_wrapper
def epoch_latest_parameters(self, **kwargs):
    """
    Return the protocol parameters for the latest epoch.
    https://docs.blockfrost.io/#tag/Cardano-Epochs/paths/~1epochs~1latest~1parameters/get
    :param return_type: Optional. "object", "json" or "pandas". Default: "object".
    :type return_type: str
    :returns object.
    :rtype: Namespace
    :raises ApiError: If API fails
    :raises Exception: If the API response is somehow malformed.
    """
    return requests.get(
        url=f"{self.url}/epochs/latest/parameters",
        headers=self.default_headers
    )

This doesn't require any integer parameter, because it will get the latest parameter.

The second definition, though, I suppose is wrong

@request_wrapper
def epoch_latest_parameters(self, number: int, **kwargs):
    """
    Return the protocol parameters for the epoch specified.
    https://docs.blockfrost.io/#tag/Cardano-Epochs/paths/~1epochs~1{number}~1parameters/get
    :param number: Number of the epoch.
    :type number: int
    :param return_type: Optional. "object", "json" or "pandas". Default: "object".
    :type return_type: str
    :returns object.
    :rtype: Namespace
    :raises ApiError: If API fails
    :raises Exception: If the API response is somehow malformed.
    """
    return requests.get(
        url=f"{self.url}/epochs/{number}/parameters",
        headers=self.default_headers
    )

It requires an integer and will get the parameters from this specific epoch.

I suppose this is a mistake and the last name should be something like "epoch_parameters".

mathiasfrohlich commented 2 years ago

Hey @mateusap1

Thanks for bringing this to my attention. The one with a function parameter should really be named epoch_protocol_parameters. This will be changed in the next version.