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 .search_rfis_post_request_body_sort_field import SearchRfisPostRequestBody_sort_field
    from .search_rfis_post_request_body_sort_order import SearchRfisPostRequestBody_sort_order

@dataclass
class SearchRfisPostRequestBody_sort(Parsable):
    # The field to sort by.Possible values: ``createdAt``, ``status``, ``dueDate``, ``title``, ``location``, ``updatedAt``, ``closedAt``, ``costImpact``, ``scheduleImpact``, ``priority``, ``discipline``, ``category``, ``reference``, ``customIdentifier``, ``customAttribute``
    field: Optional[SearchRfisPostRequestBody_sort_field] = None
    # The sort order.Possible values: ``DESC``, ``ASC``
    order: Optional[SearchRfisPostRequestBody_sort_order] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> SearchRfisPostRequestBody_sort:
        """
        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: SearchRfisPostRequestBody_sort
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return SearchRfisPostRequestBody_sort()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .search_rfis_post_request_body_sort_field import SearchRfisPostRequestBody_sort_field
        from .search_rfis_post_request_body_sort_order import SearchRfisPostRequestBody_sort_order

        from .search_rfis_post_request_body_sort_field import SearchRfisPostRequestBody_sort_field
        from .search_rfis_post_request_body_sort_order import SearchRfisPostRequestBody_sort_order

        fields: dict[str, Callable[[Any], None]] = {
            "field": lambda n : setattr(self, 'field', n.get_enum_value(SearchRfisPostRequestBody_sort_field)),
            "order": lambda n : setattr(self, 'order', n.get_enum_value(SearchRfisPostRequestBody_sort_order)),
        }
        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_enum_value("field", self.field)
        writer.write_enum_value("order", self.order)
    

