# coding: utf-8

"""
    One-API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

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

class SendOtpRequest(BaseModel):
    """
    SendOtpRequest
    """ # noqa: E501
    recipient: StrictStr = Field(description="The phone number of the recipient of the one-time password. 9 to 15 digits without the + sign. 3 to 15 characters for the sender’s numeric name.")
    channel: StrictStr = Field(description="A channel for sending a one-time password. Possible values: sms, viber.")
    sender: StrictStr = Field(description="Sender’s name: from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces); 3 to 15 characters for the sender’s numeric name. To setup senders visit the [account](https://app.bsg.world/sms/senders)")
    sender_alt: Optional[StrictStr] = Field(default=None, description="Used only for the Viber channel to alternatively send a one-time code in SMS (if it was not possible to send the code in a Viber message, for example, if the recipient is not a Viber user).The name or number of the SMS sender. String up to 15 characters: from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces); 3 to 15 characters for the sender’s numeric name.")
    template_id: StrictInt = Field(description="Unique identifier of the [template](https://app.bsg.world/2fa/templates) with the Approved status. It’s not allowed to specify the template ID in other statuses. The template ID must be from 1 to 9 digits")
    code_lifetime: Annotated[int, Field(le=300, strict=True, ge=30)] = Field(description="The password expiration time after which the password becomes invalid. An integer from 30 seconds to 300 seconds.")
    code_max_tries: Annotated[int, Field(le=5, strict=True, ge=1)] = Field(description="The number of password verification attempts. An integer from 1 to 5.")
    code_digits: Annotated[int, Field(le=9, strict=True, ge=3)] = Field(description="The length of the numeric code, from 3 to 9 digits.")
    __properties: ClassVar[List[str]] = ["recipient", "channel", "sender", "sender_alt", "template_id", "code_lifetime", "code_max_tries", "code_digits"]

    @field_validator('channel')
    def channel_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['sms', 'viber']):
            raise ValueError("must be one of enum values ('sms', 'viber')")
        return value

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

        return _dict

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

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

        _obj = cls.model_validate({
            "recipient": obj.get("recipient"),
            "channel": obj.get("channel"),
            "sender": obj.get("sender"),
            "sender_alt": obj.get("sender_alt"),
            "template_id": obj.get("template_id"),
            "code_lifetime": obj.get("code_lifetime"),
            "code_max_tries": obj.get("code_max_tries"),
            "code_digits": obj.get("code_digits")
        })
        return _obj


