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
from uuid import UUID

@dataclass
class ValuesImportPostResponse(Parsable):
    # The display code.Max length: 255
    code: Optional[str] = None
    # The date and time that the item was created, in ISO 8601 format.
    created_at: Optional[datetime.datetime] = None
    # The description of the code.Max length: 2048
    description: Optional[str] = None
    # The ID of the code.
    id: Optional[UUID] = None
    # The original value of the code before the delimiters are removed.Max length: 255
    original_code: Optional[str] = None
    # The parent ID of this code if it is the sub item of another code.
    parent_id: Optional[str] = None
    # The ID of the segment this code belongs to.
    segment_id: Optional[UUID] = None
    # The date and time that the item was last updated, in ISO 8601 format.
    updated_at: Optional[datetime.datetime] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ValuesImportPostResponse:
        """
        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: ValuesImportPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ValuesImportPostResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "code": lambda n : setattr(self, 'code', n.get_str_value()),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "originalCode": lambda n : setattr(self, 'original_code', n.get_str_value()),
            "parentId": lambda n : setattr(self, 'parent_id', n.get_str_value()),
            "segmentId": lambda n : setattr(self, 'segment_id', n.get_uuid_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_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_str_value("code", self.code)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("description", self.description)
        writer.write_uuid_value("id", self.id)
        writer.write_str_value("originalCode", self.original_code)
        writer.write_str_value("parentId", self.parent_id)
        writer.write_uuid_value("segmentId", self.segment_id)
        writer.write_datetime_value("updatedAt", self.updated_at)
    

