"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 486fbe5d6fe3

from __future__ import annotations
from .mode import Mode
from .terminal_brand import TerminalBrand
from .terminal_model import TerminalModel
from .url import URL, URLTypedDict
from enum import Enum
from mollie import models, utils
from mollie.types import BaseModel, Nullable, UNSET_SENTINEL
import pydantic
from pydantic import field_serializer, model_serializer
from typing_extensions import Annotated, TypedDict


class ListEntityTerminalStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The status of the terminal."""

    PENDING = "pending"
    ACTIVE = "active"
    INACTIVE = "inactive"


class ListEntityTerminalLinksTypedDict(TypedDict):
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""

    self_: URLTypedDict
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""


class ListEntityTerminalLinks(BaseModel):
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""

    self_: Annotated[URL, pydantic.Field(alias="self")]
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""


class ListEntityTerminalTypedDict(TypedDict):
    resource: str
    r"""Indicates the response contains a terminal object. Will always contain the string `terminal` for this endpoint."""
    id: str
    r"""The identifier uniquely referring to this terminal. Example: `term_7MgL4wea46qkRcoTZjWEH`."""
    mode: Mode
    r"""Whether this entity was created in live mode or in test mode."""
    description: str
    r"""A short description of the terminal. The description can be used as an identifier for the terminal. Currently, the
    description is set when the terminal is initially configured. It will be visible in the Mollie Dashboard, and it
    may be visible on the device itself depending on the device.
    """
    status: ListEntityTerminalStatus
    brand: Nullable[TerminalBrand]
    r"""The brand of the terminal."""
    model: Nullable[TerminalModel]
    r"""The model of the terminal. For example for a PAX A920, this field's value will be `A920`."""
    serial_number: Nullable[str]
    r"""The serial number of the terminal. The serial number is provided at terminal creation time."""
    currency: str
    r"""The currency configured on the terminal, in ISO 4217 format. Currently most of our terminals are bound to a
    specific currency, chosen during setup.
    """
    profile_id: str
    r"""The identifier referring to the [profile](get-profile) this entity belongs to.

    Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted in the creation
    request. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is
    required.
    """
    created_at: str
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""
    updated_at: str
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""
    links: ListEntityTerminalLinksTypedDict
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""


class ListEntityTerminal(BaseModel):
    resource: str
    r"""Indicates the response contains a terminal object. Will always contain the string `terminal` for this endpoint."""

    id: str
    r"""The identifier uniquely referring to this terminal. Example: `term_7MgL4wea46qkRcoTZjWEH`."""

    mode: Mode
    r"""Whether this entity was created in live mode or in test mode."""

    description: str
    r"""A short description of the terminal. The description can be used as an identifier for the terminal. Currently, the
    description is set when the terminal is initially configured. It will be visible in the Mollie Dashboard, and it
    may be visible on the device itself depending on the device.
    """

    status: ListEntityTerminalStatus

    brand: Nullable[TerminalBrand]
    r"""The brand of the terminal."""

    model: Nullable[TerminalModel]
    r"""The model of the terminal. For example for a PAX A920, this field's value will be `A920`."""

    serial_number: Annotated[Nullable[str], pydantic.Field(alias="serialNumber")]
    r"""The serial number of the terminal. The serial number is provided at terminal creation time."""

    currency: str
    r"""The currency configured on the terminal, in ISO 4217 format. Currently most of our terminals are bound to a
    specific currency, chosen during setup.
    """

    profile_id: Annotated[str, pydantic.Field(alias="profileId")]
    r"""The identifier referring to the [profile](get-profile) this entity belongs to.

    Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted in the creation
    request. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is
    required.
    """

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""

    updated_at: Annotated[str, pydantic.Field(alias="updatedAt")]
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""

    links: Annotated[ListEntityTerminalLinks, pydantic.Field(alias="_links")]
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""

    @field_serializer("mode")
    def serialize_mode(self, value):
        if isinstance(value, str):
            try:
                return models.Mode(value)
            except ValueError:
                return value
        return value

    @field_serializer("status")
    def serialize_status(self, value):
        if isinstance(value, str):
            try:
                return models.ListEntityTerminalStatus(value)
            except ValueError:
                return value
        return value

    @field_serializer("brand")
    def serialize_brand(self, value):
        if isinstance(value, str):
            try:
                return models.TerminalBrand(value)
            except ValueError:
                return value
        return value

    @field_serializer("model")
    def serialize_model(self, value):
        if isinstance(value, str):
            try:
                return models.TerminalModel(value)
            except ValueError:
                return value
        return value

    @model_serializer(mode="wrap")
    def _serialize_model(self, handler):
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                m[k] = val

        return m


try:
    ListEntityTerminalLinks.model_rebuild()
except NameError:
    pass
try:
    ListEntityTerminal.model_rebuild()
except NameError:
    pass
