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 .with_takeoff_type_get_response_primary_quantity_definition_unit_of_measure import WithTakeoffTypeGetResponse_primaryQuantityDefinition_unitOfMeasure

@dataclass
class WithTakeoffTypeGetResponse_primaryQuantityDefinition(Parsable):
    """
    The classification quantity details.
    """
    # The classification code selected from the first classification system.
    classification_code_one: Optional[str] = None
    # The classification code selected from the second classification system.
    classification_code_two: Optional[str] = None
    # The formula to calculate the quantity.
    expression: Optional[str] = None
    # A custom output name from the user.
    output_name: Optional[str] = None
    # The unit of measurement.Possible values: ``EA``, ``IN``, ``LF``, ``YD``, ``SI``, ``SF``, ``SY``, ``CI``, ``CF``, ``CY``, ``LBS``, ``TON``, ``MM``, ``M``, ``M2``, ``M3``, ``KG``, ``T``.
    unit_of_measure: Optional[WithTakeoffTypeGetResponse_primaryQuantityDefinition_unitOfMeasure] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithTakeoffTypeGetResponse_primaryQuantityDefinition:
        """
        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: WithTakeoffTypeGetResponse_primaryQuantityDefinition
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithTakeoffTypeGetResponse_primaryQuantityDefinition()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .with_takeoff_type_get_response_primary_quantity_definition_unit_of_measure import WithTakeoffTypeGetResponse_primaryQuantityDefinition_unitOfMeasure

        from .with_takeoff_type_get_response_primary_quantity_definition_unit_of_measure import WithTakeoffTypeGetResponse_primaryQuantityDefinition_unitOfMeasure

        fields: dict[str, Callable[[Any], None]] = {
            "classificationCodeOne": lambda n : setattr(self, 'classification_code_one', n.get_str_value()),
            "classificationCodeTwo": lambda n : setattr(self, 'classification_code_two', n.get_str_value()),
            "expression": lambda n : setattr(self, 'expression', n.get_str_value()),
            "outputName": lambda n : setattr(self, 'output_name', n.get_str_value()),
            "unitOfMeasure": lambda n : setattr(self, 'unit_of_measure', n.get_enum_value(WithTakeoffTypeGetResponse_primaryQuantityDefinition_unitOfMeasure)),
        }
        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("classificationCodeOne", self.classification_code_one)
        writer.write_str_value("classificationCodeTwo", self.classification_code_two)
        writer.write_str_value("expression", self.expression)
        writer.write_str_value("outputName", self.output_name)
        writer.write_enum_value("unitOfMeasure", self.unit_of_measure)
    

