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 .content_views_get_response_results_view_sheet_view_calibration_units import ContentViewsGetResponse_results_view_SheetView_calibration_units

@dataclass
class ContentViewsGetResponse_results_view_SheetView_calibration(Parsable):
    """
    The sheet view calibration details.
    """
    # The scale used in the sheet view calibration.
    scale_factor: Optional[float] = None
    # The units used in the sheet view calibration.Possible values: ``FT_AND_DECIMAL_IN``, ``FT_AND_FRACTIONAL_IN``, ``M``, ``CM``, ``MM``.
    units: Optional[ContentViewsGetResponse_results_view_SheetView_calibration_units] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ContentViewsGetResponse_results_view_SheetView_calibration:
        """
        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: ContentViewsGetResponse_results_view_SheetView_calibration
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ContentViewsGetResponse_results_view_SheetView_calibration()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .content_views_get_response_results_view_sheet_view_calibration_units import ContentViewsGetResponse_results_view_SheetView_calibration_units

        from .content_views_get_response_results_view_sheet_view_calibration_units import ContentViewsGetResponse_results_view_SheetView_calibration_units

        fields: dict[str, Callable[[Any], None]] = {
            "scaleFactor": lambda n : setattr(self, 'scale_factor', n.get_float_value()),
            "units": lambda n : setattr(self, 'units', n.get_enum_value(ContentViewsGetResponse_results_view_SheetView_calibration_units)),
        }
        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_float_value("scaleFactor", self.scale_factor)
        writer.write_enum_value("units", self.units)
    

