# coding: utf-8

"""
    Qoetry API

    Qoetry API for dataset collection and management. Start dataset collection jobs, monitor their progress, and download results as CSV files.  ## Authentication  **All endpoints require API key authentication** (except `/health` and `/`).  You can provide your API key via: - Query parameter: `?api_key=your_api_key` - Header: `x-api-key: your_api_key` - Header: `Authorization: Bearer your_api_key`  ## Rate Limits  API calls are subject to monthly quotas based on your subscription plan. Quota information is available via the `/v0/usage` endpoint. 

    The version of the OpenAPI document: 0.5.0
    Contact: samuel.tinnerholm@gmail.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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from qoery.models.v0_plans_get200_response_plans_value_annual_price import V0PlansGet200ResponsePlansValueAnnualPrice
from qoery.models.v0_plans_get200_response_plans_value_api_keys import V0PlansGet200ResponsePlansValueApiKeys
from qoery.models.v0_plans_get200_response_plans_value_monthly_price import V0PlansGet200ResponsePlansValueMonthlyPrice
from typing import Optional, Set
from typing_extensions import Self

class V0PlansGet200ResponsePlansValue(BaseModel):
    """
    Subscription plan details
    """ # noqa: E501
    name: StrictStr = Field(description="Plan display name")
    description: StrictStr = Field(description="Plan description")
    price: StrictStr = Field(description="Human-friendly display price")
    billing: StrictStr = Field(description="Billing cadence description")
    limits: Dict[str, StrictInt] = Field(description="Monthly limits per endpoint")
    api_keys: V0PlansGet200ResponsePlansValueApiKeys
    support: StrictStr = Field(description="Support level")
    monthly_price: Optional[V0PlansGet200ResponsePlansValueMonthlyPrice] = Field(default=None, alias="monthlyPrice")
    annual_price: Optional[V0PlansGet200ResponsePlansValueAnnualPrice] = Field(default=None, alias="annualPrice")
    discount_percentage: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, description="Discount percentage for annual billing", alias="discountPercentage")
    __properties: ClassVar[List[str]] = ["name", "description", "price", "billing", "limits", "api_keys", "support", "monthlyPrice", "annualPrice", "discountPercentage"]

    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 V0PlansGet200ResponsePlansValue 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,
        )
        # override the default output from pydantic by calling `to_dict()` of api_keys
        if self.api_keys:
            _dict['api_keys'] = self.api_keys.to_dict()
        # override the default output from pydantic by calling `to_dict()` of monthly_price
        if self.monthly_price:
            _dict['monthlyPrice'] = self.monthly_price.to_dict()
        # override the default output from pydantic by calling `to_dict()` of annual_price
        if self.annual_price:
            _dict['annualPrice'] = self.annual_price.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "description": obj.get("description"),
            "price": obj.get("price"),
            "billing": obj.get("billing"),
            "limits": obj.get("limits"),
            "api_keys": V0PlansGet200ResponsePlansValueApiKeys.from_dict(obj["api_keys"]) if obj.get("api_keys") is not None else None,
            "support": obj.get("support"),
            "monthlyPrice": V0PlansGet200ResponsePlansValueMonthlyPrice.from_dict(obj["monthlyPrice"]) if obj.get("monthlyPrice") is not None else None,
            "annualPrice": V0PlansGet200ResponsePlansValueAnnualPrice.from_dict(obj["annualPrice"]) if obj.get("annualPrice") is not None else None,
            "discountPercentage": obj.get("discountPercentage")
        })
        return _obj


