# generated by datamodel-codegen:
#   filename:  purchase_order.xsd
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from decimal import Decimal
from enum import Enum

from pydantic import BaseModel, Field, RootModel, conint, constr


class CountryCode(RootModel[constr(pattern=r'[A-Z]{2}', min_length=2, max_length=2)]):
    root: constr(pattern=r'[A-Z]{2}', min_length=2, max_length=2) = Field(
        ..., title='CountryCode'
    )


class OrderStatus(Enum):
    draft = 'draft'
    paid = 'paid'
    shipped = 'shipped'


class AddressType(BaseModel):
    street: str
    city: str
    country: CountryCode | None = None


class Money(BaseModel):
    value: Decimal
    currency: str


class LineItemType(BaseModel):
    sku: str
    quantity: conint(ge=1)
    note: str | None = None
    price: Money
    lineNumber: conint(ge=0, le=4294967295)


class ExpressLineItemType(LineItemType):
    trackingCode: str | None = None


class PurchaseOrderType(BaseModel):
    orderId: str
    status: OrderStatus
    shippingAddress: AddressType
    item: list[LineItemType] = Field(..., min_length=1)
    expressItem: list[ExpressLineItemType] | None = None
    priority: bool | None = False


class PurchaseOrder(PurchaseOrderType):
    pass
