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

if TYPE_CHECKING:
    from .patch_request_body_additional_collaborators import PatchRequestBody_additionalCollaborators

@dataclass
class PatchRequestBody(Parsable):
    # The actual completion date of the main contract.
    actual_completion_date: Optional[str] = None
    # The additional collaborator company and contacts.
    additional_collaborators: Optional[list[PatchRequestBody_additionalCollaborators]] = None
    # The BIM360/ACC ID of the architecture firm.
    architect_company_id: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    architect_company_uid: Optional[str] = None
    # The BIM360/ACC ID of the primary contact at the architecture firm.
    architect_contact_id: Optional[str] = None
    # The closing date of the main contract.
    close_date: Optional[str] = None
    # The code of the main contract.Max length: 255
    code: Optional[str] = None
    # The completed work retention percentage of the main contract amount.
    completed_work_retention_percent: Optional[float] = None
    # The BIM360/ACC ID of the supplier's default contact.
    contact_id: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    contractor_company_uid: Optional[str] = None
    # Detailed description of a main contract.Max length: 2048
    description: Optional[str] = None
    # The execution date of the main contract.
    executed_date: Optional[str] = None
    # The identifier assigned to an item in its original external ERP system. Use this ID to track and look up data within the integrated system. Note that this value comes from the item's ID in the external system.Max length: 255
    external_id: Optional[str] = None
    # A message generated by the external ERP system that explains the sync status of the integration. For example, common values include ``success`` or ``fail`` to indicate the result of the integration operation.Max length: 255
    external_message: Optional[str] = None
    # The name of the external ERP system integrated with Cost Management. Use this name to identify and search for data within the integrated system.Max length: 255
    external_system: Optional[str] = None
    # The state of the item during the integration with the external ERP system (such as SignNow). An item can be a ``budget``, ``contract``, ``main contract``, ``main contract item``, ``cost item``, ``expense``, ``expense item``, ``change order``, or ``schedule of value``. For more details, see `Integrate with External System </en/docs/acc/v1/tutorials/cost/integrate-with-external-system/>`_ tutorial.Possible values:``locked``: the item is currently locked within the ERP system, preventing modifications until unlocked. To unlock and modify the item, use the relevant PATCH endpoint to set ``integrationState`` to ``null``. For example, for a budget, call `PATCH budgets <en/docs/bim360/v1/reference/http/cost-budgets-budgetId-PATCH/>`_. For a contract, call `PATCH contracts <en/docs/bim360/v1/reference/http/cost-contracts-contractId-PATCH/>`_. For more details, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Integrated_and_Locked>`_.``integrated``: the item has been successfully added to the ERP system.``failed``: the item encountered an error during the integration process and was not successfully added to the ERP system. For example, if a user tries to integrate ``contracts`` from an ERP system and the updates fail, the ``integrationState`` can be set to ``failed``. Retry the sync process or analyze the issue if it continues to fail.``null``: The item has not been integrated with the ERP system. This is default value.For more information regarding integrations within the Cost Management system, see `Integrations in Cost Management <https://help.autodesk.com/view/BUILD/ENU/?guid=Cost_Integrations>`_.
    integration_state: Optional[str] = None
    # ``true``: This is the default main contract.``false``: This is not the default main contract.
    is_default: Optional[bool] = None
    # The date and time when the item was last synchronized with the external ERP system. This value is updated by the external system and is in ISO 8601 format.
    last_sync_time: Optional[datetime.datetime] = None
    # The materials retention percentage of the main contract amount.
    materials_retention_percent: Optional[float] = None
    # The name of the main contract.Max length: 1024
    name: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    notary_company_uid: Optional[str] = None
    # A note about the main contract in `Tiptap <https://tiptap.dev/introduction/>`_-formatted rich text.
    note: Optional[str] = None
    # The BIM360/ACC ID of the owner company.
    owner_company_id: Optional[str] = None
    # The unique ID (UUID) of the company in this account. Detailed company information can be retrieved using this UUID by calling `GET companies/:company_id <en/docs/bim360/v1/reference/http/companies-:company_id-GET/>`_ in the response.
    owner_company_uid: Optional[str] = None
    # The BIM360/ACC ID of the primary contact at the owner company.
    owner_contact_id: Optional[str] = None
    # The planned completion date of the main contract.
    planned_completion_date: Optional[str] = None
    # Total retention percentage of the main contract amount.
    retention_cap: Optional[float] = None
    # The revised completion date of the main contract.
    revised_completion_date: Optional[str] = None
    # The scope of work signed by all parties to the main contract, in `Tiptap <https://tiptap.dev/introduction/>`_-formatted rich text.
    scope_of_work: Optional[str] = None
    # The start date of the main contract.
    start_date: Optional[str] = None
    # The status of the main contract. Possible values: ``closed``, ``executed``, ``review``, ``signed``.
    status: Optional[str] = None
    # The type of the main contract. For example, ``Fixed Price`` or ``Unit Price``. This is customizable for the project administrator.
    type: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> PatchRequestBody:
        """
        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: PatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return PatchRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .patch_request_body_additional_collaborators import PatchRequestBody_additionalCollaborators

        from .patch_request_body_additional_collaborators import PatchRequestBody_additionalCollaborators

        fields: dict[str, Callable[[Any], None]] = {
            "actualCompletionDate": lambda n : setattr(self, 'actual_completion_date', n.get_str_value()),
            "additionalCollaborators": lambda n : setattr(self, 'additional_collaborators', n.get_collection_of_object_values(PatchRequestBody_additionalCollaborators)),
            "architectCompanyId": lambda n : setattr(self, 'architect_company_id', n.get_str_value()),
            "architectCompanyUid": lambda n : setattr(self, 'architect_company_uid', n.get_str_value()),
            "architectContactId": lambda n : setattr(self, 'architect_contact_id', n.get_str_value()),
            "closeDate": lambda n : setattr(self, 'close_date', n.get_str_value()),
            "code": lambda n : setattr(self, 'code', n.get_str_value()),
            "completedWorkRetentionPercent": lambda n : setattr(self, 'completed_work_retention_percent', n.get_float_value()),
            "contactId": lambda n : setattr(self, 'contact_id', n.get_str_value()),
            "contractorCompanyUid": lambda n : setattr(self, 'contractor_company_uid', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "executedDate": lambda n : setattr(self, 'executed_date', n.get_str_value()),
            "externalId": lambda n : setattr(self, 'external_id', n.get_str_value()),
            "externalMessage": lambda n : setattr(self, 'external_message', n.get_str_value()),
            "externalSystem": lambda n : setattr(self, 'external_system', n.get_str_value()),
            "integrationState": lambda n : setattr(self, 'integration_state', n.get_str_value()),
            "isDefault": lambda n : setattr(self, 'is_default', n.get_bool_value()),
            "lastSyncTime": lambda n : setattr(self, 'last_sync_time', n.get_datetime_value()),
            "materialsRetentionPercent": lambda n : setattr(self, 'materials_retention_percent', n.get_float_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "notaryCompanyUid": lambda n : setattr(self, 'notary_company_uid', n.get_str_value()),
            "note": lambda n : setattr(self, 'note', n.get_str_value()),
            "ownerCompanyId": lambda n : setattr(self, 'owner_company_id', n.get_str_value()),
            "ownerCompanyUid": lambda n : setattr(self, 'owner_company_uid', n.get_str_value()),
            "ownerContactId": lambda n : setattr(self, 'owner_contact_id', n.get_str_value()),
            "plannedCompletionDate": lambda n : setattr(self, 'planned_completion_date', n.get_str_value()),
            "retentionCap": lambda n : setattr(self, 'retention_cap', n.get_float_value()),
            "revisedCompletionDate": lambda n : setattr(self, 'revised_completion_date', n.get_str_value()),
            "scopeOfWork": lambda n : setattr(self, 'scope_of_work', n.get_str_value()),
            "startDate": lambda n : setattr(self, 'start_date', n.get_str_value()),
            "status": lambda n : setattr(self, 'status', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', 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("actualCompletionDate", self.actual_completion_date)
        writer.write_collection_of_object_values("additionalCollaborators", self.additional_collaborators)
        writer.write_str_value("architectCompanyId", self.architect_company_id)
        writer.write_str_value("architectCompanyUid", self.architect_company_uid)
        writer.write_str_value("architectContactId", self.architect_contact_id)
        writer.write_str_value("closeDate", self.close_date)
        writer.write_str_value("code", self.code)
        writer.write_float_value("completedWorkRetentionPercent", self.completed_work_retention_percent)
        writer.write_str_value("contactId", self.contact_id)
        writer.write_str_value("contractorCompanyUid", self.contractor_company_uid)
        writer.write_str_value("description", self.description)
        writer.write_str_value("executedDate", self.executed_date)
        writer.write_str_value("externalId", self.external_id)
        writer.write_str_value("externalMessage", self.external_message)
        writer.write_str_value("externalSystem", self.external_system)
        writer.write_str_value("integrationState", self.integration_state)
        writer.write_bool_value("isDefault", self.is_default)
        writer.write_datetime_value("lastSyncTime", self.last_sync_time)
        writer.write_float_value("materialsRetentionPercent", self.materials_retention_percent)
        writer.write_str_value("name", self.name)
        writer.write_str_value("notaryCompanyUid", self.notary_company_uid)
        writer.write_str_value("note", self.note)
        writer.write_str_value("ownerCompanyId", self.owner_company_id)
        writer.write_str_value("ownerCompanyUid", self.owner_company_uid)
        writer.write_str_value("ownerContactId", self.owner_contact_id)
        writer.write_str_value("plannedCompletionDate", self.planned_completion_date)
        writer.write_float_value("retentionCap", self.retention_cap)
        writer.write_str_value("revisedCompletionDate", self.revised_completion_date)
        writer.write_str_value("scopeOfWork", self.scope_of_work)
        writer.write_str_value("startDate", self.start_date)
        writer.write_str_value("status", self.status)
        writer.write_str_value("type", self.type)
    

