# coding: utf-8

"""
    用户全部 API 文档

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

    The version of the OpenAPI document: v1
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class CurrencyTransaction(BaseModel):
    """
    货币交易记录实体，用于记录用户的货币交易详情。
    """ # noqa: E501
    id: Optional[StrictInt] = Field(default=None, description="货币交易记录的唯一标识符。")
    from_user_id: Optional[StrictInt] = Field(default=None, description="发起交易的发送方用户ID，若为转账交易时必填。", alias="fromUserID")
    user_id: Optional[StrictInt] = Field(default=None, description="进行货币交易的用户ID。", alias="userID")
    transaction_type: Optional[Annotated[str, Field(strict=True, max_length=50)]] = Field(default=None, description="货币交易的类型，例如 '消费', '奖励', '兑换', '转账' 等。", alias="transactionType")
    currency_type: Optional[Annotated[str, Field(strict=True, max_length=50)]] = Field(default=None, description="交易的货币类型，例如 'USD', 'CNY' 等。", alias="currencyType")
    currency_change: Optional[StrictInt] = Field(default=None, description="货币的变动数量，正数表示增加，负数表示减少。", alias="currencyChange")
    currency_balance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="交易完成后的货币余额。", alias="currencyBalance")
    description: Optional[StrictStr] = Field(default=None, description="描述货币变动的具体原因或相关交易详情。")
    status: Optional[Annotated[str, Field(strict=True, max_length=50)]] = Field(default=None, description="货币交易的当前状态，例如 '成功', '失败', '待审核' 等。")
    remark: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="交易的额外信息或管理员的备注。")
    tags: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="用于分类或标记交易的标签。")
    create_date: Optional[datetime] = Field(default=None, description="货币交易发生的时间，默认为当前时间。", alias="createDate")
    __properties: ClassVar[List[str]] = ["id", "fromUserID", "userID", "transactionType", "currencyType", "currencyChange", "currencyBalance", "description", "status", "remark", "tags", "createDate"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if transaction_type (nullable) is None
        # and model_fields_set contains the field
        if self.transaction_type is None and "transaction_type" in self.model_fields_set:
            _dict['transactionType'] = None

        # set to None if currency_type (nullable) is None
        # and model_fields_set contains the field
        if self.currency_type is None and "currency_type" in self.model_fields_set:
            _dict['currencyType'] = None

        # set to None if description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

        # set to None if status (nullable) is None
        # and model_fields_set contains the field
        if self.status is None and "status" in self.model_fields_set:
            _dict['status'] = None

        # set to None if remark (nullable) is None
        # and model_fields_set contains the field
        if self.remark is None and "remark" in self.model_fields_set:
            _dict['remark'] = None

        # set to None if tags (nullable) is None
        # and model_fields_set contains the field
        if self.tags is None and "tags" in self.model_fields_set:
            _dict['tags'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CurrencyTransaction from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "fromUserID": obj.get("fromUserID"),
            "userID": obj.get("userID"),
            "transactionType": obj.get("transactionType"),
            "currencyType": obj.get("currencyType"),
            "currencyChange": obj.get("currencyChange"),
            "currencyBalance": obj.get("currencyBalance"),
            "description": obj.get("description"),
            "status": obj.get("status"),
            "remark": obj.get("remark"),
            "tags": obj.get("tags"),
            "createDate": obj.get("createDate")
        })
        return _obj


