# coding: utf-8

"""
    CustomerBillingService

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

    The version of the OpenAPI document: 1.0.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.billing.coupon_claim_info import CouponClaimInfo
from openapi_client.models.billing.coupon_redemption import CouponRedemption
from typing_extensions import Self

class Coupon(BaseModel):
    """
    Coupon
    """ # noqa: E501
    coupon_code: Optional[StrictStr] = Field(default=None, alias="CouponCode")
    class_name: Optional[StrictStr] = Field(default=None, alias="ClassName")
    coupon_type: Optional[StrictStr] = Field(default=None, alias="CouponType")
    amount: Optional[StrictFloat] = Field(default=None, alias="Amount")
    spend_threshold: Optional[StrictFloat] = Field(default=None, alias="SpendThreshold")
    currency_code: Optional[StrictStr] = Field(default=None, alias="CurrencyCode")
    percent_off: Optional[StrictFloat] = Field(default=None, alias="PercentOff")
    active_duration: Optional[StrictInt] = Field(default=None, alias="ActiveDuration")
    expiration_date: Optional[datetime] = Field(default=None, alias="ExpirationDate")
    start_date: Optional[datetime] = Field(default=None, alias="StartDate")
    end_date: Optional[datetime] = Field(default=None, alias="EndDate")
    send_to_email: Optional[StrictStr] = Field(default=None, alias="SendToEmail")
    send_to_date: Optional[datetime] = Field(default=None, alias="SendToDate")
    is_redeemed: Optional[StrictBool] = Field(default=None, alias="IsRedeemed")
    redemption_info: Optional[CouponRedemption] = Field(default=None, alias="RedemptionInfo")
    claim_info: Optional[CouponClaimInfo] = Field(default=None, alias="ClaimInfo")
    __properties: ClassVar[List[str]] = ["CouponCode", "ClassName", "CouponType", "Amount", "SpendThreshold", "CurrencyCode", "PercentOff", "ActiveDuration", "ExpirationDate", "StartDate", "EndDate", "SendToEmail", "SendToDate", "IsRedeemed", "RedemptionInfo", "ClaimInfo"]

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

    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,
        )
        # override the default output from pydantic by calling `to_dict()` of redemption_info
        if self.redemption_info:
            _dict['RedemptionInfo'] = self.redemption_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of claim_info
        if self.claim_info:
            _dict['ClaimInfo'] = self.claim_info.to_dict()
        # set to None if coupon_code (nullable) is None
        # and model_fields_set contains the field
        if self.coupon_code is None and "coupon_code" in self.model_fields_set:
            _dict['CouponCode'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "CouponCode": obj.get("CouponCode") if obj.get("CouponCode") is not None else None,
                        "ClassName": obj.get("ClassName") if obj.get("ClassName") is not None else None,
                        "CouponType": obj.get("CouponType") if obj.get("CouponType") is not None else None,
                        "Amount": obj.get("Amount") if obj.get("Amount") is not None else None,
                        "SpendThreshold": obj.get("SpendThreshold") if obj.get("SpendThreshold") is not None else None,
                        "CurrencyCode": obj.get("CurrencyCode") if obj.get("CurrencyCode") is not None else None,
                        "PercentOff": obj.get("PercentOff") if obj.get("PercentOff") is not None else None,
                        "ActiveDuration": obj.get("ActiveDuration") if obj.get("ActiveDuration") is not None else None,
                        "ExpirationDate": obj.get("ExpirationDate") if obj.get("ExpirationDate") is not None else None,
                        "StartDate": obj.get("StartDate") if obj.get("StartDate") is not None else None,
                        "EndDate": obj.get("EndDate") if obj.get("EndDate") is not None else None,
                        "SendToEmail": obj.get("SendToEmail") if obj.get("SendToEmail") is not None else None,
                        "SendToDate": obj.get("SendToDate") if obj.get("SendToDate") is not None else None,
                        "IsRedeemed": obj.get("IsRedeemed") if obj.get("IsRedeemed") is not None else None,
                        "RedemptionInfo": CouponRedemption.from_dict(obj["RedemptionInfo"]) if obj.get("RedemptionInfo") is not None else None,
                        "ClaimInfo": CouponClaimInfo.from_dict(obj["ClaimInfo"]) if obj.get("ClaimInfo") is not None else None
        })
        return _obj
