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

@dataclass
class TimeSheetsPatchRequestBody(Parsable):
    # The code that identifies the budget to which the timesheet belongs. Required if both ``trackingItemInstanceId`` and ``trackingItemInstanceNumber`` are omitted from this request. To find the budget code, call `GET budgets </en/docs/bim360/v1/reference/http/cost-budgets-GET/>`_ and inspect ``results.code`` in the response.
    budget_code: Optional[str] = None
    # The last date of the time period covered by the timesheet. This is also the date that the tracked ``inputQuantity`` and ``outputQuantity`` values are considered to have been reported.
    end_date: Optional[str] = None
    # The hours worked during the time period covered by the timesheet.
    input_quantity: Optional[float] = None
    # The quantity of material used during time period covered by the timesheet.
    output_quantity: Optional[float] = None
    # The first date of the time period covered by the timesheet.
    start_date: Optional[str] = None
    # The ID of the tracking item instance to which the timesheet will belong. Required if both ``trackingItemInstanceNumber`` and ``budgetCode`` are omitted from this request. To find the instance ID, call `GET performance-tracking-item-instances </en/docs/bim360/v1/reference/http/cost-performance-tracking-item-instances-GET/>`_ and inspect ``results.id`` in the response.
    tracking_item_instance_id: Optional[str] = None
    # The user-provided code that represents the tracking item instance to which the timesheet will belong. Required if both ``trackingItemInstanceId`` and ``budgetCode`` are omitted from this request. To find the instance number, call `GET performance-tracking-item-instances </en/docs/bim360/v1/reference/http/cost-performance-tracking-item-instances-GET/>`_ and inspect ``results.number`` in the response.
    tracking_item_instance_number: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> TimeSheetsPatchRequestBody:
        """
        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: TimeSheetsPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return TimeSheetsPatchRequestBody()
    
    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]] = {
            "budgetCode": lambda n : setattr(self, 'budget_code', n.get_str_value()),
            "endDate": lambda n : setattr(self, 'end_date', n.get_str_value()),
            "inputQuantity": lambda n : setattr(self, 'input_quantity', n.get_float_value()),
            "outputQuantity": lambda n : setattr(self, 'output_quantity', n.get_float_value()),
            "startDate": lambda n : setattr(self, 'start_date', n.get_str_value()),
            "trackingItemInstanceId": lambda n : setattr(self, 'tracking_item_instance_id', n.get_str_value()),
            "trackingItemInstanceNumber": lambda n : setattr(self, 'tracking_item_instance_number', 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_str_value("budgetCode", self.budget_code)
        writer.write_str_value("endDate", self.end_date)
        writer.write_float_value("inputQuantity", self.input_quantity)
        writer.write_float_value("outputQuantity", self.output_quantity)
        writer.write_str_value("startDate", self.start_date)
        writer.write_str_value("trackingItemInstanceId", self.tracking_item_instance_id)
        writer.write_str_value("trackingItemInstanceNumber", self.tracking_item_instance_number)
    

