# 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 pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ReturnPageNotifyRequest(BaseModel):
    """
    支付宝返回页面通知请求
    """ # noqa: E501
    app_id: Optional[StrictStr] = Field(default=None, description="应用ID")
    auth_app_id: Optional[StrictStr] = Field(default=None, description="授权应用ID")
    charset: Optional[StrictStr] = Field(default=None, description="字符集")
    method: Optional[StrictStr] = Field(default=None, description="接口名称")
    out_trade_no: Optional[StrictStr] = Field(default=None, description="商户订单号")
    seller_id: Optional[StrictStr] = Field(default=None, description="卖家支付宝用户号")
    sign: Optional[StrictStr] = Field(default=None, description="签名")
    sign_type: Optional[StrictStr] = Field(default=None, description="签名类型")
    timestamp: Optional[StrictStr] = Field(default=None, description="时间戳")
    total_amount: Optional[StrictStr] = Field(default=None, description="订单总金额")
    trade_no: Optional[StrictStr] = Field(default=None, description="支付宝交易号")
    version: Optional[StrictStr] = Field(default=None, description="接口版本")
    __properties: ClassVar[List[str]] = ["app_id", "auth_app_id", "charset", "method", "out_trade_no", "seller_id", "sign", "sign_type", "timestamp", "total_amount", "trade_no", "version"]

    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 ReturnPageNotifyRequest 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 app_id (nullable) is None
        # and model_fields_set contains the field
        if self.app_id is None and "app_id" in self.model_fields_set:
            _dict['app_id'] = None

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "app_id": obj.get("app_id"),
            "auth_app_id": obj.get("auth_app_id"),
            "charset": obj.get("charset"),
            "method": obj.get("method"),
            "out_trade_no": obj.get("out_trade_no"),
            "seller_id": obj.get("seller_id"),
            "sign": obj.get("sign"),
            "sign_type": obj.get("sign_type"),
            "timestamp": obj.get("timestamp"),
            "total_amount": obj.get("total_amount"),
            "trade_no": obj.get("trade_no"),
            "version": obj.get("version")
        })
        return _obj


