# coding: utf-8

"""
    Ringer Business API - Phone Number Management

    This API provides endpoints for managing phone numbers within a Ringer Business account and its sites. Phone numbers are essential for making and receiving calls and can be routed to various features like devices, menus, or voicemail.  Functionality includes: - Listing phone numbers associated with a specific site. - Assigning (creating) a new phone number to a site. - Retrieving details of a specific phone number. - Updating a phone number's configuration (e.g., its routing destination). - Deleting/unassigning a phone number from a site. - Transferring a phone number between sites. - Listing available phone numbers for assignment to a site (from inventory or search). - Searching for available phone numbers based on criteria like area code, city, etc. 

    The version of the OpenAPI document: 1.0.0
    Contact: support@ringer.tel
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class PhoneNumberAvailability(BaseModel):
    """
    Represents an available phone number that can be acquired.
    """ # noqa: E501
    number: StrictStr = Field(description="The available phone number in E.164 format.")
    location: Optional[StrictStr] = Field(default=None, description="Geographic location or rate center associated with the number.")
    type: Optional[StrictStr] = Field(default=None, description="Type of number (e.g., local, toll-free, mobile).")
    features: Optional[List[StrictStr]] = Field(default=None, description="Supported features for this number (e.g., voice, sms, mms).")
    __properties: ClassVar[List[str]] = ["number", "location", "type", "features"]

    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 PhoneNumberAvailability 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,
        )
        # set to None if location (nullable) is None
        # and model_fields_set contains the field
        if self.location is None and "location" in self.model_fields_set:
            _dict['location'] = None

        # set to None if type (nullable) is None
        # and model_fields_set contains the field
        if self.type is None and "type" in self.model_fields_set:
            _dict['type'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "number": obj.get("number"),
            "location": obj.get("location"),
            "type": obj.get("type"),
            "features": obj.get("features")
        })
        return _obj


