# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from bsg_api.models.sender_request_type import SenderRequestType
from typing import Optional, Set
from typing_extensions import Self

class SenderRequestNaturalRequest(BaseModel):
    """
    SenderRequestNaturalRequest
    """ # noqa: E501
    country_code: StrictStr = Field(description="Country code according to ISO 3166-1 alpha-2 standard")
    type: SenderRequestType
    sender: StrictStr = Field(description="Sender name.   Up to 11 Latin letters or digits, up to 15 – only digits. To setup senders visit the [account](https://app.bsg.world/sms/senders) or use [sender api](#tag/Senders)")
    name: Annotated[str, Field(min_length=1, strict=True, max_length=100)] = Field(description="Last name, first name, and middle name")
    code_of_company: Annotated[str, Field(min_length=1, strict=True, max_length=30)] = Field(description="National registration code of Company (ЄДРПОУ for Ukraine)")
    description: Annotated[str, Field(min_length=1, strict=True, max_length=1000)] = Field(description="Service description")
    informing_purpose: Annotated[str, Field(min_length=1, strict=True, max_length=1000)] = Field(description="Purpose of informing")
    site_url: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=150)]] = Field(default=None, description="Website URL of your service")
    comment: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=1000)]] = Field(default=None, description="any additional information")
    __properties: ClassVar[List[str]] = ["country_code", "type", "sender", "name", "code_of_company", "description", "informing_purpose", "site_url", "comment"]

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

        return _dict

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

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

        _obj = cls.model_validate({
            "country_code": obj.get("country_code"),
            "type": obj.get("type") if obj.get("type") is not None else SenderRequestType.SMS,
            "sender": obj.get("sender"),
            "name": obj.get("name"),
            "code_of_company": obj.get("code_of_company"),
            "description": obj.get("description"),
            "informing_purpose": obj.get("informing_purpose"),
            "site_url": obj.get("site_url"),
            "comment": obj.get("comment")
        })
        return _obj


