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

import typing

import typing_extensions
from ..types.fulfillment_delivery_details_order_fulfillment_delivery_details_schedule_type import (
    FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType,
)
from .fulfillment_recipient import FulfillmentRecipientParams


class FulfillmentDeliveryDetailsParams(typing_extensions.TypedDict):
    """
    Describes delivery details of an order fulfillment.
    """

    recipient: typing_extensions.NotRequired[FulfillmentRecipientParams]
    """
    The contact information for the person to receive the fulfillment.
    """

    schedule_type: typing_extensions.NotRequired[FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType]
    """
    Indicates the fulfillment delivery schedule type. If `SCHEDULED`, then
    `deliver_at` is required. The default is `SCHEDULED`.
    See [OrderFulfillmentDeliveryDetailsScheduleType](#type-orderfulfillmentdeliverydetailsscheduletype) for possible values
    """

    placed_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when the fulfillment was placed.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    
    Must be in RFC 3339 timestamp format, e.g., "2016-09-04T23:59:33.123Z".
    """

    deliver_at: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    that represents the start of the delivery period.
    The application can set this field while the fulfillment `state` is
    `PROPOSED`, `RESERVED`, or `PREPARED` (any time before the
    terminal state such as `COMPLETED`, `CANCELED`, and `FAILED`).
    
    The timestamp must be in RFC 3339 format
    (for example, "2016-09-04T23:59:33.123Z").
    
    For fulfillments with the schedule type `ASAP`, this is automatically set
    to the current time plus `prep_time_duration`, if available.
    """

    prep_time_duration: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [duration](https://developer.squareup.com/docs/build-basics/working-with-dates)
    needed to prepare and deliver this fulfillment.
    The duration must be in RFC 3339 format (for example, "PT30M" for 30 minutes). Don't confuse
    "M" for months with "M" for minutes. "P5M" means 5 months, while "PT5M" means 5 minutes.
    """

    delivery_window_duration: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [duration](https://developer.squareup.com/docs/build-basics/working-with-dates)
    after `deliver_at` in which to deliver the order.
    Applications can set this field when the fulfillment `state` is
    `PROPOSED`, `RESERVED`, or `PREPARED` (any time before the terminal state
    such as `COMPLETED`, `CANCELED`, and `FAILED`).
    
    The duration must be in RFC 3339 format (for example, "PT30M" for 30 minutes). Don't confuse
    "M" for months with "M" for minutes. "P5M" means 5 months, while "PT5M" means 5 minutes.
    """

    note: typing_extensions.NotRequired[typing.Optional[str]]
    """
    Provides additional instructions about the delivery fulfillment.
    It is displayed in the Square Point of Sale application and set by the API.
    """

    completed_at: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicates when the seller completed the fulfillment.
    This field is automatically set when  fulfillment `state` changes to `COMPLETED`.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    in_progress_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicates when the seller started processing the fulfillment.
    This field is automatically set when the fulfillment `state` changes to `RESERVED`.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    rejected_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when the fulfillment was rejected. This field is
    automatically set when the fulfillment `state` changes to `FAILED`.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    ready_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when the seller marked the fulfillment as ready for
    courier pickup. This field is automatically set when the fulfillment `state` changes
    to PREPARED.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    delivered_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when the fulfillment was delivered to the recipient.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    canceled_at: typing_extensions.NotRequired[str]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when the fulfillment was canceled. This field is automatically
    set when the fulfillment `state` changes to `CANCELED`.
    
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    cancel_reason: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The delivery cancellation reason. Max length: 100 characters.
    """

    courier_pickup_at: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates)
    indicating when an order can be picked up by the courier for delivery.
    The timestamp must be in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z").
    """

    courier_pickup_window_duration: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [duration](https://developer.squareup.com/docs/build-basics/working-with-dates)
    after `courier_pickup_at` in which the courier should pick up the order.
    The duration must be in RFC 3339 format (for example, "PT30M" for 30 minutes). Don't confuse
    "M" for months with "M" for minutes. "P5M" means 5 months, while "PT5M" means 5 minutes.
    """

    is_no_contact_delivery: typing_extensions.NotRequired[typing.Optional[bool]]
    """
    Whether the delivery is preferred to be no contact.
    """

    dropoff_notes: typing_extensions.NotRequired[typing.Optional[str]]
    """
    A note to provide additional instructions about how to deliver the order.
    """

    courier_provider_name: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The name of the courier provider.
    """

    courier_support_phone_number: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The support phone number of the courier.
    """

    square_delivery_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The identifier for the delivery created by Square.
    """

    external_delivery_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The identifier for the delivery created by the third-party courier service.
    """

    managed_delivery: typing_extensions.NotRequired[typing.Optional[bool]]
    """
    The flag to indicate the delivery is managed by a third party (ie DoorDash), which means
    we may not receive all recipient information for PII purposes.
    """
