# coding: utf-8

"""
    lomi. API

    Payment processing API for francophone West African businesses.

    The version of the OpenAPI document: 1.1.0
    Contact: hello@lomi.africa
    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
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self

class DiscountCoupons(BaseModel):
    """
    discount coupons resource object
    """ # noqa: E501
    applies_to_product_types: Optional[StrictStr] = None
    code: Optional[StrictStr] = None
    coupon_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    created_at: Optional[datetime] = Field(default=None, description="ISO 8601 datetime")
    current_uses: Optional[Union[StrictFloat, StrictInt]] = None
    customer_type: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    discount_fixed_amount: Optional[Union[StrictFloat, StrictInt]] = None
    discount_percentage: Optional[Union[StrictFloat, StrictInt]] = None
    discount_type: Optional[StrictStr] = None
    environment: Optional[StrictStr] = None
    expires_at: Optional[datetime] = Field(default=None, description="ISO 8601 datetime")
    is_active: Optional[StrictBool] = Field(default=None, description="Whether this resource is currently active")
    is_organization_wide: Optional[StrictBool] = None
    max_quantity_per_use: Optional[Union[StrictFloat, StrictInt]] = None
    max_uses: Optional[Union[StrictFloat, StrictInt]] = None
    organization_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    scope_type: Optional[StrictStr] = None
    updated_at: Optional[datetime] = Field(default=None, description="ISO 8601 datetime")
    usage_frequency_limit: Optional[StrictStr] = None
    usage_limit_value: Optional[Union[StrictFloat, StrictInt]] = None
    valid_from: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["applies_to_product_types", "code", "coupon_id", "created_at", "current_uses", "customer_type", "description", "discount_fixed_amount", "discount_percentage", "discount_type", "environment", "expires_at", "is_active", "is_organization_wide", "max_quantity_per_use", "max_uses", "organization_id", "scope_type", "updated_at", "usage_frequency_limit", "usage_limit_value", "valid_from"]

    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 DiscountCoupons 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "created_at",
            "updated_at",
        ])

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

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

        _obj = cls.model_validate({
            "applies_to_product_types": obj.get("applies_to_product_types"),
            "code": obj.get("code"),
            "coupon_id": obj.get("coupon_id"),
            "created_at": obj.get("created_at"),
            "current_uses": obj.get("current_uses"),
            "customer_type": obj.get("customer_type"),
            "description": obj.get("description"),
            "discount_fixed_amount": obj.get("discount_fixed_amount"),
            "discount_percentage": obj.get("discount_percentage"),
            "discount_type": obj.get("discount_type"),
            "environment": obj.get("environment"),
            "expires_at": obj.get("expires_at"),
            "is_active": obj.get("is_active"),
            "is_organization_wide": obj.get("is_organization_wide"),
            "max_quantity_per_use": obj.get("max_quantity_per_use"),
            "max_uses": obj.get("max_uses"),
            "organization_id": obj.get("organization_id"),
            "scope_type": obj.get("scope_type"),
            "updated_at": obj.get("updated_at"),
            "usage_frequency_limit": obj.get("usage_frequency_limit"),
            "usage_limit_value": obj.get("usage_limit_value"),
            "valid_from": obj.get("valid_from")
        })
        return _obj


