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 .actions_post_response_errors import ActionsPostResponse_errors

@dataclass
class ActionsPostResponse(Parsable):
    # The name of the action performed on the specified item. For example, budgetOpen on a PCO.Max length: 255
    action: Optional[str] = None
    # The object ID of the item on which the action was performed - a change order (PCO, RCO, OCO, RFQ or SCO) for example.
    association_id: Optional[str] = None
    # The type of the item on which the action was performed. Possible values: ``FormInstance``, ``OCO``, ``PCO``, ``RCO``, ``RFQ``, ``SCO``, ``Expense``, ``Contract``, ``CostPayment``, ``BudgetPayment``, ``BudgetTransfer``, ``MainContract``.
    association_type: Optional[str] = None
    # An array of errors that occurred during action execution.
    errors: Optional[list[ActionsPostResponse_errors]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ActionsPostResponse:
        """
        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: ActionsPostResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ActionsPostResponse()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .actions_post_response_errors import ActionsPostResponse_errors

        from .actions_post_response_errors import ActionsPostResponse_errors

        fields: dict[str, Callable[[Any], None]] = {
            "action": lambda n : setattr(self, 'action', n.get_str_value()),
            "associationId": lambda n : setattr(self, 'association_id', n.get_str_value()),
            "associationType": lambda n : setattr(self, 'association_type', n.get_str_value()),
            "errors": lambda n : setattr(self, 'errors', n.get_collection_of_object_values(ActionsPostResponse_errors)),
        }
        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("action", self.action)
        writer.write_str_value("associationId", self.association_id)
        writer.write_str_value("associationType", self.association_type)
        writer.write_collection_of_object_values("errors", self.errors)
    

