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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .timecard_wage import TimecardWage
from .break_ import Break
from .timecard_status import TimecardStatus
from .money import Money
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class Timecard(UncheckedBaseModel):
    """
    A record of the hourly rate, start time, and end time of a single timecard (shift)
    for a team member. This might include a record of the start and end times of breaks
    taken during the shift.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    **Read only** The Square-issued UUID for this object.
    """

    location_id: str = pydantic.Field()
    """
    The ID of the [location](entity:Location) for this timecard. The location should be based on
    where the team member clocked in.
    """

    timezone: typing.Optional[str] = pydantic.Field(default=None)
    """
    **Read only** The time zone calculated from the location based on the `location_id`,
    provided as a convenience value. Format: the IANA time zone database identifier for the
    location time zone.
    """

    start_at: str = pydantic.Field()
    """
    The start time of the timecard, in RFC 3339 format and shifted to the location
    timezone + offset. Precision up to the minute is respected; seconds are truncated.
    """

    end_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    The end time of the timecard, in RFC 3339 format and shifted to the location
    timezone + offset. Precision up to the minute is respected; seconds are truncated.
    """

    wage: typing.Optional[TimecardWage] = pydantic.Field(default=None)
    """
    Job and pay related information. If the wage is not set on create, it defaults to a wage
    of zero. If the title is not set on create, it defaults to the name of the role the team member
    is assigned to, if any.
    """

    breaks: typing.Optional[typing.List[Break]] = pydantic.Field(default=None)
    """
    A list of all the paid or unpaid breaks that were taken during this timecard.
    """

    status: typing.Optional[TimecardStatus] = pydantic.Field(default=None)
    """
    Describes the working state of the timecard.
    See [TimecardStatus](#type-timecardstatus) for possible values
    """

    version: typing.Optional[int] = pydantic.Field(default=None)
    """
    **Read only** The current version of the timecard, which is incremented with each update.
    This field is used for [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency)
    control to ensure that requests don't overwrite data from another request.
    """

    created_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    The timestamp of when the timecard was created, in RFC 3339 format presented as UTC.
    """

    updated_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    The timestamp of when the timecard was last updated, in RFC 3339 format presented as UTC.
    """

    team_member_id: str = pydantic.Field()
    """
    The ID of the [team member](entity:TeamMember) this timecard belongs to.
    """

    declared_cash_tip_money: typing.Optional[Money] = pydantic.Field(default=None)
    """
    The cash tips declared by the team member for this timecard.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
