# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from bsg_api.models.sender_request_status import SenderRequestStatus
from bsg_api.models.sender_request_type import SenderRequestType
from typing import Optional, Set
from typing_extensions import Self

class SenderRequestSchema(BaseModel):
    """
    SenderRequestSchema
    """ # noqa: E501
    id: Optional[StrictInt] = Field(default=None, description="Number of the application for Sender registration")
    sender: Optional[StrictStr] = Field(default=None, 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)")
    status: Optional[SenderRequestStatus] = None
    created_at: Optional[datetime] = Field(default=None, description="Date when the item was created in the system ― set by the system automatically. Display format ― Y-m-d H:i:s")
    registered_at: Optional[datetime] = Field(default=None, description="Sender registration date")
    status_changed_at: Optional[datetime] = Field(default=None, description="Date and time when the status of the application for Sender registration changed. Format ISO 8601: yyyy-mm-dd hh:mm:ss")
    country_code: Optional[StrictStr] = Field(default=None, description="Country code according to ISO 3166-1 alpha-2 standard")
    code_of_company: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=30)]] = Field(default=None, description="National registration code of Company (ЄДРПОУ for Ukraine)")
    tax_number: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=30)]] = Field(default=None, description="Taxpayer number")
    type: Optional[SenderRequestType] = SenderRequestType.SMS
    site_url: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=150)]] = Field(default=None, description="Website URL of your service")
    name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=100)]] = Field(default=None, description="Last name, first name, and middle name")
    legal_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=100)]] = Field(default=None, description="Legal entity name")
    address: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field(default=None, description="Legal Address")
    informing_purpose: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=1000)]] = Field(default=None, description="Purpose of informing")
    comment: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=1000)]] = Field(default=None, description="any additional information")
    rejection_reason: Optional[Annotated[str, Field(strict=True, max_length=1000)]] = Field(default=None, description="Reason for rejecting the application for Sender registration. Displayed only for the “rejected” application status")
    description: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=1000)]] = Field(default=None, description="Service description")
    __properties: ClassVar[List[str]] = ["id", "sender", "status", "created_at", "registered_at", "status_changed_at", "country_code", "code_of_company", "tax_number", "type", "site_url", "name", "legal_name", "address", "informing_purpose", "comment", "rejection_reason", "description"]

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

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

        # 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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "sender": obj.get("sender"),
            "status": obj.get("status"),
            "created_at": obj.get("created_at"),
            "registered_at": obj.get("registered_at"),
            "status_changed_at": obj.get("status_changed_at"),
            "country_code": obj.get("country_code"),
            "code_of_company": obj.get("code_of_company"),
            "tax_number": obj.get("tax_number"),
            "type": obj.get("type") if obj.get("type") is not None else SenderRequestType.SMS,
            "site_url": obj.get("site_url"),
            "name": obj.get("name"),
            "legal_name": obj.get("legal_name"),
            "address": obj.get("address"),
            "informing_purpose": obj.get("informing_purpose"),
            "comment": obj.get("comment"),
            "rejection_reason": obj.get("rejection_reason"),
            "description": obj.get("description")
        })
        return _obj


