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

from __future__ import annotations
from enum import Enum
from mollie import models, utils
from mollie.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import field_serializer, model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class Action(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The action performed on the unmatched credit transfer."""

    MATCH = "match"
    RETURN = "return"


class UnmatchedCreditTransferActionResponseStatus(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The current status of the action."""

    PENDING = "pending"


class UnmatchedCreditTransferActionResponseDetailsTypedDict(TypedDict):
    r"""Additional details about the action."""

    payment_ids: NotRequired[List[str]]
    r"""The IDs of the payments matched to the unmatched credit transfer."""


class UnmatchedCreditTransferActionResponseDetails(BaseModel):
    r"""Additional details about the action."""

    payment_ids: Annotated[Optional[List[str]], pydantic.Field(alias="paymentIds")] = (
        None
    )
    r"""The IDs of the payments matched to the unmatched credit transfer."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["paymentIds"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UnmatchedCreditTransferActionResponseSelfTypedDict(TypedDict):
    r"""The URL to this action."""

    href: NotRequired[str]
    type: NotRequired[str]


class UnmatchedCreditTransferActionResponseSelf(BaseModel):
    r"""The URL to this action."""

    href: Optional[str] = None

    type: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["href", "type"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UnmatchedCreditTransferActionResponseDocumentationTypedDict(TypedDict):
    r"""The URL to the documentation of this endpoint."""

    href: NotRequired[str]
    type: NotRequired[str]


class UnmatchedCreditTransferActionResponseDocumentation(BaseModel):
    r"""The URL to the documentation of this endpoint."""

    href: Optional[str] = None

    type: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["href", "type"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UnmatchedCreditTransferActionResponseLinksTypedDict(TypedDict):
    r"""Links to related resources."""

    self_: NotRequired[UnmatchedCreditTransferActionResponseSelfTypedDict]
    r"""The URL to this action."""
    documentation: NotRequired[
        UnmatchedCreditTransferActionResponseDocumentationTypedDict
    ]
    r"""The URL to the documentation of this endpoint."""


class UnmatchedCreditTransferActionResponseLinks(BaseModel):
    r"""Links to related resources."""

    self_: Annotated[
        Optional[UnmatchedCreditTransferActionResponseSelf],
        pydantic.Field(alias="self"),
    ] = None
    r"""The URL to this action."""

    documentation: Optional[UnmatchedCreditTransferActionResponseDocumentation] = None
    r"""The URL to the documentation of this endpoint."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["self", "documentation"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UnmatchedCreditTransferActionResponseTypedDict(TypedDict):
    resource: str
    r"""The resource type of the object."""
    id: str
    r"""The identifier uniquely referring to this unmatched credit transfer action."""
    unmatched_credit_transfer_id: str
    r"""The identifier of the unmatched credit transfer this action belongs to."""
    action: Action
    r"""The action performed on the unmatched credit transfer."""
    status: UnmatchedCreditTransferActionResponseStatus
    r"""The current status of the action."""
    created_at: str
    r"""The entity's date and time of creation, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."""
    links: UnmatchedCreditTransferActionResponseLinksTypedDict
    r"""Links to related resources."""
    details: NotRequired[UnmatchedCreditTransferActionResponseDetailsTypedDict]
    r"""Additional details about the action."""


class UnmatchedCreditTransferActionResponse(BaseModel):
    resource: str
    r"""The resource type of the object."""

    id: str
    r"""The identifier uniquely referring to this unmatched credit transfer action."""

    unmatched_credit_transfer_id: Annotated[
        str, pydantic.Field(alias="unmatchedCreditTransferId")
    ]
    r"""The identifier of the unmatched credit transfer this action belongs to."""

    action: Action
    r"""The action performed on the unmatched credit transfer."""

    status: UnmatchedCreditTransferActionResponseStatus
    r"""The current status of the action."""

    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."""

    links: Annotated[
        UnmatchedCreditTransferActionResponseLinks, pydantic.Field(alias="_links")
    ]
    r"""Links to related resources."""

    details: Optional[UnmatchedCreditTransferActionResponseDetails] = None
    r"""Additional details about the action."""

    @field_serializer("action")
    def serialize_action(self, value):
        if isinstance(value, str):
            try:
                return models.Action(value)
            except ValueError:
                return value
        return value

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    UnmatchedCreditTransferActionResponseDetails.model_rebuild()
except NameError:
    pass
try:
    UnmatchedCreditTransferActionResponseLinks.model_rebuild()
except NameError:
    pass
try:
    UnmatchedCreditTransferActionResponse.model_rebuild()
except NameError:
    pass
