"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from factify.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class DocumentPermissionSetTypedDict(TypedDict):
    r"""DocumentPermissionSet contains the permissions the authenticated user has on a document."""

    attach_policy: NotRequired[bool]
    comment_private: NotRequired[bool]
    comment_public: NotRequired[bool]
    copy_content: NotRequired[bool]
    create_version: NotRequired[bool]
    export: NotRequired[bool]
    grant_access: NotRequired[bool]
    list_versions: NotRequired[bool]
    manage_access: NotRequired[bool]
    open: NotRequired[bool]
    screenshot: NotRequired[bool]
    trash: NotRequired[bool]
    view: NotRequired[bool]
    view_analytics: NotRequired[bool]
    view_leads: NotRequired[bool]
    view_timeline: NotRequired[bool]


class DocumentPermissionSet(BaseModel):
    r"""DocumentPermissionSet contains the permissions the authenticated user has on a document."""

    attach_policy: Optional[bool] = None

    comment_private: Optional[bool] = None

    comment_public: Optional[bool] = None

    copy_content: Optional[bool] = None

    create_version: Optional[bool] = None

    export: Optional[bool] = None

    grant_access: Optional[bool] = None

    list_versions: Optional[bool] = None

    manage_access: Optional[bool] = None

    open: Optional[bool] = None

    screenshot: Optional[bool] = None

    trash: Optional[bool] = None

    view: Optional[bool] = None

    view_analytics: Optional[bool] = None

    view_leads: Optional[bool] = None

    view_timeline: Optional[bool] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "attach_policy",
                "comment_private",
                "comment_public",
                "copy_content",
                "create_version",
                "export",
                "grant_access",
                "list_versions",
                "manage_access",
                "open",
                "screenshot",
                "trash",
                "view",
                "view_analytics",
                "view_leads",
                "view_timeline",
            ]
        )
        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
