from __future__ import annotations
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 .resources_get_response_results_custom_attributes_type import ResourcesGetResponse_results_customAttributes_type

@dataclass
class ResourcesGetResponse_results_customAttributes(Parsable):
    # The unique identifier of the custom attribute.
    id: Optional[int] = None
    # The name of the custom attribute.
    name: Optional[str] = None
    # The data type of the custom attribute. Possible values:- ``string`` – Text field.- ``date`` – Date field.- ``array`` – Drop-down list.
    type: Optional[ResourcesGetResponse_results_customAttributes_type] = None
    # The value of the custom attribute.
    value: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ResourcesGetResponse_results_customAttributes:
        """
        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: ResourcesGetResponse_results_customAttributes
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ResourcesGetResponse_results_customAttributes()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .resources_get_response_results_custom_attributes_type import ResourcesGetResponse_results_customAttributes_type

        from .resources_get_response_results_custom_attributes_type import ResourcesGetResponse_results_customAttributes_type

        fields: dict[str, Callable[[Any], None]] = {
            "id": lambda n : setattr(self, 'id', n.get_int_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(ResourcesGetResponse_results_customAttributes_type)),
            "value": lambda n : setattr(self, 'value', n.get_str_value()),
        }
        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_int_value("id", self.id)
        writer.write_str_value("name", self.name)
        writer.write_enum_value("type", self.type)
        writer.write_str_value("value", self.value)
    

