# coding: utf-8

"""
    XingChen 开放接口定义

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

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

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

import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError

from typing_extensions import Annotated
from pydantic import Field, StrictInt, StrictStr

from typing import Optional

from xingchen.models import ResultDTOPollingImageDetailDTO
from xingchen.models.chat_history_query_dto import ChatHistoryQueryDTO
from xingchen.models.message_rating_request import MessageRatingRequest
from xingchen.models.result_dto_boolean import ResultDTOBoolean
from xingchen.models.result_dto_page_result_chat_message_dto import ResultDTOPageResultChatMessageDTO
from xingchen.models.sys_reminder_request import SysReminderRequest
from xingchen.models.custom.reset_history_request import ResetChatHistoryRequest

from xingchen.api_client import ApiClient
from xingchen.api_response import ApiResponse
from xingchen.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class ChatMessageApiSub:
    """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

    def version(self):
        return self.api_client.api_version()

    @validate_arguments
    def chat_histories(self, chat_history_query_dto: Annotated[ChatHistoryQueryDTO, Field(..., description="对话请求")],
                       **kwargs) -> ResultDTOPageResultChatMessageDTO:  # noqa: E501
        """对话历史  # noqa: E501

         当前用户与角色的对话历史查询： - where: 查询条件：必传  - characterId: 必传  - startTime：开始时间戳，选传  - endTime: 结束时间戳，选传  - sessionId: 会话ID，宣传 - 排序：必传，默认根据创建时间倒排 - pageSize: 分页大小，选传，默认10 - pageNumber: 分页页码，宣传，默认1   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.chat_histories(chat_history_query_dto, async_req=True)
        >>> result = thread.get()

        :param chat_history_query_dto: 对话请求 (required)
        :type chat_history_query_dto: ChatHistoryQueryDTO
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ResultDTOPageResultChatMessageDTO
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the chat_histories_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.chat_histories_with_http_info(chat_history_query_dto, **kwargs)  # noqa: E501

    @validate_arguments
    def chat_histories_with_http_info(self, chat_history_query_dto: Annotated[
        ChatHistoryQueryDTO, Field(..., description="对话请求")], **kwargs) -> ApiResponse:  # noqa: E501
        """对话历史  # noqa: E501

         当前用户与角色的对话历史查询： - where: 查询条件：必传  - characterId: 必传  - startTime：开始时间戳，选传  - endTime: 结束时间戳，选传  - sessionId: 会话ID，宣传 - 排序：必传，默认根据创建时间倒排 - pageSize: 分页大小，选传，默认10 - pageNumber: 分页页码，宣传，默认1   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.chat_histories_with_http_info(chat_history_query_dto, async_req=True)
        >>> result = thread.get()

        :param chat_history_query_dto: 对话请求 (required)
        :type chat_history_query_dto: ChatHistoryQueryDTO
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ResultDTOPageResultChatMessageDTO, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'chat_history_query_dto'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method chat_histories" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['chat_history_query_dto'] is not None:
            _body_params = _params['chat_history_query_dto']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
                                          self.api_client.select_header_content_type(
                                              ['application/json']))
        if _content_types_list:
            _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Authorization']  # noqa: E501

        _response_types_map = {
            '200': "ResultDTOPageResultChatMessageDTO",
        }

        return self.api_client.call_api(
            '/{0}/api/chat/message/histories'.format(self.version()), 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def rate_message(self, message_rating_request: Annotated[MessageRatingRequest, Field(..., description="对话请求")],
                     **kwargs) -> ResultDTOBoolean:  # noqa: E501
        """消息评分  # noqa: E501

         评分请求参数： - 消息ID：必传 - 评分：必传，整型，[0-5]   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.rate_message(message_rating_request, async_req=True)
        >>> result = thread.get()

        :param message_rating_request: 对话请求 (required)
        :type message_rating_request: MessageRatingRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ResultDTOBoolean
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the rate_message_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.rate_message_with_http_info(message_rating_request, **kwargs)  # noqa: E501

    @validate_arguments
    def rate_message_with_http_info(self, message_rating_request: Annotated[
        MessageRatingRequest, Field(..., description="对话请求")], **kwargs) -> ApiResponse:  # noqa: E501
        """消息评分  # noqa: E501

         评分请求参数： - 消息ID：必传 - 评分：必传，整型，[0-5]   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.rate_message_with_http_info(message_rating_request, async_req=True)
        >>> result = thread.get()

        :param message_rating_request: 对话请求 (required)
        :type message_rating_request: MessageRatingRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ResultDTOBoolean, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'message_rating_request'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method rate_message" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['message_rating_request'] is not None:
            _body_params = _params['message_rating_request']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
                                          self.api_client.select_header_content_type(
                                              ['application/json']))
        if _content_types_list:
            _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Authorization']  # noqa: E501

        _response_types_map = {
            '200': "ResultDTOBoolean",
        }

        return self.api_client.call_api(
            '/{0}/api/chat/rating'.format(self.version()), 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def sys_reminder(self, sys_reminder_request: Annotated[SysReminderRequest, Field(..., description="对话请求")],
                     **kwargs) -> ResultDTOBoolean:  # noqa: E501
        """sys_reminder  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.sys_reminder(sys_reminder_request, async_req=True)
        >>> result = thread.get()

        :param sys_reminder_request: 对话请求 (required)
        :type sys_reminder_request: SysReminderRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ResultDTOBoolean
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the sys_reminder_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.sys_reminder_with_http_info(sys_reminder_request, **kwargs)  # noqa: E501

    @validate_arguments
    def sys_reminder_with_http_info(self, sys_reminder_request: Annotated[
        SysReminderRequest, Field(..., description="对话请求")], **kwargs) -> ApiResponse:  # noqa: E501
        """sys_reminder  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.sys_reminder_with_http_info(sys_reminder_request, async_req=True)
        >>> result = thread.get()

        :param sys_reminder_request: 对话请求 (required)
        :type sys_reminder_request: SysReminderRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ResultDTOBoolean, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'sys_reminder_request'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method sys_reminder" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['sys_reminder_request'] is not None:
            _body_params = _params['sys_reminder_request']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
                                          self.api_client.select_header_content_type(
                                              ['application/json']))
        if _content_types_list:
            _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Authorization']  # noqa: E501

        _response_types_map = {
            '200': "ResultDTOBoolean",
        }

        return self.api_client.call_api(
            '/{0}/api/chat/reminder'.format(self.version()), 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def reset_chat_history(self, request: Annotated[
        ResetChatHistoryRequest, Field(..., description="重置对话")], **kwargs) -> ApiResponse:

        kwargs['_return_http_data_only'] = True

        if '_preload_content' in kwargs:
            message = "Error! Please call the sys_reminder_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)

        path = '/{0}/api/chat/reset'.format(self.version())
        request_body = request
        success_response_type = 'ResultDTOBoolean'

        return self.request_with_http_info(path, request_body, success_response_type, **kwargs)

    def request_with_http_info(self, path: str, request_body: any, success_response_type: str, **kwargs) -> ApiResponse:  # noqa: E501

        _params = locals()

        _all_params = [
            'request_body'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method sys_reminder" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['request_body'] is not None:
            _body_params = _params['request_body']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
                                          self.api_client.select_header_content_type(
                                              ['application/json']))
        if _content_types_list:
            _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Authorization']  # noqa: E501

        _response_types_map = {
            '200': success_response_type,
        }

        return self.api_client.call_api(
            path,
            'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def polling_image_detail(self, message_id: Annotated[StrictStr, Field(..., description="消息ID")],
                          user_id: Annotated[StrictInt, Field(..., description="用户ID")],
                          **kwargs) -> ResultDTOPollingImageDetailDTO:  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the character_details_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.polling_image_detail_with_http_info(message_id, user_id, **kwargs)  # noqa: E501

    @validate_arguments
    def polling_image_detail_with_http_info(self, message_id: Annotated[StrictStr, Field(..., description="角色ID")],
                                         user_id: Annotated[StrictInt, Field(..., description="用户ID")],
                                         **kwargs) -> ApiResponse:  # noqa: E501
        _params = locals()

        _all_params = [
            'message_id',
            'user_id'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method polling_image_detail" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('message_id') is not None:  # noqa: E501
            _query_params.append(('messageId', _params['message_id']))

        if _params.get('user_id') is not None:  # noqa: E501
            _query_params.append(('userId', _params['user_id']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['*/*'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Authorization']  # noqa: E501

        _response_types_map = {
            '200': "ResultDTOPollingImageDetailDTO",
        }

        return self.api_client.call_api(
            '/{api_version}/api/chat/polling/image'.format(api_version=self.api_client.configuration.api_version), 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
