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

from __future__ import annotations
from abbyy_document_ai.types import BaseModel
from datetime import date
import pydantic
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class DeclarationTypeTypedDict(TypedDict):
    part1: NotRequired[str]
    r"""First subdivision of the declaration type code (EU, EX, CO, IM)"""
    part2: NotRequired[str]
    r"""Second subdivision of the declaration type code (A, B, C, D, E, F)"""
    part3: NotRequired[str]
    r"""Third subdivision of the declaration type code (can be blank)"""


class DeclarationType(BaseModel):
    part1: Optional[str] = None
    r"""First subdivision of the declaration type code (EU, EX, CO, IM)"""

    part2: Optional[str] = None
    r"""Second subdivision of the declaration type code (A, B, C, D, E, F)"""

    part3: Optional[str] = None
    r"""Third subdivision of the declaration type code (can be blank)"""


class FormsTypedDict(TypedDict):
    part1: NotRequired[float]
    r"""The declaration page number"""
    part2: NotRequired[float]
    r"""The total number of pages"""


class Forms(BaseModel):
    part1: Optional[float] = None
    r"""The declaration page number"""

    part2: Optional[float] = None
    r"""The total number of pages"""


class ReferenceNumberTypedDict(TypedDict):
    reference_number: str
    r"""The reference number (for tracking)"""


class ReferenceNumber(BaseModel):
    reference_number: Annotated[str, pydantic.Field(alias="referenceNumber")]
    r"""The reference number (for tracking)"""


class ConsignorTypedDict(TypedDict):
    name: NotRequired[str]
    r"""The consignor's name"""
    address: NotRequired[str]
    r"""The consignor's address"""
    eori_number: NotRequired[str]
    r"""The consignor's Economic Operators Registration and Identification (EORI) number"""


class Consignor(BaseModel):
    name: Optional[str] = None
    r"""The consignor's name"""

    address: Optional[str] = None
    r"""The consignor's address"""

    eori_number: Annotated[Optional[str], pydantic.Field(alias="eoriNumber")] = None
    r"""The consignor's Economic Operators Registration and Identification (EORI) number"""


class CustomsDeclarationFieldsConsigneeTypedDict(TypedDict):
    name: NotRequired[str]
    r"""The consignee's name"""
    address: NotRequired[str]
    r"""The consignee's address"""
    eori_number: NotRequired[str]
    r"""The consignee's Economic Operators Registration and Identification (EORI) number"""


class CustomsDeclarationFieldsConsignee(BaseModel):
    name: Optional[str] = None
    r"""The consignee's name"""

    address: Optional[str] = None
    r"""The consignee's address"""

    eori_number: Annotated[Optional[str], pydantic.Field(alias="eoriNumber")] = None
    r"""The consignee's Economic Operators Registration and Identification (EORI) number"""


class DeclarantTypedDict(TypedDict):
    name: NotRequired[str]
    r"""The declarant's name"""
    address: NotRequired[str]
    r"""The declarant's address"""
    eori_number: NotRequired[str]
    r"""The declarant's Economic Operators Registration and Identification (EORI) number"""


class Declarant(BaseModel):
    name: Optional[str] = None
    r"""The declarant's name"""

    address: Optional[str] = None
    r"""The declarant's address"""

    eori_number: Annotated[Optional[str], pydantic.Field(alias="eoriNumber")] = None
    r"""The declarant's Economic Operators Registration and Identification (EORI) number"""


class ControlByOfficeOfDispatchTypedDict(TypedDict):
    result: NotRequired[str]
    r"""Other information specified by the customs office"""
    seals_affixed: NotRequired[bool]
    r"""Whether seals were affixed"""
    seals_identity: NotRequired[str]
    r"""Identity of the seals"""
    time_limit: NotRequired[str]
    r"""Time limit for the declaration"""


class ControlByOfficeOfDispatch(BaseModel):
    result: Optional[str] = None
    r"""Other information specified by the customs office"""

    seals_affixed: Annotated[Optional[bool], pydantic.Field(alias="sealsAffixed")] = (
        None
    )
    r"""Whether seals were affixed"""

    seals_identity: Annotated[Optional[str], pydantic.Field(alias="sealsIdentity")] = (
        None
    )
    r"""Identity of the seals"""

    time_limit: Annotated[Optional[str], pydantic.Field(alias="timeLimit")] = None
    r"""Time limit for the declaration"""


class CustomsDeclarationFieldsTypedDict(TypedDict):
    r"""Fields extracted from a customs declaration"""

    movement_reference_number: NotRequired[str]
    r"""The Movement Reference Number (MRN)"""
    movement_reference_number_barcode: NotRequired[str]
    r"""The MRN barcode"""
    issuing_date: NotRequired[date]
    r"""The date on which the declaration was issued"""
    customs_office: NotRequired[str]
    r"""The customs office identifier"""
    declaration_type: NotRequired[DeclarationTypeTypedDict]
    forms: NotRequired[List[FormsTypedDict]]
    security_declaration: NotRequired[str]
    r"""Specifies whether the declaration contains additional risk analysis documents (S or empty)"""
    items: NotRequired[float]
    r"""The number of items in the shipment"""
    total_packages: NotRequired[float]
    r"""The total number of packages"""
    reference_number: NotRequired[List[ReferenceNumberTypedDict]]
    transport_charges_method_of_payment_code: NotRequired[str]
    r"""The code for the method of payment used to cover transport charges"""
    consignor: NotRequired[ConsignorTypedDict]
    consignee: NotRequired[CustomsDeclarationFieldsConsigneeTypedDict]
    declarant: NotRequired[List[DeclarantTypedDict]]
    export_country_code: NotRequired[str]
    r"""The consignor's country code"""
    destination_country_code: NotRequired[str]
    r"""The consignee's country code"""
    countries_of_routing_codes: NotRequired[str]
    r"""The codes for countries of routing for the shipment"""
    identity_of_means_of_transport_at_departure: NotRequired[str]
    r"""The identifier for the means of transport at departure"""
    nationality_of_means_of_transport_at_departure: NotRequired[str]
    r"""The country of registration of the transport at departure"""
    container: NotRequired[str]
    r"""Specifies whether the goods are being shipped in a container (0 or 1)"""
    identity_of_means_of_transport_at_border: NotRequired[str]
    r"""The identifier for the transport shipping the goods when they are presented at the border"""
    nationality_of_means_of_transport_at_border: NotRequired[str]
    r"""The country of registration of the transport shipping the goods when they are presented at the border"""
    currency: NotRequired[str]
    r"""The currency used to specify the value of the goods in the declaration"""
    total: NotRequired[float]
    r"""The total value of the shipped goods"""
    exchange_rate: NotRequired[float]
    r"""The currency exchange rate"""
    mode_of_transport_at_border: NotRequired[str]
    r"""The mode of transport used to arrive at the border (road, rail, air, sea)"""
    internal_mode_of_transport: NotRequired[str]
    r"""The internal mode of transport of the goods (road, rail, air, sea)"""
    customs_office_of_exit: NotRequired[str]
    r"""Identifier of the customs office that released the goods"""
    location_of_goods: NotRequired[str]
    r"""The location where the goods are stored before customs clearance"""
    gross_weight_in_kg: NotRequired[float]
    r"""The total gross weight of the packaged goods (in kilograms)"""
    seal_number: NotRequired[str]
    r"""The seal number"""
    control_by_office_of_dispatch: NotRequired[ControlByOfficeOfDispatchTypedDict]


class CustomsDeclarationFields(BaseModel):
    r"""Fields extracted from a customs declaration"""

    movement_reference_number: Annotated[
        Optional[str], pydantic.Field(alias="movementReferenceNumber")
    ] = None
    r"""The Movement Reference Number (MRN)"""

    movement_reference_number_barcode: Annotated[
        Optional[str], pydantic.Field(alias="movementReferenceNumberBarcode")
    ] = None
    r"""The MRN barcode"""

    issuing_date: Annotated[Optional[date], pydantic.Field(alias="issuingDate")] = None
    r"""The date on which the declaration was issued"""

    customs_office: Annotated[Optional[str], pydantic.Field(alias="customsOffice")] = (
        None
    )
    r"""The customs office identifier"""

    declaration_type: Annotated[
        Optional[DeclarationType], pydantic.Field(alias="declarationType")
    ] = None

    forms: Optional[List[Forms]] = None

    security_declaration: Annotated[
        Optional[str], pydantic.Field(alias="securityDeclaration")
    ] = None
    r"""Specifies whether the declaration contains additional risk analysis documents (S or empty)"""

    items: Optional[float] = None
    r"""The number of items in the shipment"""

    total_packages: Annotated[
        Optional[float], pydantic.Field(alias="totalPackages")
    ] = None
    r"""The total number of packages"""

    reference_number: Annotated[
        Optional[List[ReferenceNumber]], pydantic.Field(alias="referenceNumber")
    ] = None

    transport_charges_method_of_payment_code: Annotated[
        Optional[str], pydantic.Field(alias="transportChargesMethodOfPaymentCode")
    ] = None
    r"""The code for the method of payment used to cover transport charges"""

    consignor: Optional[Consignor] = None

    consignee: Optional[CustomsDeclarationFieldsConsignee] = None

    declarant: Optional[List[Declarant]] = None

    export_country_code: Annotated[
        Optional[str], pydantic.Field(alias="exportCountryCode")
    ] = None
    r"""The consignor's country code"""

    destination_country_code: Annotated[
        Optional[str], pydantic.Field(alias="destinationCountryCode")
    ] = None
    r"""The consignee's country code"""

    countries_of_routing_codes: Annotated[
        Optional[str], pydantic.Field(alias="countriesOfRoutingCodes")
    ] = None
    r"""The codes for countries of routing for the shipment"""

    identity_of_means_of_transport_at_departure: Annotated[
        Optional[str], pydantic.Field(alias="identityOfMeansOfTransportAtDeparture")
    ] = None
    r"""The identifier for the means of transport at departure"""

    nationality_of_means_of_transport_at_departure: Annotated[
        Optional[str], pydantic.Field(alias="nationalityOfMeansOfTransportAtDeparture")
    ] = None
    r"""The country of registration of the transport at departure"""

    container: Optional[str] = None
    r"""Specifies whether the goods are being shipped in a container (0 or 1)"""

    identity_of_means_of_transport_at_border: Annotated[
        Optional[str], pydantic.Field(alias="identityOfMeansOfTransportAtBorder")
    ] = None
    r"""The identifier for the transport shipping the goods when they are presented at the border"""

    nationality_of_means_of_transport_at_border: Annotated[
        Optional[str], pydantic.Field(alias="nationalityOfMeansOfTransportAtBorder")
    ] = None
    r"""The country of registration of the transport shipping the goods when they are presented at the border"""

    currency: Optional[str] = None
    r"""The currency used to specify the value of the goods in the declaration"""

    total: Optional[float] = None
    r"""The total value of the shipped goods"""

    exchange_rate: Annotated[Optional[float], pydantic.Field(alias="exchangeRate")] = (
        None
    )
    r"""The currency exchange rate"""

    mode_of_transport_at_border: Annotated[
        Optional[str], pydantic.Field(alias="modeOfTransportAtBorder")
    ] = None
    r"""The mode of transport used to arrive at the border (road, rail, air, sea)"""

    internal_mode_of_transport: Annotated[
        Optional[str], pydantic.Field(alias="internalModeOfTransport")
    ] = None
    r"""The internal mode of transport of the goods (road, rail, air, sea)"""

    customs_office_of_exit: Annotated[
        Optional[str], pydantic.Field(alias="customsOfficeOfExit")
    ] = None
    r"""Identifier of the customs office that released the goods"""

    location_of_goods: Annotated[
        Optional[str], pydantic.Field(alias="locationOfGoods")
    ] = None
    r"""The location where the goods are stored before customs clearance"""

    gross_weight_in_kg: Annotated[
        Optional[float], pydantic.Field(alias="grossWeightInKg")
    ] = None
    r"""The total gross weight of the packaged goods (in kilograms)"""

    seal_number: Annotated[Optional[str], pydantic.Field(alias="sealNumber")] = None
    r"""The seal number"""

    control_by_office_of_dispatch: Annotated[
        Optional[ControlByOfficeOfDispatch],
        pydantic.Field(alias="controlByOfficeOfDispatch"),
    ] = None
