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

from __future__ import annotations
from .entity_capability import EntityCapability, EntityCapabilityTypedDict
from .entity_onboarding_status import (
    EntityOnboardingStatus,
    EntityOnboardingStatusTypedDict,
)
from .entity_organization import EntityOrganization, EntityOrganizationTypedDict
from .url import URL, URLTypedDict
from mollie.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from mollie.utils import (
    FieldMetadata,
    HeaderMetadata,
    PathParamMetadata,
    QueryParamMetadata,
)
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetClientRequestTypedDict(TypedDict):
    organization_id: str
    r"""Provide the ID of the related organization."""
    embed: NotRequired[Nullable[str]]
    r"""This endpoint allows embedding related API items by appending the following values via the `embed` query string
    parameter.

    * `organization`: Include the organization of the client. Available for `signuplink` partners, or for `oauth`
    partners with the `organizations.read` scope.
    * `onboarding`: Include the onboarding status of the client. Available for `signuplink` partners, or for `oauth`
    partners with the `onboarding.read` scope.
    * `capabilities`: Include the [capabilities](list-capabilities) of the client organization.
    Available for *oauth* partners with the `onboarding.read` scope.
    """
    idempotency_key: NotRequired[str]
    r"""A unique key to ensure idempotent requests. This key should be a UUID v4 string."""


class GetClientRequest(BaseModel):
    organization_id: Annotated[
        str,
        pydantic.Field(alias="organizationId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Provide the ID of the related organization."""

    embed: Annotated[
        OptionalNullable[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""This endpoint allows embedding related API items by appending the following values via the `embed` query string
    parameter.

    * `organization`: Include the organization of the client. Available for `signuplink` partners, or for `oauth`
    partners with the `organizations.read` scope.
    * `onboarding`: Include the onboarding status of the client. Available for `signuplink` partners, or for `oauth`
    partners with the `onboarding.read` scope.
    * `capabilities`: Include the [capabilities](list-capabilities) of the client organization.
    Available for *oauth* partners with the `onboarding.read` scope.
    """

    idempotency_key: Annotated[
        Optional[str],
        pydantic.Field(alias="idempotency-key"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""A unique key to ensure idempotent requests. This key should be a UUID v4 string."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["embed", "idempotency-key"])
        nullable_fields = set(["embed"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class GetClientCommissionTypedDict(TypedDict):
    r"""The commission object."""

    count: NotRequired[int]
    r"""The commission count."""


class GetClientCommission(BaseModel):
    r"""The commission object."""

    count: Optional[int] = None
    r"""The commission count."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["count"])
        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 GetClientLinksTypedDict(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."""
    organization: NotRequired[URLTypedDict]
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""
    onboarding: NotRequired[URLTypedDict]
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""
    documentation: NotRequired[URLTypedDict]
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""


class GetClientLinks(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."""

    organization: Optional[URL] = None
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""

    onboarding: Optional[URL] = None
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""

    documentation: Optional[URL] = None
    r"""In v2 endpoints, URLs are commonly represented as objects with an `href` and `type` field."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["organization", "onboarding", "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 GetClientEmbeddedTypedDict(TypedDict):
    organization: NotRequired[EntityOrganizationTypedDict]
    onboarding: NotRequired[EntityOnboardingStatusTypedDict]
    capabilities: NotRequired[EntityCapabilityTypedDict]


class GetClientEmbedded(BaseModel):
    organization: Optional[EntityOrganization] = None

    onboarding: Optional[EntityOnboardingStatus] = None

    capabilities: Optional[EntityCapability] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["organization", "onboarding", "capabilities"])
        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 GetClientResponseTypedDict(TypedDict):
    r"""The client object."""

    resource: str
    r"""Indicates the response contains a client object. Will always contain the string `client` for this resource type."""
    id: str
    r"""The identifier uniquely referring to this client. Example: `org_12345678`."""
    links: GetClientLinksTypedDict
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""
    commission: NotRequired[Nullable[GetClientCommissionTypedDict]]
    r"""The commission object."""
    organization_created_at: NotRequired[str]
    r"""The date and time the client organization was created, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
    format.
    """
    embedded: NotRequired[GetClientEmbeddedTypedDict]


class GetClientResponse(BaseModel):
    r"""The client object."""

    resource: str
    r"""Indicates the response contains a client object. Will always contain the string `client` for this resource type."""

    id: str
    r"""The identifier uniquely referring to this client. Example: `org_12345678`."""

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

    commission: OptionalNullable[GetClientCommission] = UNSET
    r"""The commission object."""

    organization_created_at: Annotated[
        Optional[str], pydantic.Field(alias="organizationCreatedAt")
    ] = None
    r"""The date and time the client organization was created, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
    format.
    """

    embedded: Annotated[
        Optional[GetClientEmbedded], pydantic.Field(alias="_embedded")
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["commission", "organizationCreatedAt", "_embedded"])
        nullable_fields = set(["commission"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


try:
    GetClientLinks.model_rebuild()
except NameError:
    pass
try:
    GetClientResponse.model_rebuild()
except NameError:
    pass
