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 .with_response_patch_response_response import WithResponsePatchResponse_response
    from .with_response_patch_response_response_attachments import WithResponsePatchResponse_responseAttachments
    from .with_response_patch_response_rfi import WithResponsePatchResponse_rfi

@dataclass
class WithResponsePatchResponse(Parsable):
    # The details of the response that was created or updated.
    response: Optional[WithResponsePatchResponse_response] = None
    # The list of attachment groups created as part of the response.
    response_attachments: Optional[list[WithResponsePatchResponse_responseAttachments]] = None
    # The details of the RFI to which the response was added.
    rfi: Optional[list[WithResponsePatchResponse_rfi]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithResponsePatchResponse:
        """
        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: WithResponsePatchResponse
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithResponsePatchResponse()
    
    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_response_patch_response_response import WithResponsePatchResponse_response
        from .with_response_patch_response_response_attachments import WithResponsePatchResponse_responseAttachments
        from .with_response_patch_response_rfi import WithResponsePatchResponse_rfi

        from .with_response_patch_response_response import WithResponsePatchResponse_response
        from .with_response_patch_response_response_attachments import WithResponsePatchResponse_responseAttachments
        from .with_response_patch_response_rfi import WithResponsePatchResponse_rfi

        fields: dict[str, Callable[[Any], None]] = {
            "response": lambda n : setattr(self, 'response', n.get_object_value(WithResponsePatchResponse_response)),
            "responseAttachments": lambda n : setattr(self, 'response_attachments', n.get_collection_of_object_values(WithResponsePatchResponse_responseAttachments)),
            "rfi": lambda n : setattr(self, 'rfi', n.get_collection_of_object_values(WithResponsePatchResponse_rfi)),
        }
        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("response", self.response)
        writer.write_collection_of_object_values("responseAttachments", self.response_attachments)
        writer.write_collection_of_object_values("rfi", self.rfi)
    

