# coding: utf-8

"""
    qoery's API

    Every number on the internet, queryable. Instant access to millions of trusted statistics through a single natural language query or API call.  # Installation  ### Python SDK  Install from PyPI:  ```bash pip install qoery ```  PyPI: [qoery](https://pypi.org/project/qoery/)  ### JavaScript SDK  Install from npm:  ```bash npm install qoery ```  npm: [qoery](https://www.npmjs.com/package/qoery) 

    The version of the OpenAPI document: 0.4.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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from qoery.models.plans_get200_response_plans_value_api_keys import PlansGet200ResponsePlansValueApiKeys
from qoery.models.plans_get200_response_plans_value_monthly_price import PlansGet200ResponsePlansValueMonthlyPrice
from typing import Optional, Set
from typing_extensions import Self

class PlansGet200ResponsePlansValue(BaseModel):
    """
    PlansGet200ResponsePlansValue
    """ # noqa: E501
    name: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    price: Optional[StrictStr] = Field(default=None, description="Human-friendly display price")
    billing: Optional[StrictStr] = Field(default=None, description="Billing cadence for display (e.g., monthly, annual, one-time)")
    limits: Optional[Dict[str, StrictInt]] = Field(default=None, description="Monthly limits keyed by endpoint (e.g., 'query/nl', 'scrape', 'plot2table')")
    api_keys: Optional[PlansGet200ResponsePlansValueApiKeys] = None
    support: Optional[StrictStr] = None
    monthly_price: Optional[PlansGet200ResponsePlansValueMonthlyPrice] = Field(default=None, alias="monthlyPrice")
    annual_price: Optional[PlansGet200ResponsePlansValueMonthlyPrice] = Field(default=None, alias="annualPrice")
    discount_percentage: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, 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 PlansGet200ResponsePlansValue 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 PlansGet200ResponsePlansValue 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": PlansGet200ResponsePlansValueApiKeys.from_dict(obj["api_keys"]) if obj.get("api_keys") is not None else None,
            "support": obj.get("support"),
            "monthlyPrice": PlansGet200ResponsePlansValueMonthlyPrice.from_dict(obj["monthlyPrice"]) if obj.get("monthlyPrice") is not None else None,
            "annualPrice": PlansGet200ResponsePlansValueMonthlyPrice.from_dict(obj["annualPrice"]) if obj.get("annualPrice") is not None else None,
            "discountPercentage": obj.get("discountPercentage")
        })
        return _obj


