# coding: utf-8

"""
    Onboarding Buddy API

    This document details all the available operations in the Onboarding Buddy API specification

    The version of the OpenAPI document: v1
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from onboarding_buddy_client.models.email_sanction_record_m import EmailSanctionRecordM
from typing import Optional, Set
from typing_extensions import Self

class EmailAddressResponseM(BaseModel):
    """
    EmailAddressResponseM
    """ # noqa: E501
    message_id: Optional[StrictStr] = Field(default=None, alias="messageId")
    correlation_id: Optional[StrictStr] = Field(default=None, alias="correlationId")
    idempotency_key: Optional[StrictStr] = Field(default=None, alias="idempotencyKey")
    in_error: Optional[StrictBool] = Field(default=None, alias="inError")
    error_type: Optional[StrictStr] = Field(default=None, alias="errorType")
    messages: Optional[List[StrictStr]] = None
    email_address: Optional[StrictStr] = Field(default=None, alias="emailAddress")
    email_status: Optional[StrictStr] = Field(default=None, alias="emailStatus")
    free_email: Optional[StrictBool] = Field(default=None, alias="freeEmail")
    did_you_mean: Optional[StrictStr] = Field(default=None, alias="didYouMean")
    domain: Optional[StrictStr] = None
    smtp_provider: Optional[StrictStr] = Field(default=None, alias="smtpProvider")
    mx_found: Optional[StrictBool] = Field(default=None, alias="mxFound")
    mx_record: Optional[StrictStr] = Field(default=None, alias="mxRecord")
    is_disposable_domain: Optional[StrictBool] = Field(default=None, alias="isDisposableDomain")
    check_status: Optional[StrictStr] = Field(default=None, alias="checkStatus")
    sanction_record: Optional[EmailSanctionRecordM] = Field(default=None, alias="sanctionRecord")
    __properties: ClassVar[List[str]] = ["messageId", "correlationId", "idempotencyKey", "inError", "errorType", "messages", "emailAddress", "emailStatus", "freeEmail", "didYouMean", "domain", "smtpProvider", "mxFound", "mxRecord", "isDisposableDomain", "checkStatus", "sanctionRecord"]

    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 EmailAddressResponseM 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,
        )
        # override the default output from pydantic by calling `to_dict()` of sanction_record
        if self.sanction_record:
            _dict['sanctionRecord'] = self.sanction_record.to_dict()
        # set to None if message_id (nullable) is None
        # and model_fields_set contains the field
        if self.message_id is None and "message_id" in self.model_fields_set:
            _dict['messageId'] = None

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "messageId": obj.get("messageId"),
            "correlationId": obj.get("correlationId"),
            "idempotencyKey": obj.get("idempotencyKey"),
            "inError": obj.get("inError"),
            "errorType": obj.get("errorType"),
            "messages": obj.get("messages"),
            "emailAddress": obj.get("emailAddress"),
            "emailStatus": obj.get("emailStatus"),
            "freeEmail": obj.get("freeEmail"),
            "didYouMean": obj.get("didYouMean"),
            "domain": obj.get("domain"),
            "smtpProvider": obj.get("smtpProvider"),
            "mxFound": obj.get("mxFound"),
            "mxRecord": obj.get("mxRecord"),
            "isDisposableDomain": obj.get("isDisposableDomain"),
            "checkStatus": obj.get("checkStatus"),
            "sanctionRecord": EmailSanctionRecordM.from_dict(obj["sanctionRecord"]) if obj.get("sanctionRecord") is not None else None
        })
        return _obj


