# coding: utf-8

"""
    Slack Web API

    One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.

    The version of the OpenAPI document: 1.7.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictInt, StrictStr
from typing import Optional
from typing_extensions import Annotated
from slack_beta_ti.models.default_success_template import DefaultSuccessTemplate

from slack_beta_ti.api_client import ApiClient, RequestSerialized
from slack_beta_ti.api_response import ApiResponse
from slack_beta_ti.rest import RESTResponseType


class SearchApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def search_messages(
        self,
        token: Annotated[StrictStr, Field(description="Authentication token. Requires scope: `search:read`")],
        query: Annotated[StrictStr, Field(description="Search query.")],
        count: Annotated[Optional[StrictInt], Field(description="Pass the number of results you want per \"page\". Maximum of `100`.")] = None,
        highlight: Annotated[Optional[StrictBool], Field(description="Pass a value of `true` to enable query highlight markers (see below).")] = None,
        page: Optional[StrictInt] = None,
        sort: Annotated[Optional[StrictStr], Field(description="Return matches sorted by either `score` or `timestamp`.")] = None,
        sort_dir: Annotated[Optional[StrictStr], Field(description="Change sort direction to ascending (`asc`) or descending (`desc`).")] = None,
        request_timeout__: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        request_auth__: Optional[Dict[StrictStr, Any]] = None,
        content_type__: Optional[StrictStr] = None,
        headers__: Optional[Dict[StrictStr, Any]] = None,
        host__: Optional[StrictStr] = None,
    ) -> DefaultSuccessTemplate:
        """search_messages

        Searches for messages matching a query.

        :param token: Authentication token. Requires scope: `search:read` (required)
        :type token: str
        :param query: Search query. (required)
        :type query: str
        :param count: Pass the number of results you want per \"page\". Maximum of `100`.
        :type count: int
        :param highlight: Pass a value of `true` to enable query highlight markers (see below).
        :type highlight: bool
        :param page:
        :type page: int
        :param sort: Return matches sorted by either `score` or `timestamp`.
        :type sort: str
        :param sort_dir: Change sort direction to ascending (`asc`) or descending (`desc`).
        :type sort_dir: str
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_messages_serialize(
            token=token,
            query=query,
            count=count,
            highlight=highlight,
            page=page,
            sort=sort,
            sort_dir=sort_dir,
            request_auth__=request_auth__,
            content_type__=content_type__,
            headers__=headers__,
            host__=host__
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "DefaultSuccessTemplate",
        }
        response_data = self.api_client.call_api(
            *_param,
            request_timeout__=request_timeout__
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def search_messages_with_http_info(
        self,
        token: Annotated[StrictStr, Field(description="Authentication token. Requires scope: `search:read`")],
        query: Annotated[StrictStr, Field(description="Search query.")],
        count: Annotated[Optional[StrictInt], Field(description="Pass the number of results you want per \"page\". Maximum of `100`.")] = None,
        highlight: Annotated[Optional[StrictBool], Field(description="Pass a value of `true` to enable query highlight markers (see below).")] = None,
        page: Optional[StrictInt] = None,
        sort: Annotated[Optional[StrictStr], Field(description="Return matches sorted by either `score` or `timestamp`.")] = None,
        sort_dir: Annotated[Optional[StrictStr], Field(description="Change sort direction to ascending (`asc`) or descending (`desc`).")] = None,
        request_timeout__: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        request_auth__: Optional[Dict[StrictStr, Any]] = None,
        content_type__: Optional[StrictStr] = None,
        headers__: Optional[Dict[StrictStr, Any]] = None,
        host__: Optional[StrictStr] = None,
    ) -> ApiResponse[DefaultSuccessTemplate]:
        """search_messages

        Searches for messages matching a query.

        :param token: Authentication token. Requires scope: `search:read` (required)
        :type token: str
        :param query: Search query. (required)
        :type query: str
        :param count: Pass the number of results you want per \"page\". Maximum of `100`.
        :type count: int
        :param highlight: Pass a value of `true` to enable query highlight markers (see below).
        :type highlight: bool
        :param page:
        :type page: int
        :param sort: Return matches sorted by either `score` or `timestamp`.
        :type sort: str
        :param sort_dir: Change sort direction to ascending (`asc`) or descending (`desc`).
        :type sort_dir: str
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_messages_serialize(
            token=token,
            query=query,
            count=count,
            highlight=highlight,
            page=page,
            sort=sort,
            sort_dir=sort_dir,
            request_auth__=request_auth__,
            content_type__=content_type__,
            headers__=headers__,
            host__=host__
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "DefaultSuccessTemplate",
        }
        response_data = self.api_client.call_api(
            *_param,
            request_timeout__=request_timeout__
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def search_messages_without_preload_content(
        self,
        token: Annotated[StrictStr, Field(description="Authentication token. Requires scope: `search:read`")],
        query: Annotated[StrictStr, Field(description="Search query.")],
        count: Annotated[Optional[StrictInt], Field(description="Pass the number of results you want per \"page\". Maximum of `100`.")] = None,
        highlight: Annotated[Optional[StrictBool], Field(description="Pass a value of `true` to enable query highlight markers (see below).")] = None,
        page: Optional[StrictInt] = None,
        sort: Annotated[Optional[StrictStr], Field(description="Return matches sorted by either `score` or `timestamp`.")] = None,
        sort_dir: Annotated[Optional[StrictStr], Field(description="Change sort direction to ascending (`asc`) or descending (`desc`).")] = None,
        request_timeout__: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        request_auth__: Optional[Dict[StrictStr, Any]] = None,
        content_type__: Optional[StrictStr] = None,
        headers__: Optional[Dict[StrictStr, Any]] = None,
        host__: Optional[StrictStr] = None,
    ) -> RESTResponseType:
        """search_messages

        Searches for messages matching a query.

        :param token: Authentication token. Requires scope: `search:read` (required)
        :type token: str
        :param query: Search query. (required)
        :type query: str
        :param count: Pass the number of results you want per \"page\". Maximum of `100`.
        :type count: int
        :param highlight: Pass a value of `true` to enable query highlight markers (see below).
        :type highlight: bool
        :param page:
        :type page: int
        :param sort: Return matches sorted by either `score` or `timestamp`.
        :type sort: str
        :param sort_dir: Change sort direction to ascending (`asc`) or descending (`desc`).
        :type sort_dir: str
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._search_messages_serialize(
            token=token,
            query=query,
            count=count,
            highlight=highlight,
            page=page,
            sort=sort,
            sort_dir=sort_dir,
            request_auth__=request_auth__,
            content_type__=content_type__,
            headers__=headers__,
            host__=host__
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "DefaultSuccessTemplate",
        }
        response_data = self.api_client.call_api(
            *_param,
            request_timeout__=request_timeout__
        )
        return response_data.response


    def _search_messages_serialize(
        self,
        token,
        query,
        count,
        highlight,
        page,
        sort,
        sort_dir,
        request_auth__,
        content_type__,
        headers__,
        host__,
    ) -> RequestSerialized:


        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = headers__ or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if token is not None:
            
            _query_params.append(('token', token))
            
        if count is not None:
            
            _query_params.append(('count', count))
            
        if highlight is not None:
            
            _query_params.append(('highlight', highlight))
            
        if page is not None:
            
            _query_params.append(('page', page))
            
        if query is not None:
            
            _query_params.append(('query', query))
            
        if sort is not None:
            
            _query_params.append(('sort', sort))
            
        if sort_dir is not None:
            
            _query_params.append(('sort_dir', sort_dir))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'slackAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/search.messages',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            host__=host__,
            request_auth__=request_auth__
        )


