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
from uuid import UUID

if TYPE_CHECKING:
    from .items_post_request_body_manager_type import ItemsPostRequestBody_managerType
    from .items_post_request_body_priority import ItemsPostRequestBody_priority
    from .items_post_request_body_state_id import ItemsPostRequestBody_stateId
    from .items_post_request_body_subcontractor_type import ItemsPostRequestBody_subcontractorType
    from .items_post_request_body_watchers import ItemsPostRequestBody_watchers

@dataclass
class ItemsPostRequestBody(Parsable):
    # A custom number to assign to the submittal item. Before creating 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 company 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``. This corresponds to the ``mgr-1`` state ``Open (Submitted)``.
    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[ItemsPostRequestBody_managerType] = None
    # The ID of the package associated with the submittal item.To retrieve a list of packages and their corresponding IDs, 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[ItemsPostRequestBody_priority] = 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 UUID of the spec section to assign to the submittal item.
    spec_id: Optional[UUID] = None
    # The initial state of the submittal item, which depends on the role and permitted actions of the user.Possible values: ``draft``, ``sbc-1``, ``mgr-1``.The required fields depend on the selected state ID. For example, if the state is ``mgr-1``, required fields include subcontractor (``subcontractor``), subcontractor type (``subcontractorType``), and submitter due date (``submitterDueDate``). If the state is ``sbc-1``, required fields include manager (``manager``) and manager type (``manager-type``).The required fields for creating the submittal item depend on the input stateId. The different states will require different mandatory fields. Refer Step 1: Verify User Permissions in the `Create a Submittal Item </en/docs/acc/v1/tutorials/submittals/create-submittal-item/>`_ tutorial for details.
    state_id: Optional[ItemsPostRequestBody_stateId] = None
    # The Autodesk ID of the subcontractor to assign to the submittal item. When creating a submittal item as a manager in the UI, you will see ‘assign to responsible contractor’.Get the subcontractor ID using:- `GET projects/users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET>`_ to verify the actual name of the user in case the typs is a ``user`` (1).- `GET companies </en/docs/acc/v1/reference/http/projects-:project_id-companies-GET/>`_ to determine the name of the company in case the typs is a ``company`` (2).Note that we do not currently support verifying names of roles.
    subcontractor: Optional[str] = None
    # The type of subcontractor. This attribute is required when a subcontractor is specified.Possible values: ``1`` (user), ``2`` (company), ``3`` (role).
    subcontractor_type: Optional[ItemsPostRequestBody_subcontractorType] = None
    # The date by which the subcontractor is expected to submit the submittal to the manager, in the following format: YYYY-MM-DD in UTC (ISO 8601). For example, ``2018-02-15``. This corresponds to the ``sbc-1`` state ``Waiting for submission``.
    submitter_due_date: Optional[str] = None
    # Define the subsection details of the submittal item. For example, ``1.05-B``.
    subsection: Optional[str] = None
    # The ID of a review template used to apply predefined steps and tasks when creating a submittal item. Templates must be created in the UI or retrieved by calling `GET templates </en/docs/acc/v1/reference/http/submittals-templates-GET/>`_.
    template_id: Optional[UUID] = None
    # The title of the submittal item defined by the user when creating the submittal item.
    title: Optional[str] = None
    # The UUID of the item type to assign to the submittal item, which can be obtained by calling `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[str] = None
    # A list of project watchers, who can be individual users, roles, or companies.
    watchers: Optional[list[ItemsPostRequestBody_watchers]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ItemsPostRequestBody:
        """
        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: ItemsPostRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ItemsPostRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .items_post_request_body_manager_type import ItemsPostRequestBody_managerType
        from .items_post_request_body_priority import ItemsPostRequestBody_priority
        from .items_post_request_body_state_id import ItemsPostRequestBody_stateId
        from .items_post_request_body_subcontractor_type import ItemsPostRequestBody_subcontractorType
        from .items_post_request_body_watchers import ItemsPostRequestBody_watchers

        from .items_post_request_body_manager_type import ItemsPostRequestBody_managerType
        from .items_post_request_body_priority import ItemsPostRequestBody_priority
        from .items_post_request_body_state_id import ItemsPostRequestBody_stateId
        from .items_post_request_body_subcontractor_type import ItemsPostRequestBody_subcontractorType
        from .items_post_request_body_watchers import ItemsPostRequestBody_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(ItemsPostRequestBody_managerType)),
            "packageId": lambda n : setattr(self, 'package_id', n.get_uuid_value()),
            "priority": lambda n : setattr(self, 'priority', n.get_enum_value(ItemsPostRequestBody_priority)),
            "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()),
            "specId": lambda n : setattr(self, 'spec_id', n.get_uuid_value()),
            "stateId": lambda n : setattr(self, 'state_id', n.get_enum_value(ItemsPostRequestBody_stateId)),
            "subcontractor": lambda n : setattr(self, 'subcontractor', n.get_str_value()),
            "subcontractorType": lambda n : setattr(self, 'subcontractor_type', n.get_enum_value(ItemsPostRequestBody_subcontractorType)),
            "submitterDueDate": lambda n : setattr(self, 'submitter_due_date', n.get_str_value()),
            "subsection": lambda n : setattr(self, 'subsection', n.get_str_value()),
            "templateId": lambda n : setattr(self, 'template_id', n.get_uuid_value()),
            "title": lambda n : setattr(self, 'title', n.get_str_value()),
            "typeId": lambda n : setattr(self, 'type_id', n.get_str_value()),
            "watchers": lambda n : setattr(self, 'watchers', n.get_collection_of_object_values(ItemsPostRequestBody_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_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_uuid_value("specId", self.spec_id)
        writer.write_enum_value("stateId", self.state_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_uuid_value("templateId", self.template_id)
        writer.write_str_value("title", self.title)
        writer.write_str_value("typeId", self.type_id)
        writer.write_collection_of_object_values("watchers", self.watchers)
    

