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 .workflows_post_request_body_steps_candidates import WorkflowsPostRequestBody_steps_candidates
    from .workflows_post_request_body_steps_due_date_type import WorkflowsPostRequestBody_steps_dueDateType
    from .workflows_post_request_body_steps_group_review import WorkflowsPostRequestBody_steps_groupReview
    from .workflows_post_request_body_steps_type import WorkflowsPostRequestBody_steps_type

@dataclass
class WorkflowsPostRequestBody_steps(Parsable):
    # (Displayed in the UI when selecting Reviewers/Approvers for a step) Defines the users, roles, or companies to specify for this step of the approval workflow. At least one of the fields (``users``, ``roles``, or ``companies``) must be provided.
    candidates: Optional[WorkflowsPostRequestBody_steps_candidates] = None
    # Specifies how the due date is calculated for this step. It works together with duration.This field applies only to ``REVIEWER`` and ``APPROVER`` steps.Possible values:- ``CALENDAR_DAY`` (default): the due date includes all calendar days, including weekends and holidays.- ``WORKDAY``: the due date excludes weekends and project holidays.
    due_date_type: Optional[WorkflowsPostRequestBody_steps_dueDateType] = None
    # (``Time allowed`` in the UI) The number of days allocated to complete this step.This field applies only to ``REVIEWER`` and ``APPROVER`` steps. It is used to calculate the due date based on the selected ``dueDateType``.Valid range: ``1–99``.
    duration: Optional[int] = None
    # (``Reviewer Type`` in the UI) Defines whether multiple reviewers can participate in this step and how their responses are handled. It applies only to ``REVIEWER`` steps.
    group_review: Optional[WorkflowsPostRequestBody_steps_groupReview] = None
    # The name of the step, as defined in the workflow. It appears in the UI and is used in workflow configuration. Maximum length: 255 characters.Max length: 255
    name: Optional[str] = None
    # Indicates the step type in the workflow. Possible values:- ``INITIATOR``: the first step. It typically represents the person who launches the review.- ``REVIEWER``: an intermediate step. It allows one or more reviewers to evaluate the files.- ``APPROVER``: the final step. It represents the decision maker who approves or rejects the files.
    type: Optional[WorkflowsPostRequestBody_steps_type] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WorkflowsPostRequestBody_steps:
        """
        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: WorkflowsPostRequestBody_steps
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WorkflowsPostRequestBody_steps()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .workflows_post_request_body_steps_candidates import WorkflowsPostRequestBody_steps_candidates
        from .workflows_post_request_body_steps_due_date_type import WorkflowsPostRequestBody_steps_dueDateType
        from .workflows_post_request_body_steps_group_review import WorkflowsPostRequestBody_steps_groupReview
        from .workflows_post_request_body_steps_type import WorkflowsPostRequestBody_steps_type

        from .workflows_post_request_body_steps_candidates import WorkflowsPostRequestBody_steps_candidates
        from .workflows_post_request_body_steps_due_date_type import WorkflowsPostRequestBody_steps_dueDateType
        from .workflows_post_request_body_steps_group_review import WorkflowsPostRequestBody_steps_groupReview
        from .workflows_post_request_body_steps_type import WorkflowsPostRequestBody_steps_type

        fields: dict[str, Callable[[Any], None]] = {
            "candidates": lambda n : setattr(self, 'candidates', n.get_object_value(WorkflowsPostRequestBody_steps_candidates)),
            "dueDateType": lambda n : setattr(self, 'due_date_type', n.get_enum_value(WorkflowsPostRequestBody_steps_dueDateType)),
            "duration": lambda n : setattr(self, 'duration', n.get_int_value()),
            "groupReview": lambda n : setattr(self, 'group_review', n.get_object_value(WorkflowsPostRequestBody_steps_groupReview)),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', n.get_enum_value(WorkflowsPostRequestBody_steps_type)),
        }
        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_object_value("candidates", self.candidates)
        writer.write_enum_value("dueDateType", self.due_date_type)
        writer.write_int_value("duration", self.duration)
        writer.write_object_value("groupReview", self.group_review)
        writer.write_str_value("name", self.name)
        writer.write_enum_value("type", self.type)
    

