# Generated by ariadne-codegen
# Source: metasrht/graphql/

from datetime import datetime
from typing import Annotated, Optional

from iso3166 import Country
from pydantic import BeforeValidator, Field
from srht.graphql import gql_time

from metasrht.countries import parse

from .base_model import BaseModel
from .enums import Currency


class BillingAddress(BaseModel):
    full_name: Optional[str] = Field(alias="fullName")
    business_name: Optional[str] = Field(alias="businessName")
    address_1: Optional[str] = Field(alias="address1")
    address_2: Optional[str] = Field(alias="address2")
    city: Optional[str]
    region: Optional[str]
    postcode: Optional[str]
    country: Optional[Annotated[Country, BeforeValidator(parse)]]
    vat: Optional[str]


class ClientRegistration(BaseModel):
    client: "ClientRegistrationClient"
    secret: str


class ClientRegistrationClient(BaseModel):
    uuid: str


class Invoice(BaseModel):
    id: int
    invoice_no: str = Field(alias="invoiceNo")
    issued: Annotated[datetime, BeforeValidator(gql_time)]
    service_end: Annotated[datetime, BeforeValidator(gql_time)] = Field(
        alias="serviceEnd"
    )
    total: int
    currency: Currency


class OauthGrant(BaseModel):
    grant: "OauthGrantGrant"
    grants: str
    secret: str
    refresh_token: str = Field(alias="refreshToken")


class OauthGrantGrant(BaseModel):
    expires: Annotated[datetime, BeforeValidator(gql_time)]


class Product(BaseModel):
    id: int
    name: str
    subsidized: bool
    prices: list["ProductPrices"]


class ProductPrices(BaseModel):
    currency: Currency
    amount: int


BillingAddress.model_rebuild()
ClientRegistration.model_rebuild()
Invoice.model_rebuild()
OauthGrant.model_rebuild()
Product.model_rebuild()
