# coding: utf-8

"""
    FlexPrice API

    FlexPrice API Service

    The version of the OpenAPI document: 1.0
    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from flexprice.models.types_payment_destination_type import TypesPaymentDestinationType
from flexprice.models.types_payment_gateway_type import TypesPaymentGatewayType
from flexprice.models.types_payment_method_type import TypesPaymentMethodType
from typing import Optional, Set
from typing_extensions import Self

class DtoCreatePaymentRequest(BaseModel):
    """
    DtoCreatePaymentRequest
    """ # noqa: E501
    amount: Union[StrictFloat, StrictInt]
    cancel_url: Optional[StrictStr] = None
    currency: StrictStr
    destination_id: StrictStr
    destination_type: TypesPaymentDestinationType
    idempotency_key: Optional[StrictStr] = None
    metadata: Optional[Dict[str, StrictStr]] = None
    payment_gateway: Optional[TypesPaymentGatewayType] = None
    payment_method_id: Optional[StrictStr] = None
    payment_method_type: TypesPaymentMethodType
    process_payment: Optional[StrictBool] = True
    save_card_and_make_default: Optional[StrictBool] = False
    success_url: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["amount", "cancel_url", "currency", "destination_id", "destination_type", "idempotency_key", "metadata", "payment_gateway", "payment_method_id", "payment_method_type", "process_payment", "save_card_and_make_default", "success_url"]

    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 DtoCreatePaymentRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "amount": obj.get("amount"),
            "cancel_url": obj.get("cancel_url"),
            "currency": obj.get("currency"),
            "destination_id": obj.get("destination_id"),
            "destination_type": obj.get("destination_type"),
            "idempotency_key": obj.get("idempotency_key"),
            "metadata": obj.get("metadata"),
            "payment_gateway": obj.get("payment_gateway"),
            "payment_method_id": obj.get("payment_method_id"),
            "payment_method_type": obj.get("payment_method_type"),
            "process_payment": obj.get("process_payment") if obj.get("process_payment") is not None else True,
            "save_card_and_make_default": obj.get("save_card_and_make_default") if obj.get("save_card_and_make_default") is not None else False,
            "success_url": obj.get("success_url")
        })
        return _obj


