# coding: utf-8

"""
    Ringer Business API

    This API provides comprehensive endpoints for the Ringer Business system. It includes functionality for managing customer accounts, addresses, sites,  phone numbers, payments, users, and other business resources.  Operations typically require authentication and appropriate permissions. 

    The version of the OpenAPI document: 1.0.4
    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ForwardUpdateRequest(BaseModel):
    """
    Data for updating an existing call forward. Only provide fields to change.
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="A user-friendly name for the forward configuration.")
    destination_dial_string: Optional[StrictStr] = Field(default=None, description="The external phone number (E.164 format recommended) to which calls will be forwarded.")
    timeout: Optional[StrictInt] = Field(default=None, description="How long (in seconds) the forward will be attempted before failing over or disconnecting.")
    active: Optional[StrictBool] = Field(default=None, description="Whether this call forward rule is currently active.")
    fail_over_destination_code: Optional[StrictStr] = Field(default=None, description="System code for the destination if the forward attempt fails or times out.")
    user_id: Optional[StrictInt] = Field(default=None, description="Optional. Identifier of the user primarily associated with this forward.")
    __properties: ClassVar[List[str]] = ["name", "destination_dial_string", "timeout", "active", "fail_over_destination_code", "user_id"]

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ForwardUpdateRequest 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_dial_string": obj.get("destination_dial_string"),
            "timeout": obj.get("timeout"),
            "active": obj.get("active"),
            "fail_over_destination_code": obj.get("fail_over_destination_code"),
            "user_id": obj.get("user_id")
        })
        return _obj


