# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

from ..core.datetime_utils import serialize_datetime
from .client_facing_source import ClientFacingSource
from .client_facing_sport import ClientFacingSport

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class ClientFacingWorkout(pydantic.BaseModel):
    user_id: str = pydantic.Field(
        description="User id returned by vital create user request. This id should be stored in your database against the user and used for all interactions with the vital api."
    )
    id: str
    title: typing.Optional[str]
    timezone_offset: typing.Optional[int]
    average_hr: typing.Optional[int]
    max_hr: typing.Optional[int]
    distance: typing.Optional[float]
    calendar_date: str = pydantic.Field(
        description="Date of the workout summary in the YYYY-mm-dd format. This generally matches the workout start date."
    )
    time_start: dt.datetime = pydantic.Field(description="Start time of the workout::time")
    time_end: dt.datetime = pydantic.Field(description="End time of the workout::time")
    calories: typing.Optional[float]
    sport: typing.Optional[ClientFacingSport] = pydantic.Field(description="Sport's name")
    hr_zones: typing.Optional[typing.List[int]]
    moving_time: typing.Optional[int]
    total_elevation_gain: typing.Optional[float]
    elev_high: typing.Optional[float]
    elev_low: typing.Optional[float]
    average_speed: typing.Optional[float]
    max_speed: typing.Optional[float]
    average_watts: typing.Optional[float]
    device_watts: typing.Optional[float]
    max_watts: typing.Optional[float]
    weighted_average_watts: typing.Optional[float]
    steps: typing.Optional[int]
    map_: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(alias="map")
    provider_id: str = pydantic.Field(description="Provider ID given for that specific workout")
    source: ClientFacingSource = pydantic.Field(description="Source the data has come from.")

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        allow_population_by_field_name = True
        json_encoders = {dt.datetime: serialize_datetime}
