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

from __future__ import annotations
from .url import URL, URLTypedDict
from mollie.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


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

    self_: 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 EntityPermissionLinks(BaseModel):
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""

    self_: Annotated[Optional[URL], pydantic.Field(alias="self")] = 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(["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 EntityPermissionTypedDict(TypedDict):
    resource: str
    r"""Indicates the response contains a permission object. Will always contain the string `permission` for this
    endpoint.
    """
    id: str
    r"""The identifier uniquely referring to this permission. Example: `payments.read`."""
    description: str
    r"""A short description of what kind of access the permission enables."""
    granted: bool
    r"""Whether this permission is granted to the app by the organization."""
    links: EntityPermissionLinksTypedDict
    r"""An object with several relevant URLs. Every URL object will contain an `href` and a `type` field."""


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

    id: str
    r"""The identifier uniquely referring to this permission. Example: `payments.read`."""

    description: str
    r"""A short description of what kind of access the permission enables."""

    granted: bool
    r"""Whether this permission is granted to the app by the organization."""

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


try:
    EntityPermissionLinks.model_rebuild()
except NameError:
    pass
try:
    EntityPermission.model_rebuild()
except NameError:
    pass
