# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 0.82
    Contact: info@mixpeek.com
    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, StrictBool, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class SpendingCapsResponse(BaseModel):
    """
    Response with spending cap configuration.
    """ # noqa: E501
    monthly_spending_budget: Optional[StrictInt] = Field(default=None, description="Soft spending limit in USD cents (null = unlimited)")
    monthly_spending_budget_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Soft spending limit in USD")
    spending_alert_thresholds: Optional[List[StrictInt]] = Field(default=None, description="Percentage thresholds for spending alerts")
    spending_alerts_enabled: Optional[StrictBool] = Field(default=True, description="Whether spending alerts are enabled")
    spending_alerts_sent: Optional[List[StrictInt]] = Field(default=None, description="Alert thresholds triggered in current billing cycle")
    hard_spending_cap: Optional[StrictInt] = Field(default=None, description="Hard spending limit in USD cents (null = no hard cap)")
    hard_spending_cap_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Hard spending limit in USD")
    hard_cap_enabled: Optional[StrictBool] = Field(default=False, description="Whether hard spending cap is enforced")
    current_spending_cents: StrictInt = Field(description="Current spending in current billing cycle (cents)")
    current_spending_usd: Union[StrictFloat, StrictInt] = Field(description="Current spending in current billing cycle (USD)")
    budget_percentage_used: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Percentage of budget used (null if no budget set)")
    __properties: ClassVar[List[str]] = ["monthly_spending_budget", "monthly_spending_budget_usd", "spending_alert_thresholds", "spending_alerts_enabled", "spending_alerts_sent", "hard_spending_cap", "hard_spending_cap_usd", "hard_cap_enabled", "current_spending_cents", "current_spending_usd", "budget_percentage_used"]

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

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

        _obj = cls.model_validate({
            "monthly_spending_budget": obj.get("monthly_spending_budget"),
            "monthly_spending_budget_usd": obj.get("monthly_spending_budget_usd"),
            "spending_alert_thresholds": obj.get("spending_alert_thresholds"),
            "spending_alerts_enabled": obj.get("spending_alerts_enabled") if obj.get("spending_alerts_enabled") is not None else True,
            "spending_alerts_sent": obj.get("spending_alerts_sent"),
            "hard_spending_cap": obj.get("hard_spending_cap"),
            "hard_spending_cap_usd": obj.get("hard_spending_cap_usd"),
            "hard_cap_enabled": obj.get("hard_cap_enabled") if obj.get("hard_cap_enabled") is not None else False,
            "current_spending_cents": obj.get("current_spending_cents"),
            "current_spending_usd": obj.get("current_spending_usd"),
            "budget_percentage_used": obj.get("budget_percentage_used")
        })
        return _obj


