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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .shift_wage import ShiftWage
from .break_ import Break
from .shift_status import ShiftStatus
from .money import Money
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class Shift(UncheckedBaseModel):
    """
    A record of the hourly rate, start, and end times for a single work shift
    for an employee. This might include a record of the start and end times for breaks
    taken during the shift.

    Deprecated at Square API version 2025-05-21. Replaced by [Timecard](entity:Timecard).
    See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes).
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The UUID for this object.
    """

    employee_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the employee this shift belongs to. DEPRECATED at version 2020-08-26. Use `team_member_id` instead.
    """

    location_id: str = pydantic.Field()
    """
    The ID of the location this shift occurred at. The location should be based on
    where the employee clocked in.
    """

    timezone: typing.Optional[str] = pydantic.Field(default=None)
    """
    The read-only convenience value that is calculated from the location based
    on the `location_id`. Format: the IANA timezone database identifier for the
    location timezone.
    """

    start_at: str = pydantic.Field()
    """
    RFC 3339; 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)
    """
    RFC 3339; shifted to the timezone + offset. Precision up to the minute is
    respected; seconds are truncated.
    """

    wage: typing.Optional[ShiftWage] = 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 employee
    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 shift.
    """

    status: typing.Optional[ShiftStatus] = pydantic.Field(default=None)
    """
    Describes the working state of the current `Shift`.
    See [ShiftStatus](#type-shiftstatus) for possible values
    """

    version: typing.Optional[int] = pydantic.Field(default=None)
    """
    Used for resolving concurrency issues. The request fails if the version
    provided does not match the server version at the time of the request. If not provided,
    Square executes a blind write; potentially overwriting data from another
    write.
    """

    created_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    A read-only timestamp in RFC 3339 format; presented in UTC.
    """

    updated_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    A read-only timestamp in RFC 3339 format; presented in UTC.
    """

    team_member_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the team member this shift belongs to. Replaced `employee_id` at version "2020-08-26".
    """

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

    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
