# 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.message_status import MessageStatus
from typing import Optional, Set
from typing_extensions import Self

class RcsStatusCallback(BaseModel):
    """
    RCS status callback object
    """ # noqa: E501
    error: Optional[StrictInt] = Field(default=None, description="error code, 0 - if successful")
    error_description: Optional[StrictStr] = Field(default=None, description="error description", alias="errorDescription")
    id: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Message ID – a unique identifier automatically generated on the Platform when the message is created")
    msisdn: Optional[Annotated[str, Field(min_length=9, strict=True, max_length=15)]] = Field(default=None, description="Phone number")
    reference: Optional[StrictStr] = Field(default=None, description="external unique ID. String up to 32 characters containing only alpha numeric characters.  **Please note:** messages with duplicate reference_id will be rejected")
    time_in: 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")
    time_sent: Optional[datetime] = Field(default=None, description="Date and time of sending the message")
    time_dr: Optional[datetime] = Field(default=None, description="Date and time of receipt of the delivery report response")
    status: Optional[MessageStatus] = None
    price: Optional[StrictStr] = Field(default=None, description="Message price")
    currency: Optional[StrictStr] = Field(default=None, description="The currency code of the account. Specified according to the ISO-4217 standard")
    __properties: ClassVar[List[str]] = ["error", "errorDescription", "id", "msisdn", "reference", "time_in", "time_sent", "time_dr", "status", "price", "currency"]

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "error": obj.get("error"),
            "errorDescription": obj.get("errorDescription"),
            "id": obj.get("id"),
            "msisdn": obj.get("msisdn"),
            "reference": obj.get("reference"),
            "time_in": obj.get("time_in"),
            "time_sent": obj.get("time_sent"),
            "time_dr": obj.get("time_dr"),
            "status": obj.get("status"),
            "price": obj.get("price"),
            "currency": obj.get("currency")
        })
        return _obj


