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 .with_item_patch_request_body_manager_type import WithItemPatchRequestBody_managerType
    from .with_item_patch_request_body_priority import WithItemPatchRequestBody_priority
    from .with_item_patch_request_body_subcontractor_type import WithItemPatchRequestBody_subcontractorType
    from .with_item_patch_request_body_watchers import WithItemPatchRequestBody_watchers

@dataclass
class WithItemPatchRequestBody(Parsable):
    # A custom number to assign to the submittal item. Before updating an item, check what the custom numbering type is for the current project by calling `GET metadata </en/docs/acc/v1/reference/http/submittals-metadata-GET/>`_ to get the custom identifier sequence type.Submittals support two custom numbering types:- Global Numbering: The custom identifier only contains the sequential number.- Spec Section Numbering: When the project uses spec section numbering for custom numbering, ensure that only the sequential number part of the custom identifier is sent in the request, excluding the spec ID.To find the next available custom number in the sequence, call `GET items:next-custom-identifier </en/docs/acc/v1/reference/http/submittals-itemsnext-custom-identifier-GET/>`_.To verify whether the custom number has not been used and is in a supported format, call `POST items:validate-custom-identifier </en/docs/acc/v1/reference/http/submittals-itemsvalidate-custom-identifier-POST/>`_.For more information on custom numbering, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Custom_Numbering>`_.
    custom_identifier: Optional[str] = None
    # A description of the submittal item to add context about its purpose.
    description: Optional[str] = None
    # The duration (in days) from the approval of the submittal to the delivery of materials or products to the construction site.
    lead_time: Optional[int] = None
    # The Autodesk ID (``autodeskId``) or Group ID (``memberGroupId``) specifying the manager to assign to the submittal item. The manager could be a user, role, or a company. Note that the user must be defined as a manager in the project. You can verify this by calling `GET mappings </en/docs/acc/v1/reference/http/submittals-mappings-GET/>`_.To get the possible values for a manager, call `GET mappings </en/docs/acc/v1/reference/http/submittals-mappings-GET/>`_ and check the autodeskId. This returns a list of all the users, roles, and companies that are managers in the project. Call `GET projects/users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET>`_ to verify the actual name of the user. If a copmany is a manager, call `GET companies <en/docs/acc/v1/reference/http/projects-:project_id-companies-GET/>`_ to verify the actual name of the company. Note that we do not currently support verifying names of roles.
    manager: Optional[str] = None
    # The date by which the manager is expected to prepare the submittal item for review to the reviewer, in the following format: YYYY-MM-DD in UTC (ISO 8601). For example, ``2018-02-15``.
    manager_due_date: Optional[str] = None
    # The type of manager. This attribute is required when a manager is specified. To determine the type of manager, call `GET mappings </en/docs/acc/v1/reference/http/submittals-mappings-GET/>`_ and check the user type.Possible values: ``1`` (user), ``2`` (company), ``3`` (role).
    manager_type: Optional[WithItemPatchRequestBody_managerType] = None
    # The ID of the package associated with the submittal item. This attribute is optional and is used for workflows involving attachments.To retrieve package details, call `GET packages </en/docs/acc/v1/reference/http/submittals-packages-GET/>`_.
    package_id: Optional[UUID] = None
    # The priority level of the submittal item.Possible values:- ``Low``- ``Normal``- ``High``When the priority is not set, the default value is ``Normal``.
    priority: Optional[WithItemPatchRequestBody_priority] = None
    # The date when the manager closed and distributed the submittal item, formatted as YYYY-MM-DDTHH:mm:ss.SSSSSSZ (ISO 8601) in UTC. For example, ``2018-02-15T12:09:24.198466Z``.
    published_date: Optional[datetime.datetime] = None
    # The timestamp marking when the item transitioned from the ``rev`` state ``(Open - In Review)`` to the ``mgr-2`` state ``(close and distribute)``, formatted as YYYY-MM-DDTHH:mm:ss.SSSSSSZ (ISO 8601) in UTC. For example, ``2018-02-15T12:09:24.198466Z``.
    received_from_review: Optional[datetime.datetime] = None
    # The date and time when the submittal was received back from the subcontractor after review, formatted as YYYY-MM-DDTHH:mm:ss.SSSSSSZ (ISO 8601) in UTC. For example, ``2018-02-15T12:09:24.198466Z``.
    received_from_submitter: Optional[datetime.datetime] = None
    # The date by which approval for the submittal is required, in the following format: YYYY-MM-DD in UTC (ISO 8601). For example, ``2018-02-15``.
    required_approval_date: Optional[str] = None
    # The date the responsible contractor needs to submit the submittal to the submittal manager, in the following format: YYYY-MM-DD (ISO 8601) in UTC. For example, ``2018-02-15``.
    required_date: Optional[str] = None
    # The date when the materials are expected to arrive on the site, in the following format: YYYY-MM-DD (ISO 8601) in UTC. For example, ``2018-02-15``.
    required_on_job_date: Optional[str] = None
    # The date and time when the submittal item was transitioned to the ``rev`` state ``(Open - In review)``, formatted as YYYY-MM-DDTHH:mm:ss.SSSSSSZ (ISO 8601) in UTC. For example, ``2018-02-15T12:09:24.198466Z``.
    sent_to_review: Optional[datetime.datetime] = None
    # The date and time when the submittal was sent to the subcontrator for review, formatted as YYYY-MM-DDTHH:mm:ss.SSSSSSZ (ISO 8601) in UTC. For example, ``2018-02-15T12:09:24.198466Z``.
    sent_to_submitter: Optional[datetime.datetime] = None
    # The unique identifier (UUID) of the spec section to assign to the submittal item, which can be obtained by calling `GET specs </en/docs/acc/v1/reference/http/submittals-specs-GET/>`_.
    spec_id: Optional[UUID] = None
    # The Autodesk ID of the subcontractor to assign to the submittal item. When updating a submittal item as a manager in the UI, you will see ‘assign to responsible contractor’. The subcontractor can be a user (``autodeskId``), role (``memberGroupId``), or company (``memberGroupId``).For users, call `GET users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET>`_.For companies, call `GET companies <en/docs/acc/v1/reference/http/projects-:project_id-companies-GET/>`_.Note that we do not currently support finding details about roles for a project.
    subcontractor: Optional[str] = None
    # The type of subcontractor. This attribute is required when a subcontrator is specified.Possible values: ``1`` (user), ``2`` (company), ``3`` (role).
    subcontractor_type: Optional[WithItemPatchRequestBody_subcontractorType] = None
    # The date by which the subcontractor is expected to submit the submittal to the manager, formatted as YYYY-MM-DD in UTC (ISO 8601). For example, ``2018-02-15``.
    submitter_due_date: Optional[str] = None
    # Define the subsection details of the submittal item. For example, ``1.05-B``.
    subsection: Optional[str] = None
    # The title of the submittal item defined by the user when updating the submittal item.
    title: Optional[str] = None
    # The ID of the item type to assign to the submittal item. To retrieve the type ID, call `GET item-types </en/docs/acc/v1/reference/http/submittals-item-types-GET/>`_ or `GET item-types/:id </en/docs/acc/v1/reference/http/submittals-item-types-id-GET/>`_.
    type_id: Optional[UUID] = None
    # A list of project watchers, who can be individual users, roles, or companies.
    watchers: Optional[list[WithItemPatchRequestBody_watchers]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithItemPatchRequestBody:
        """
        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: WithItemPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithItemPatchRequestBody()
    
    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_item_patch_request_body_manager_type import WithItemPatchRequestBody_managerType
        from .with_item_patch_request_body_priority import WithItemPatchRequestBody_priority
        from .with_item_patch_request_body_subcontractor_type import WithItemPatchRequestBody_subcontractorType
        from .with_item_patch_request_body_watchers import WithItemPatchRequestBody_watchers

        from .with_item_patch_request_body_manager_type import WithItemPatchRequestBody_managerType
        from .with_item_patch_request_body_priority import WithItemPatchRequestBody_priority
        from .with_item_patch_request_body_subcontractor_type import WithItemPatchRequestBody_subcontractorType
        from .with_item_patch_request_body_watchers import WithItemPatchRequestBody_watchers

        fields: dict[str, Callable[[Any], None]] = {
            "customIdentifier": lambda n : setattr(self, 'custom_identifier', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "leadTime": lambda n : setattr(self, 'lead_time', n.get_int_value()),
            "manager": lambda n : setattr(self, 'manager', n.get_str_value()),
            "managerDueDate": lambda n : setattr(self, 'manager_due_date', n.get_str_value()),
            "managerType": lambda n : setattr(self, 'manager_type', n.get_enum_value(WithItemPatchRequestBody_managerType)),
            "packageId": lambda n : setattr(self, 'package_id', n.get_uuid_value()),
            "priority": lambda n : setattr(self, 'priority', n.get_enum_value(WithItemPatchRequestBody_priority)),
            "publishedDate": lambda n : setattr(self, 'published_date', n.get_datetime_value()),
            "receivedFromReview": lambda n : setattr(self, 'received_from_review', n.get_datetime_value()),
            "receivedFromSubmitter": lambda n : setattr(self, 'received_from_submitter', n.get_datetime_value()),
            "requiredApprovalDate": lambda n : setattr(self, 'required_approval_date', n.get_str_value()),
            "requiredDate": lambda n : setattr(self, 'required_date', n.get_str_value()),
            "requiredOnJobDate": lambda n : setattr(self, 'required_on_job_date', n.get_str_value()),
            "sentToReview": lambda n : setattr(self, 'sent_to_review', n.get_datetime_value()),
            "sentToSubmitter": lambda n : setattr(self, 'sent_to_submitter', n.get_datetime_value()),
            "specId": lambda n : setattr(self, 'spec_id', n.get_uuid_value()),
            "subcontractor": lambda n : setattr(self, 'subcontractor', n.get_str_value()),
            "subcontractorType": lambda n : setattr(self, 'subcontractor_type', n.get_enum_value(WithItemPatchRequestBody_subcontractorType)),
            "submitterDueDate": lambda n : setattr(self, 'submitter_due_date', n.get_str_value()),
            "subsection": lambda n : setattr(self, 'subsection', n.get_str_value()),
            "title": lambda n : setattr(self, 'title', n.get_str_value()),
            "typeId": lambda n : setattr(self, 'type_id', n.get_uuid_value()),
            "watchers": lambda n : setattr(self, 'watchers', n.get_collection_of_object_values(WithItemPatchRequestBody_watchers)),
        }
        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("customIdentifier", self.custom_identifier)
        writer.write_str_value("description", self.description)
        writer.write_int_value("leadTime", self.lead_time)
        writer.write_str_value("manager", self.manager)
        writer.write_str_value("managerDueDate", self.manager_due_date)
        writer.write_enum_value("managerType", self.manager_type)
        writer.write_uuid_value("packageId", self.package_id)
        writer.write_enum_value("priority", self.priority)
        writer.write_datetime_value("publishedDate", self.published_date)
        writer.write_datetime_value("receivedFromReview", self.received_from_review)
        writer.write_datetime_value("receivedFromSubmitter", self.received_from_submitter)
        writer.write_str_value("requiredApprovalDate", self.required_approval_date)
        writer.write_str_value("requiredDate", self.required_date)
        writer.write_str_value("requiredOnJobDate", self.required_on_job_date)
        writer.write_datetime_value("sentToReview", self.sent_to_review)
        writer.write_datetime_value("sentToSubmitter", self.sent_to_submitter)
        writer.write_uuid_value("specId", self.spec_id)
        writer.write_str_value("subcontractor", self.subcontractor)
        writer.write_enum_value("subcontractorType", self.subcontractor_type)
        writer.write_str_value("submitterDueDate", self.submitter_due_date)
        writer.write_str_value("subsection", self.subsection)
        writer.write_str_value("title", self.title)
        writer.write_uuid_value("typeId", self.type_id)
        writer.write_collection_of_object_values("watchers", self.watchers)
    

