"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .lineitem import LineItem, LineItemTypedDict
from panora_sdk.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, TypedDict
from typing_extensions import NotRequired


class UnifiedEcommerceOrderInputFieldMappingsTypedDict(TypedDict):
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    
    

class UnifiedEcommerceOrderInputFieldMappings(BaseModel):
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    
    

class UnifiedEcommerceOrderInputTypedDict(TypedDict):
    order_status: NotRequired[Nullable[str]]
    r"""The status of the order"""
    order_number: NotRequired[Nullable[str]]
    r"""The number of the order"""
    payment_status: NotRequired[Nullable[str]]
    r"""The payment status of the order"""
    currency: NotRequired[Nullable[str]]
    r"""The currency of the order. Authorized value must be of type CurrencyCode (ISO 4217)"""
    total_price: NotRequired[Nullable[float]]
    r"""The total price of the order"""
    total_discount: NotRequired[Nullable[float]]
    r"""The total discount on the order"""
    total_shipping: NotRequired[Nullable[float]]
    r"""The total shipping cost of the order"""
    total_tax: NotRequired[Nullable[float]]
    r"""The total tax on the order"""
    fulfillment_status: NotRequired[Nullable[str]]
    r"""The fulfillment status of the order"""
    customer_id: NotRequired[Nullable[str]]
    r"""The UUID of the customer associated with the order"""
    items: NotRequired[Nullable[List[LineItemTypedDict]]]
    r"""The items in the order"""
    field_mappings: NotRequired[Nullable[UnifiedEcommerceOrderInputFieldMappingsTypedDict]]
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    

class UnifiedEcommerceOrderInput(BaseModel):
    order_status: OptionalNullable[str] = UNSET
    r"""The status of the order"""
    order_number: OptionalNullable[str] = UNSET
    r"""The number of the order"""
    payment_status: OptionalNullable[str] = UNSET
    r"""The payment status of the order"""
    currency: OptionalNullable[str] = UNSET
    r"""The currency of the order. Authorized value must be of type CurrencyCode (ISO 4217)"""
    total_price: OptionalNullable[float] = UNSET
    r"""The total price of the order"""
    total_discount: OptionalNullable[float] = UNSET
    r"""The total discount on the order"""
    total_shipping: OptionalNullable[float] = UNSET
    r"""The total shipping cost of the order"""
    total_tax: OptionalNullable[float] = UNSET
    r"""The total tax on the order"""
    fulfillment_status: OptionalNullable[str] = UNSET
    r"""The fulfillment status of the order"""
    customer_id: OptionalNullable[str] = UNSET
    r"""The UUID of the customer associated with the order"""
    items: OptionalNullable[List[LineItem]] = UNSET
    r"""The items in the order"""
    field_mappings: OptionalNullable[UnifiedEcommerceOrderInputFieldMappings] = UNSET
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    
    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["order_status", "order_number", "payment_status", "currency", "total_price", "total_discount", "total_shipping", "total_tax", "fulfillment_status", "customer_id", "items", "field_mappings"]
        nullable_fields = ["order_status", "order_number", "payment_status", "currency", "total_price", "total_discount", "total_shipping", "total_tax", "fulfillment_status", "customer_id", "items", "field_mappings"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields
                or (
                    k in optional_fields
                    and k in nullable_fields
                    and (
                        self.__pydantic_fields_set__.intersection({n})
                        or k in null_default_fields
                    )  # pylint: disable=no-member
                )
            ):
                m[k] = val

        return m
        
