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

if TYPE_CHECKING:
    from .takeoff_items_get_response_results_content_view import TakeoffItemsGetResponse_results_contentView
    from .takeoff_items_get_response_results_primary_quantity import TakeoffItemsGetResponse_results_primaryQuantity
    from .takeoff_items_get_response_results_property_values import TakeoffItemsGetResponse_results_propertyValues
    from .takeoff_items_get_response_results_secondary_quantities import TakeoffItemsGetResponse_results_secondaryQuantities
    from .takeoff_items_get_response_results_type import TakeoffItemsGetResponse_results_type

@dataclass
class TakeoffItemsGetResponse_results(Parsable):
    # The content view reference that this item is associated with.
    content_view: Optional[TakeoffItemsGetResponse_results_contentView] = None
    # The date and time when the resource was created, in the following format: ``YYYY-MM-DDThh:mm:ssZ``.
    created_at: Optional[datetime.datetime] = None
    # The geometry of a 2D takeoff item specified in SVG. This property is not returned for a 3D takeoff item.
    geometry: Optional[str] = None
    # The takeoff item ID.
    id: Optional[UUID] = None
    # The location ID associated with the takeoff item.For more information about the location, see `GET nodes </en/docs/acc/v1/reference/http/locations-nodes-GET/>`_.
    location_id: Optional[UUID] = None
    # The ID of the selected BIM model element in the viewing model.
    object_id: Optional[int] = None
    # The name of the takeoff type that the item is derived from.
    object_name: Optional[str] = None
    # The quantity of a takeoff.
    primary_quantity: Optional[TakeoffItemsGetResponse_results_primaryQuantity] = None
    # A list of takeoff item properties used to calculate quantity.
    property_values: Optional[list[TakeoffItemsGetResponse_results_propertyValues]] = None
    # A list of secondary takeoff quantities.
    secondary_quantities: Optional[list[TakeoffItemsGetResponse_results_secondaryQuantities]] = None
    # The takeoff type ID.
    takeoff_type_id: Optional[UUID] = None
    # The takeoff type method.Possible values: ``COUNT``, ``DISTANCE``, ``AREA``, ``SELECT``.Corresponding UI names: ``COUNT``, ``LINEAR``, ``AREA``, ``BIM``.
    type: Optional[TakeoffItemsGetResponse_results_type] = None
    # The date and time when the resource was last updated, in the following format: ``YYYY-MM-DDThh:mm:ssZ``.
    updated_at: Optional[datetime.datetime] = None
    # The name of the user who last updated the resource.
    updated_by_name: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> TakeoffItemsGetResponse_results:
        """
        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: TakeoffItemsGetResponse_results
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return TakeoffItemsGetResponse_results()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .takeoff_items_get_response_results_content_view import TakeoffItemsGetResponse_results_contentView
        from .takeoff_items_get_response_results_primary_quantity import TakeoffItemsGetResponse_results_primaryQuantity
        from .takeoff_items_get_response_results_property_values import TakeoffItemsGetResponse_results_propertyValues
        from .takeoff_items_get_response_results_secondary_quantities import TakeoffItemsGetResponse_results_secondaryQuantities
        from .takeoff_items_get_response_results_type import TakeoffItemsGetResponse_results_type

        from .takeoff_items_get_response_results_content_view import TakeoffItemsGetResponse_results_contentView
        from .takeoff_items_get_response_results_primary_quantity import TakeoffItemsGetResponse_results_primaryQuantity
        from .takeoff_items_get_response_results_property_values import TakeoffItemsGetResponse_results_propertyValues
        from .takeoff_items_get_response_results_secondary_quantities import TakeoffItemsGetResponse_results_secondaryQuantities
        from .takeoff_items_get_response_results_type import TakeoffItemsGetResponse_results_type

        fields: dict[str, Callable[[Any], None]] = {
            "contentView": lambda n : setattr(self, 'content_view', n.get_object_value(TakeoffItemsGetResponse_results_contentView)),
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "geometry": lambda n : setattr(self, 'geometry', n.get_str_value()),
            "id": lambda n : setattr(self, 'id', n.get_uuid_value()),
            "locationId": lambda n : setattr(self, 'location_id', n.get_uuid_value()),
            "objectId": lambda n : setattr(self, 'object_id', n.get_int_value()),
            "objectName": lambda n : setattr(self, 'object_name', n.get_str_value()),
            "primaryQuantity": lambda n : setattr(self, 'primary_quantity', n.get_object_value(TakeoffItemsGetResponse_results_primaryQuantity)),
            "propertyValues": lambda n : setattr(self, 'property_values', n.get_collection_of_object_values(TakeoffItemsGetResponse_results_propertyValues)),
            "secondaryQuantities": lambda n : setattr(self, 'secondary_quantities', n.get_collection_of_object_values(TakeoffItemsGetResponse_results_secondaryQuantities)),
            "takeoffTypeId": lambda n : setattr(self, 'takeoff_type_id', n.get_uuid_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(TakeoffItemsGetResponse_results_type)),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "updatedByName": lambda n : setattr(self, 'updated_by_name', 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_object_value("contentView", self.content_view)
        writer.write_datetime_value("createdAt", self.created_at)
        writer.write_str_value("geometry", self.geometry)
        writer.write_uuid_value("id", self.id)
        writer.write_uuid_value("locationId", self.location_id)
        writer.write_int_value("objectId", self.object_id)
        writer.write_str_value("objectName", self.object_name)
        writer.write_object_value("primaryQuantity", self.primary_quantity)
        writer.write_collection_of_object_values("propertyValues", self.property_values)
        writer.write_collection_of_object_values("secondaryQuantities", self.secondary_quantities)
        writer.write_uuid_value("takeoffTypeId", self.takeoff_type_id)
        writer.write_enum_value("type", self.type)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_str_value("updatedByName", self.updated_by_name)
    

