# 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.client_link_status import ClientLinkStatus
from openapi_client.models.customer.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from typing_extensions import Self

class ClientLink(BaseModel):
    """
    ClientLink
    """ # noqa: E501
    type: Optional[StrictStr] = Field(default=None, alias="Type")
    client_entity_id: Optional[StrictStr] = Field(default=None, alias="ClientEntityId")
    client_entity_number: Optional[StrictStr] = Field(default=None, alias="ClientEntityNumber")
    client_entity_name: Optional[StrictStr] = Field(default=None, alias="ClientEntityName")
    managing_customer_id: Optional[StrictStr] = Field(default=None, alias="ManagingCustomerId")
    managing_customer_number: Optional[StrictStr] = Field(default=None, alias="ManagingCustomerNumber")
    managing_customer_name: Optional[StrictStr] = Field(default=None, alias="ManagingCustomerName")
    note: Optional[StrictStr] = Field(default=None, alias="Note")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    inviter_email: Optional[StrictStr] = Field(default=None, alias="InviterEmail")
    inviter_name: Optional[StrictStr] = Field(default=None, alias="InviterName")
    inviter_phone: Optional[StrictStr] = Field(default=None, alias="InviterPhone")
    is_bill_to_client: Optional[StrictBool] = Field(default=None, alias="IsBillToClient")
    start_date: Optional[datetime] = Field(default=None, alias="StartDate")
    status: Optional[ClientLinkStatus] = Field(default=None, alias="Status")
    suppress_notification: Optional[StrictBool] = Field(default=None, alias="SuppressNotification")
    last_modified_date_time: Optional[datetime] = Field(default=None, alias="LastModifiedDateTime")
    last_modified_by_user_id: Optional[StrictStr] = Field(default=None, alias="LastModifiedByUserId")
    timestamp: Optional[StrictStr] = Field(default=None, alias="Timestamp")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    customer_link_permission: Optional[StrictStr] = Field(default=None, alias="CustomerLinkPermission")
    __properties: ClassVar[List[str]] = ["Type", "ClientEntityId", "ClientEntityNumber", "ClientEntityName", "ManagingCustomerId", "ManagingCustomerNumber", "ManagingCustomerName", "Note", "Name", "InviterEmail", "InviterName", "InviterPhone", "IsBillToClient", "StartDate", "Status", "SuppressNotification", "LastModifiedDateTime", "LastModifiedByUserId", "Timestamp", "ForwardCompatibilityMap", "CustomerLinkPermission"]

    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 each item in forward_compatibility_map (list)
        _items = []
        if self.forward_compatibility_map:
            for _item_forward_compatibility_map in self.forward_compatibility_map:
                if _item_forward_compatibility_map:
                    _items.append(_item_forward_compatibility_map.to_dict())
            _dict['ForwardCompatibilityMap'] = _items
        # set to None if type (nullable) is None
        # and model_fields_set contains the field
        if self.type is None and "type" in self.model_fields_set:
            _dict['Type'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Type": obj.get("Type") if obj.get("Type") is not None else None,
                        "ClientEntityId": obj.get("ClientEntityId") if obj.get("ClientEntityId") is not None else None,
                        "ClientEntityNumber": obj.get("ClientEntityNumber") if obj.get("ClientEntityNumber") is not None else None,
                        "ClientEntityName": obj.get("ClientEntityName") if obj.get("ClientEntityName") is not None else None,
                        "ManagingCustomerId": obj.get("ManagingCustomerId") if obj.get("ManagingCustomerId") is not None else None,
                        "ManagingCustomerNumber": obj.get("ManagingCustomerNumber") if obj.get("ManagingCustomerNumber") is not None else None,
                        "ManagingCustomerName": obj.get("ManagingCustomerName") if obj.get("ManagingCustomerName") is not None else None,
                        "Note": obj.get("Note") if obj.get("Note") is not None else None,
                        "Name": obj.get("Name") if obj.get("Name") is not None else None,
                        "InviterEmail": obj.get("InviterEmail") if obj.get("InviterEmail") is not None else None,
                        "InviterName": obj.get("InviterName") if obj.get("InviterName") is not None else None,
                        "InviterPhone": obj.get("InviterPhone") if obj.get("InviterPhone") is not None else None,
                        "IsBillToClient": obj.get("IsBillToClient") if obj.get("IsBillToClient") is not None else None,
                        "StartDate": obj.get("StartDate") if obj.get("StartDate") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "SuppressNotification": obj.get("SuppressNotification") if obj.get("SuppressNotification") is not None else None,
                        "LastModifiedDateTime": obj.get("LastModifiedDateTime") if obj.get("LastModifiedDateTime") is not None else None,
                        "LastModifiedByUserId": obj.get("LastModifiedByUserId") if obj.get("LastModifiedByUserId") is not None else None,
                        "Timestamp": obj.get("Timestamp") if obj.get("Timestamp") is not None else None,
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None,
                        "CustomerLinkPermission": obj.get("CustomerLinkPermission") if obj.get("CustomerLinkPermission") is not None else None
        })
        return _obj
