# 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


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist
from xingchen.models.chat_history_query_where import ChatHistoryQueryWhere
from xingchen.models.gateway_issued_params import GatewayIssuedParams

class ChatHistoryQueryDTO(BaseModel):
    """
    聊天历史查询对象  # noqa: E501
    """
    where: Optional[ChatHistoryQueryWhere] = None
    order_by: Optional[conlist(StrictStr)] = Field(None, alias="orderBy", description="排序条件，支持的排序字段为： - gmtCreate 排序优先级按列表顺序，默认降序，如果期望升序，需要在字段后指定，如：orderBy: [\\\"gmtCreate desc\\\"] （gmtCreate 按降序） ")
    page_num: Optional[StrictInt] = Field(None, alias="pageNum", description="页码，默认为 0")
    page_size: Optional[StrictInt] = Field(None, alias="pageSize", description="页条目数，1～50，默认为 10")
    __properties = ["where", "orderBy", "pageNum", "pageSize"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> ChatHistoryQueryDTO:
        """Create an instance of ChatHistoryQueryDTO from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of where
        if self.where:
            _dict['where'] = self.where.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ChatHistoryQueryDTO:
        """Create an instance of ChatHistoryQueryDTO from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return ChatHistoryQueryDTO.parse_obj(obj)

        _obj = ChatHistoryQueryDTO.parse_obj({
            "where": ChatHistoryQueryWhere.from_dict(obj.get("where")) if obj.get("where") is not None else None,
            "order_by": obj.get("orderBy"),
            "page_num": obj.get("pageNum"),
            "page_size": obj.get("pageSize")
        })
        return _obj


