# coding: utf-8

"""
    FreeClimb API

    FreeClimb is a cloud-based application programming interface (API) that puts the power of the Vail platform in your hands. FreeClimb simplifies the process of creating applications that can use a full range of telephony features without requiring specialized or on-site telephony equipment. Using the FreeClimb REST API to write applications is easy! You have the option to use the language of your choice or hit the API directly. Your application can execute a command by issuing a RESTful request to the FreeClimb API. The base URL to send HTTP requests to the FreeClimb REST API is: /apiserver. FreeClimb authenticates and processes your request.

    The version of the OpenAPI document: 1.0.0
    Contact: support@freeclimb.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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from freeclimb.models.capabilities import Capabilities
from freeclimb.models.tfn import TFN
from pydantic import StrictStr
from typing import Optional, Set
from typing_extensions import Self


class IncomingNumberResult(
    BaseModel, populate_by_name=True, validate_assignment=True, protected_namespaces=()
):
    """
    IncomingNumberResult
    """  # noqa: E501

    uri: Optional[StrictStr] = Field(
        default=None, description="The URI for this resource, relative to /apiserver."
    )
    date_created: Optional[StrictStr] = Field(
        default=None,
        description="The date that this resource was created (GMT) in RFC 1123 format (e.g., Mon, 15 Jun 2009 20:45:30 GMT).",
        alias="dateCreated",
    )
    date_updated: Optional[StrictStr] = Field(
        default=None,
        description="The date that this resource was last updated (GMT) in RFC 1123 format (e.g., Mon, 15 Jun 2009 20:45:30 GMT).",
        alias="dateUpdated",
    )
    revision: Optional[StrictInt] = Field(
        default=None,
        description="Revision count for the resource. This count is set to 1 on creation and is incremented every time it is updated.",
    )
    capabilities: Optional[Capabilities] = None
    campaign_id: Optional[StrictStr] = Field(
        default=None,
        description="The campaign ID generated by the campaign registry",
        alias="campaignId",
    )
    phone_number_id: Optional[StrictStr] = Field(
        default=None,
        description="String that uniquely identifies this phone number resource.",
        alias="phoneNumberId",
    )
    account_id: Optional[StrictStr] = Field(
        default=None,
        description="ID of the account that owns this phone number.",
        alias="accountId",
    )
    application_id: Optional[StrictStr] = Field(
        default=None,
        description="ID of the Application that FreeClimb should contact if a Call or SMS arrives for this phone number or a Call from this number is placed. An incoming phone number is not useful until associated with an applicationId.",
        alias="applicationId",
    )
    phone_number: Optional[StrictStr] = Field(
        default=None, description="Phone number in E.164 format.", alias="phoneNumber"
    )
    alias: Optional[StrictStr] = Field(
        default=None,
        description="Description for this phone number. Typically the conventionally-formatted version of the phone number.",
    )
    region: Optional[StrictStr] = Field(
        default=None, description="State or province of this phone number."
    )
    country: Optional[StrictStr] = Field(
        default=None, description="Country of this phone number."
    )
    voice_enabled: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether the phone number can handle Calls. Typically set to true for all numbers.",
        alias="voiceEnabled",
    )
    sms_enabled: Optional[StrictBool] = Field(
        default=None,
        description="Indication of whether the phone number can handle sending and receiving SMS messages. Typically set to true for all numbers.",
        alias="smsEnabled",
    )
    offnet: Optional[StrictBool] = Field(
        default=None,
        description="The offnet field is a boolean representing whether the number is offnet registered or not. This field will be rendered only for requests to the IncomingPhone number resource.",
    )
    tfn: Optional[TFN] = None

    __properties: ClassVar[List[str]] = [
        "uri",
        "dateCreated",
        "dateUpdated",
        "revision",
        "capabilities",
        "campaignId",
        "phoneNumberId",
        "accountId",
        "applicationId",
        "phoneNumber",
        "alias",
        "region",
        "country",
        "voiceEnabled",
        "smsEnabled",
        "offnet",
        "tfn",
    ]

    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 IncomingNumberResult 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 capabilities
        if self.capabilities:
            _dict["capabilities"] = self.capabilities.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tfn
        if self.tfn:
            _dict["tfn"] = self.tfn.to_dict()
        # set to None if campaign_id (nullable) is None
        # and model_fields_set contains the field
        if self.campaign_id is None and "campaign_id" in self.model_fields_set:
            _dict["campaignId"] = None

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "uri": obj.get("uri"),
                "dateCreated": obj.get("dateCreated"),
                "dateUpdated": obj.get("dateUpdated"),
                "revision": obj.get("revision"),
                "capabilities": (
                    Capabilities.from_dict(obj["capabilities"])
                    if obj.get("capabilities") is not None
                    else None
                ),
                "campaignId": obj.get("campaignId"),
                "phoneNumberId": obj.get("phoneNumberId"),
                "accountId": obj.get("accountId"),
                "applicationId": obj.get("applicationId"),
                "phoneNumber": obj.get("phoneNumber"),
                "alias": obj.get("alias"),
                "region": obj.get("region"),
                "country": obj.get("country"),
                "voiceEnabled": obj.get("voiceEnabled"),
                "smsEnabled": obj.get("smsEnabled"),
                "offnet": obj.get("offnet"),
                "tfn": (
                    TFN.from_dict(obj["tfn"]) if obj.get("tfn") is not None else None
                ),
            }
        )
        return _obj
