# coding: utf-8

"""
    bxb API

    A comprehensive usage-based billing platform API. Manage customers, plans, subscriptions, invoices, payments, wallets, coupons, credit notes, taxes, webhooks, and more.

    The version of the OpenAPI document: 0.3.5
    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, StrictFloat, StrictInt, field_validator
from typing import Any, ClassVar, Dict, List, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class DunningCampaignPerformanceStats(BaseModel):
    """
    Performance statistics for dunning campaigns.
    """ # noqa: E501
    total_campaigns: StrictInt
    active_campaigns: StrictInt
    total_payment_requests: StrictInt
    succeeded_requests: StrictInt
    failed_requests: StrictInt
    pending_requests: StrictInt
    recovery_rate: Union[StrictFloat, StrictInt]
    total_recovered_amount_cents: Annotated[str, Field(strict=True)]
    total_outstanding_amount_cents: Annotated[str, Field(strict=True)]
    __properties: ClassVar[List[str]] = ["total_campaigns", "active_campaigns", "total_payment_requests", "succeeded_requests", "failed_requests", "pending_requests", "recovery_rate", "total_recovered_amount_cents", "total_outstanding_amount_cents"]

    @field_validator('total_recovered_amount_cents')
    def total_recovered_amount_cents_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$", value):
            raise ValueError(r"must validate the regular expression /^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/")
        return value

    @field_validator('total_outstanding_amount_cents')
    def total_outstanding_amount_cents_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$", value):
            raise ValueError(r"must validate the regular expression /^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$/")
        return value

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

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

        _obj = cls.model_validate({
            "total_campaigns": obj.get("total_campaigns"),
            "active_campaigns": obj.get("active_campaigns"),
            "total_payment_requests": obj.get("total_payment_requests"),
            "succeeded_requests": obj.get("succeeded_requests"),
            "failed_requests": obj.get("failed_requests"),
            "pending_requests": obj.get("pending_requests"),
            "recovery_rate": obj.get("recovery_rate"),
            "total_recovered_amount_cents": obj.get("total_recovered_amount_cents"),
            "total_outstanding_amount_cents": obj.get("total_outstanding_amount_cents")
        })
        return _obj


