from __future__ import annotations
import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
    from .form_templates_get_response_data_forms import FormTemplatesGetResponse_data_forms

@dataclass
class FormTemplatesGetResponse_data(Parsable):
    # The unique identifier of the user who created the template.
    created_by: Optional[str] = None
    # Reference to fetch forms created from this template.
    forms: Optional[FormTemplatesGetResponse_data_forms] = None
    # Permissions on this template assigned to companies and roles.
    group_permissions: Optional[list[str]] = None
    # The unique identifier of the template.
    id: Optional[str] = None
    # A flag that indicates whether the template has a PDF or not.
    is_pdf: Optional[bool] = None
    # Display name of template.
    name: Optional[str] = None
    # For PDF forms, the URL to download the form's PDF.
    pdf_url: Optional[str] = None
    # Unique indentifier of the project the template belongs to.
    project_id: Optional[str] = None
    # Status of template: ````active````, ````inactive```` (archived), or ````deleted````
    status: Optional[str] = None
    # User supplied type of template
    template_type: Optional[str] = None
    # When the template was last updated, UTC date and time in ISO-8601 format.
    updated_at: Optional[datetime.datetime] = None
    # Permissions on this template assigned to individual users.
    user_permissions: Optional[list[str]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> FormTemplatesGetResponse_data:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: FormTemplatesGetResponse_data
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return FormTemplatesGetResponse_data()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .form_templates_get_response_data_forms import FormTemplatesGetResponse_data_forms

        from .form_templates_get_response_data_forms import FormTemplatesGetResponse_data_forms

        fields: dict[str, Callable[[Any], None]] = {
            "createdBy": lambda n : setattr(self, 'created_by', n.get_str_value()),
            "forms": lambda n : setattr(self, 'forms', n.get_object_value(FormTemplatesGetResponse_data_forms)),
            "groupPermissions": lambda n : setattr(self, 'group_permissions', n.get_collection_of_primitive_values(str)),
            "id": lambda n : setattr(self, 'id', n.get_str_value()),
            "isPdf": lambda n : setattr(self, 'is_pdf', n.get_bool_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "pdfUrl": lambda n : setattr(self, 'pdf_url', n.get_str_value()),
            "projectId": lambda n : setattr(self, 'project_id', n.get_str_value()),
            "status": lambda n : setattr(self, 'status', n.get_str_value()),
            "templateType": lambda n : setattr(self, 'template_type', n.get_str_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "userPermissions": lambda n : setattr(self, 'user_permissions', n.get_collection_of_primitive_values(str)),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_str_value("createdBy", self.created_by)
        writer.write_object_value("forms", self.forms)
        writer.write_collection_of_primitive_values("groupPermissions", self.group_permissions)
        writer.write_str_value("id", self.id)
        writer.write_bool_value("isPdf", self.is_pdf)
        writer.write_str_value("name", self.name)
        writer.write_str_value("pdfUrl", self.pdf_url)
        writer.write_str_value("projectId", self.project_id)
        writer.write_str_value("status", self.status)
        writer.write_str_value("templateType", self.template_type)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_collection_of_primitive_values("userPermissions", self.user_permissions)
    

