# 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 PhoneNumberUpdateRequest(BaseModel):
    """
    Data for updating an existing phone number's configuration on a site.
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="New user-friendly name for the phone number.")
    destination_code: Optional[StrictStr] = Field(default=None, description="New system code for the call routing destination.")
    __properties: ClassVar[List[str]] = ["name", "destination_code"]

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PhoneNumberUpdateRequest 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"),
            "destination_code": obj.get("destination_code")
        })
        return _obj


