# 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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from flexprice.models.types_coupon_type import TypesCouponType
from flexprice.models.types_status import TypesStatus
from typing import Optional, Set
from typing_extensions import Self

class DtoCouponApplicationResponse(BaseModel):
    """
    DtoCouponApplicationResponse
    """ # noqa: E501
    applied_at: Optional[StrictStr] = None
    coupon_association_id: Optional[StrictStr] = None
    coupon_id: Optional[StrictStr] = None
    coupon_snapshot: Optional[Dict[str, Any]] = None
    created_at: Optional[StrictStr] = None
    created_by: Optional[StrictStr] = None
    currency: Optional[StrictStr] = None
    discount_percentage: Optional[Union[StrictFloat, StrictInt]] = None
    discount_type: Optional[TypesCouponType] = None
    discounted_amount: Optional[Union[StrictFloat, StrictInt]] = None
    environment_id: Optional[StrictStr] = None
    final_price: Optional[Union[StrictFloat, StrictInt]] = None
    id: Optional[StrictStr] = None
    invoice_id: Optional[StrictStr] = None
    invoice_line_item_id: Optional[StrictStr] = None
    metadata: Optional[Dict[str, StrictStr]] = None
    original_price: Optional[Union[StrictFloat, StrictInt]] = None
    status: Optional[TypesStatus] = None
    subscription_id: Optional[StrictStr] = None
    tenant_id: Optional[StrictStr] = None
    updated_at: Optional[StrictStr] = None
    updated_by: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["applied_at", "coupon_association_id", "coupon_id", "coupon_snapshot", "created_at", "created_by", "currency", "discount_percentage", "discount_type", "discounted_amount", "environment_id", "final_price", "id", "invoice_id", "invoice_line_item_id", "metadata", "original_price", "status", "subscription_id", "tenant_id", "updated_at", "updated_by"]

    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 DtoCouponApplicationResponse 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 DtoCouponApplicationResponse from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "applied_at": obj.get("applied_at"),
            "coupon_association_id": obj.get("coupon_association_id"),
            "coupon_id": obj.get("coupon_id"),
            "coupon_snapshot": obj.get("coupon_snapshot"),
            "created_at": obj.get("created_at"),
            "created_by": obj.get("created_by"),
            "currency": obj.get("currency"),
            "discount_percentage": obj.get("discount_percentage"),
            "discount_type": obj.get("discount_type"),
            "discounted_amount": obj.get("discounted_amount"),
            "environment_id": obj.get("environment_id"),
            "final_price": obj.get("final_price"),
            "id": obj.get("id"),
            "invoice_id": obj.get("invoice_id"),
            "invoice_line_item_id": obj.get("invoice_line_item_id"),
            "metadata": obj.get("metadata"),
            "original_price": obj.get("original_price"),
            "status": obj.get("status"),
            "subscription_id": obj.get("subscription_id"),
            "tenant_id": obj.get("tenant_id"),
            "updated_at": obj.get("updated_at"),
            "updated_by": obj.get("updated_by")
        })
        return _obj


