from collections.abc import Sequence
from typing import Literal

from ..common import (
    DeliveryConfirmationMethods,
    ErrorResponse,
    ShipStationClient,
    ShipStationConnection,
    V1Address,
    V1Dimensions,
    V1Weight,
)
from ._types import (
    V1AdvancedOptions,
    V1BatchOrderCreationResponse,
    V1InsuranceOptions,
    V1InternationalOptions,
    V1Order,
    V1OrderItem,
    V1OrderLabel,
    V1OrderListResponse,
)

class OrderPortal(ShipStationClient):
    @classmethod
    async def where(
        cls: type["OrderPortal"],
        connection: ShipStationConnection,
        customerName: str | None = None,
        itemKeyword: str | None = None,
        createDateStart: str | None = None,
        createDateEnd: str | None = None,
        customsCountryCode: str | None = None,
        modifyDateStart: str | None = None,
        modifyDateEnd: str | None = None,
        orderDateStart: str | None = None,
        orderDateEnd: str | None = None,
        orderNumber: str | None = None,
        orderStatus: (
            Literal[
                "awaiting_payment",
                "awaiting_shipment",
                "pending_fulfillment",
                "shipped",
                "on_hold",
                "cancelled",
                "rejected_fulfillment",
            ]
            | None
        ) = None,
        paymentDateStart: str | None = None,
        paymentDateEnd: str | None = None,
        storeId: int | None = None,
        sortBy: Literal["OrderDate", "ModifyDate", "CreateDate"] | None = None,
        sortDir: Literal["DESC", "ASC"] | None = None,
        page: int | None = None,
        pageSize: int | None = None,
        identity: bool = False,
    ) -> tuple[int, ErrorResponse | V1OrderListResponse]: ...
    @classmethod
    async def create_label(
        cls: type["OrderPortal"],
        connection: ShipStationConnection,
        orderId: int,
        carrierCode: str,
        serviceCode: str,
        confirmation: Literal[
            "none", "delivery", "signature", "adult_signature", "direct_signature"
        ],
        shipDate: str,
        weight: V1Weight | None = None,
        dimensions: V1Dimensions | None = None,
        insuranceoptions: V1InsuranceOptions | None = None,
        internationalOptions: V1InternationalOptions | None = None,
        advancedOptions: V1AdvancedOptions | None = None,
        testLabel: bool = False,
        identity: bool = False,
    ) -> tuple[int, V1OrderLabel | ErrorResponse]: ...
    @classmethod
    async def update_order(
        cls: type["OrderPortal"],
        connection: ShipStationConnection,
        orderNumber: str,
        orderStatus: Literal[
            "awaiting_payment",
            "awaiting_shipment",
            "shipped",
            "on_hold",
            "cancelled",
            "pending_fulfillment",
        ],
        billTo: V1Address,
        shipTo: V1Address,
        orderId: int | None = None,
        orderKey: str | None = None,
        orderDate: str | None = None,
        paymentDate: str | None = None,
        shipByDate: str | None = None,
        customerUsername: str | None = None,
        customerEmail: str | None = None,
        items: Sequence[V1OrderItem] | None = None,
        amountPaid: float | None = None,
        taxAmount: float | None = None,
        shippingAmount: float | None = None,
        customerNotes: str | None = None,
        internalNotes: str | None = None,
        gift: bool | None = None,
        giftMessage: str | None = None,
        paymentMethod: str | None = None,
        requestedShippingService: str | None = None,
        carrierCode: str | None = None,
        serviceCode: str | None = None,
        packageCode: str | None = None,
        confirmation: DeliveryConfirmationMethods | None = None,
        shipDate: str | None = None,
        weight: V1Weight | None = None,
        dimensions: V1Dimensions | None = None,
        insuranceOptions: V1InsuranceOptions | None = None,
        internationalOptions: V1InternationalOptions | None = None,
        customsCountryCode: str | None = None,
        advancedOptions: V1AdvancedOptions | None = None,
        tagIds: Sequence[int] | None = None,
        identity: bool = False,
    ) -> tuple[int, V1Order | ErrorResponse]: ...
    @classmethod
    async def create_order(
        cls: type["OrderPortal"],
        connection: ShipStationConnection,
        orderNumber: str,
        orderStatus: Literal[
            "awaiting_payment",
            "awaiting_shipment",
            "shipped",
            "on_hold",
            "cancelled",
            "pending_fulfillment",
        ],
        billTo: V1Address,
        shipTo: V1Address,
        orderKey: str | None = None,
        orderDate: str | None = None,
        paymentDate: str | None = None,
        shipByDate: str | None = None,
        customerUsername: str | None = None,
        customerEmail: str | None = None,
        items: Sequence[V1OrderItem] | None = None,
        amountPaid: float | None = None,
        taxAmount: float | None = None,
        shippingAmount: float | None = None,
        customerNotes: str | None = None,
        internalNotes: str | None = None,
        gift: bool | None = None,
        giftMessage: str | None = None,
        paymentMethod: str | None = None,
        requestedShippingService: str | None = None,
        carrierCode: str | None = None,
        serviceCode: str | None = None,
        packageCode: str | None = None,
        confirmation: DeliveryConfirmationMethods | None = None,
        shipDate: str | None = None,
        weight: V1Weight | None = None,
        dimensions: V1Dimensions | None = None,
        insuranceOptions: V1InsuranceOptions | None = None,
        internationalOptions: V1InternationalOptions | None = None,
        customsCountryCode: str | None = None,
        advancedOptions: V1AdvancedOptions | None = None,
        tagIds: Sequence[int] | None = None,
        identity: bool = False,
    ) -> tuple[int, V1Order | ErrorResponse]: ...
    @classmethod
    async def create_or_update_orders(
        cls: type["OrderPortal"],
        connection: ShipStationConnection,
        orders: Sequence[V1Order],
        identity: bool = False,
    ) -> tuple[int, V1BatchOrderCreationResponse | ErrorResponse]: ...
