Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login and authentication #37

Open
github-actions bot opened this issue Jan 1, 2024 · 0 comments
Open

Login and authentication #37

github-actions bot opened this issue Jan 1, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@github-actions
Copy link

github-actions bot commented Jan 1, 2024

TODO: Login and authentication

from pysurfline.api.services import ApiService
from pysurfline.core import SpotForecasts


class SurflineClient:
    """surfline client

    Surfline API client.
    At the moment, does not require authentication.

    TODO: Login and authentication
    """

    _baseurl: str = "https://services.surfline.com/kbyg/"

    def get_spot_forecasts(
        self, spotId: str, intervalHours: int = None, days: int = None
    ) -> SpotForecasts:
        """create a SpotForecast object from API responses

        Arguments:
            spotId (str): spot id
            intervalHours (int, optional): interval hours. Defaults to None.
            days (int, optional): days. Defaults to None.

        Returns:
            SpotForecast: SpotForecast object
        """
        params = {}
        params["spotId"] = spotId

        # add optional parameters
        if intervalHours:
            params["intervalHours"] = intervalHours
        if days:
            params["days"] = days

        return SpotForecasts(
            spotId,
            # spot datails are integrated with forecast,
            # hence the different GET args
            details=ApiService(self, "spots/details").get({"spotId": spotId}),
            waves=ApiService(self, "spots/forecasts/wave").get(params=params),
            winds=ApiService(self, "spots/forecasts/wind").get(params=params),
            tides=ApiService(self, "spots/forecasts/tides").get(params=params),
            # weather and sunlight times are in the same response
            weather=ApiService(self, "spots/forecasts/weather").get(params=params)[0],
            sunlightTimes=ApiService(self, "spots/forecasts/weather").get(
                params=params
            )[1],
        )
@github-actions github-actions bot added the todo label Jan 1, 2024
@giocaizzi giocaizzi self-assigned this Jun 6, 2024
@giocaizzi giocaizzi added this to the v0.3 milestone Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant