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_filter import SearchRfisPostRequestBody_filter
    from .search_rfis_post_request_body_sort import SearchRfisPostRequestBody_sort

@dataclass
class SearchRfisPostRequestBody(Parsable):
    # Specify which attributes to include in the response.Use this to limit the response to only the fields you need.For example, ``fields=id, title``.
    fields: Optional[list[str]] = None
    # A set of optional filters to narrow the results. You can combine multiple filters.
    filter: Optional[list[SearchRfisPostRequestBody_filter]] = None
    # The number of RFIs to return. Default: ``10``. Maximum: ``200``.
    limit: Optional[int] = None
    # The number of items to skip before starting the result set. Default: ``0``.
    offset: Optional[int] = None
    # Searches for a string in the ``title``, ``question``, and ``officialResponse`` fields.
    search: Optional[str] = None
    # A list of sort rules to apply. Each item includes a ``field`` to sort by and the sort ``order``.
    sort: Optional[list[SearchRfisPostRequestBody_sort]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> SearchRfisPostRequestBody:
        """
        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
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return SearchRfisPostRequestBody()
    
    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_filter import SearchRfisPostRequestBody_filter
        from .search_rfis_post_request_body_sort import SearchRfisPostRequestBody_sort

        from .search_rfis_post_request_body_filter import SearchRfisPostRequestBody_filter
        from .search_rfis_post_request_body_sort import SearchRfisPostRequestBody_sort

        fields: dict[str, Callable[[Any], None]] = {
            "fields": lambda n : setattr(self, 'fields', n.get_collection_of_primitive_values(str)),
            "filter": lambda n : setattr(self, 'filter', n.get_collection_of_object_values(SearchRfisPostRequestBody_filter)),
            "limit": lambda n : setattr(self, 'limit', n.get_int_value()),
            "offset": lambda n : setattr(self, 'offset', n.get_int_value()),
            "search": lambda n : setattr(self, 'search', n.get_str_value()),
            "sort": lambda n : setattr(self, 'sort', n.get_collection_of_object_values(SearchRfisPostRequestBody_sort)),
        }
        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_collection_of_primitive_values("fields", self.fields)
        writer.write_collection_of_object_values("filter", self.filter)
        writer.write_int_value("limit", self.limit)
        writer.write_int_value("offset", self.offset)
        writer.write_str_value("search", self.search)
        writer.write_collection_of_object_values("sort", self.sort)
    

