# 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 pydantic import StrictStr
from typing import Optional, Set
from typing_extensions import Self


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

    var_from: StrictStr = Field(
        description="Phone number to use as the caller ID. This can be: (a) The To or From number provided in FreeClimb's initial request to your app or (b) Any incoming phone number you have purchased from FreeClimb.",
        alias="from",
    )
    to: StrictStr = Field(description="Phone number to place the Call to.")
    application_id: Optional[StrictStr] = Field(
        default=None,
        description="Required if no `parentCallId` or `callConnectUrl` has been provided. ID of the application FreeClimb should use to handle this phone call. FreeClimb will use the `callConnectUrl` and `statusCallbackUrl` set on the application unless the `callConnectUrl` attribute is also provided with the request. In this case, the URL specified in that `callConnectUrl` attribute will be used as a replacement of the `callConnectUrl` originally assigned in the application. If the `callConnectUrl` is not set as either an attribute of the request or as part of the specified application, an error will be provided. The application’s voiceUrl parameter is not used for outbound calls.",
        alias="applicationId",
    )
    send_digits: Optional[StrictStr] = Field(
        default=None,
        description="String of digits to dial after connecting to the number. It can include digits `0-9`, `*`, and `#`, and allows embedding a pause between the output of individual digits. The default pause is 500 milliseconds. So, a string such as *1234#* will be played in 2 seconds because of the 4 standard pauses implied within the string. A custom pause is specified by including a positive integer wrapped in curly braces: {n}. For more information, see **sendDigits examples** below.",
        alias="sendDigits",
    )
    if_machine: Optional[StrictStr] = Field(
        default=None,
        description="Specifies how FreeClimb should handle this Call if an answering machine answers it.",
        alias="ifMachine",
    )
    if_machine_url: Optional[StrictStr] = Field(
        default=None,
        description="This attribute specifies a URL to which FreeClimb will make a POST request when an answering machine or a fax machine is detected. This URL is required if the ifMachine flag is set to redirect. When ifMachine is set to hangup, ifMachineUrl must not be included in the request. For more information, see **ifMachineUrl example** below.",
        alias="ifMachineUrl",
    )
    timeout: Optional[StrictInt] = Field(
        default=30,
        description="Number of seconds that FreeClimb should allow the phone to ring before assuming there is no answer. Default is 30 seconds. Maximum allowed ring-time is determined by the target phone's provider. Note that most providers limit ring-time to 120 seconds.",
    )
    parent_call_id: Optional[StrictStr] = Field(
        default=None,
        description="Required if no `applicationId` or `callConnectUrl` has been provided. The ID of the parent Call in the case that this new Call is meant to be treated as a child of an existing Call. This attribute should be included when possible to reduce latency when adding child calls to Conferences containing the parent Call. A call can only be used as a parent once the call is in progress or as an inbound call that is still ringing. An outbound call is considered to be in progress once the `outdialConnect` or `outdialApiConnect` webhook is invoked. An inbound call is ringing when the inbound webhook is invoked. If a `callConnectUrl` attribute is also included with the `parentCallId` in the request, this URL will be used as a replacement of the `callConnectUrl` originally assigned in the parent call.",
        alias="parentCallId",
    )
    privacy_mode: Optional[StrictBool] = Field(
        default=None,
        description="Activate privacy mode in order to obscure log data that can potentially expose private information.",
        alias="privacyMode",
    )
    call_connect_url: Optional[StrictStr] = Field(
        default=None,
        description="The URL that FreeClimb should use to handle this phone call. If an applicationId or parentCallId have already been provided, this callConnectUrl attribute will be used as a replacement of the callConnectUrl originally assigned in the application or parent call.",
        alias="callConnectUrl",
    )

    __properties: ClassVar[List[str]] = [
        "from",
        "to",
        "applicationId",
        "sendDigits",
        "ifMachine",
        "ifMachineUrl",
        "timeout",
        "parentCallId",
        "privacyMode",
        "callConnectUrl",
    ]

    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 MakeCallRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "from": obj.get("from"),
                "to": obj.get("to"),
                "applicationId": obj.get("applicationId"),
                "sendDigits": obj.get("sendDigits"),
                "ifMachine": obj.get("ifMachine"),
                "ifMachineUrl": obj.get("ifMachineUrl"),
                "timeout": obj.get("timeout") if obj.get("timeout") is not None else 30,
                "parentCallId": obj.get("parentCallId"),
                "privacyMode": obj.get("privacyMode"),
                "callConnectUrl": obj.get("callConnectUrl"),
            }
        )
        return _obj
