# coding: utf-8

"""
    CustomerManagementService

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

    The version of the OpenAPI document: 1.0.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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.customer.address import Address
from openapi_client.models.customer.email_format import EmailFormat
from typing_extensions import Self

class ContactInfo(BaseModel):
    """
    ContactInfo
    """ # noqa: E501
    address: Optional[Address] = Field(default=None, alias="Address")
    contact_by_phone: Optional[StrictBool] = Field(default=None, alias="ContactByPhone")
    contact_by_postal_mail: Optional[StrictBool] = Field(default=None, alias="ContactByPostalMail")
    email: Optional[StrictStr] = Field(default=None, alias="Email")
    email_format: Optional[EmailFormat] = Field(default=None, alias="EmailFormat")
    fax: Optional[StrictStr] = Field(default=None, alias="Fax")
    home_phone: Optional[StrictStr] = Field(default=None, alias="HomePhone")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    mobile: Optional[StrictStr] = Field(default=None, alias="Mobile")
    phone1: Optional[StrictStr] = Field(default=None, alias="Phone1")
    phone2: Optional[StrictStr] = Field(default=None, alias="Phone2")
    __properties: ClassVar[List[str]] = ["Address", "ContactByPhone", "ContactByPostalMail", "Email", "EmailFormat", "Fax", "HomePhone", "Id", "Mobile", "Phone1", "Phone2"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Address": Address.from_dict(obj["Address"]) if obj.get("Address") is not None else None,
                        "ContactByPhone": obj.get("ContactByPhone") if obj.get("ContactByPhone") is not None else None,
                        "ContactByPostalMail": obj.get("ContactByPostalMail") if obj.get("ContactByPostalMail") is not None else None,
                        "Email": obj.get("Email") if obj.get("Email") is not None else None,
                        "EmailFormat": obj.get("EmailFormat") if obj.get("EmailFormat") is not None else None,
                        "Fax": obj.get("Fax") if obj.get("Fax") is not None else None,
                        "HomePhone": obj.get("HomePhone") if obj.get("HomePhone") is not None else None,
                        "Id": obj.get("Id") if obj.get("Id") is not None else None,
                        "Mobile": obj.get("Mobile") if obj.get("Mobile") is not None else None,
                        "Phone1": obj.get("Phone1") if obj.get("Phone1") is not None else None,
                        "Phone2": obj.get("Phone2") if obj.get("Phone2") is not None else None
        })
        return _obj
