# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from onboarding_buddy_client.models.digital_currency_address_m import DigitalCurrencyAddressM
from onboarding_buddy_client.models.individual_address_m import IndividualAddressM
from onboarding_buddy_client.models.individual_alias_m import IndividualAliasM
from onboarding_buddy_client.models.individual_sanction_record_m import IndividualSanctionRecordM
from typing import Optional, Set
from typing_extensions import Self

class OtherSanctionRecordM(BaseModel):
    """
    OtherSanctionRecordM
    """ # noqa: E501
    full_name: Optional[StrictStr] = Field(default=None, alias="fullName")
    program: Optional[StrictStr] = None
    title: Optional[StrictStr] = None
    additional_info: Optional[List[StrictStr]] = Field(default=None, alias="additionalInfo")
    alias_list: Optional[List[IndividualAliasM]] = Field(default=None, alias="aliasList")
    address_list: Optional[List[IndividualAddressM]] = Field(default=None, alias="addressList")
    nationality: Optional[StrictStr] = None
    linked_to: Optional[StrictStr] = Field(default=None, alias="linkedTo")
    place_of_birth: Optional[StrictStr] = Field(default=None, alias="placeOfBirth")
    passport: Optional[StrictStr] = None
    citizen: Optional[StrictStr] = None
    national_id_number: Optional[StrictStr] = Field(default=None, alias="nationalIdNumber")
    secondary_sanctions_risk: Optional[StrictStr] = Field(default=None, alias="secondarySanctionsRisk")
    digital_currency_address: Optional[List[DigitalCurrencyAddressM]] = Field(default=None, alias="digitalCurrencyAddress")
    websites: Optional[List[StrictStr]] = None
    email_address: Optional[List[StrictStr]] = Field(default=None, alias="emailAddress")
    call_sign: Optional[StrictStr] = Field(default=None, alias="callSign")
    vessel_type: Optional[StrictStr] = Field(default=None, alias="vesselType")
    tonnage: Optional[StrictStr] = None
    grt: Optional[StrictStr] = None
    vessel_flag: Optional[StrictStr] = Field(default=None, alias="vesselFlag")
    vessel_owner: Optional[StrictStr] = Field(default=None, alias="vesselOwner")
    also_known_as: Optional[List[StrictStr]] = Field(default=None, alias="alsoKnownAs")
    linked_individuals: Optional[List[IndividualSanctionRecordM]] = Field(default=None, alias="linkedIndividuals")
    linked_entity: Optional[List[OtherSanctionRecordM]] = Field(default=None, alias="linkedEntity")
    __properties: ClassVar[List[str]] = ["fullName", "program", "title", "additionalInfo", "aliasList", "addressList", "nationality", "linkedTo", "placeOfBirth", "passport", "citizen", "nationalIdNumber", "secondarySanctionsRisk", "digitalCurrencyAddress", "websites", "emailAddress", "callSign", "vesselType", "tonnage", "grt", "vesselFlag", "vesselOwner", "alsoKnownAs", "linkedIndividuals", "linkedEntity"]

    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 OtherSanctionRecordM 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 each item in alias_list (list)
        _items = []
        if self.alias_list:
            for _item_alias_list in self.alias_list:
                if _item_alias_list:
                    _items.append(_item_alias_list.to_dict())
            _dict['aliasList'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in address_list (list)
        _items = []
        if self.address_list:
            for _item_address_list in self.address_list:
                if _item_address_list:
                    _items.append(_item_address_list.to_dict())
            _dict['addressList'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in digital_currency_address (list)
        _items = []
        if self.digital_currency_address:
            for _item_digital_currency_address in self.digital_currency_address:
                if _item_digital_currency_address:
                    _items.append(_item_digital_currency_address.to_dict())
            _dict['digitalCurrencyAddress'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in linked_individuals (list)
        _items = []
        if self.linked_individuals:
            for _item_linked_individuals in self.linked_individuals:
                if _item_linked_individuals:
                    _items.append(_item_linked_individuals.to_dict())
            _dict['linkedIndividuals'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in linked_entity (list)
        _items = []
        if self.linked_entity:
            for _item_linked_entity in self.linked_entity:
                if _item_linked_entity:
                    _items.append(_item_linked_entity.to_dict())
            _dict['linkedEntity'] = _items
        # set to None if full_name (nullable) is None
        # and model_fields_set contains the field
        if self.full_name is None and "full_name" in self.model_fields_set:
            _dict['fullName'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "fullName": obj.get("fullName"),
            "program": obj.get("program"),
            "title": obj.get("title"),
            "additionalInfo": obj.get("additionalInfo"),
            "aliasList": [IndividualAliasM.from_dict(_item) for _item in obj["aliasList"]] if obj.get("aliasList") is not None else None,
            "addressList": [IndividualAddressM.from_dict(_item) for _item in obj["addressList"]] if obj.get("addressList") is not None else None,
            "nationality": obj.get("nationality"),
            "linkedTo": obj.get("linkedTo"),
            "placeOfBirth": obj.get("placeOfBirth"),
            "passport": obj.get("passport"),
            "citizen": obj.get("citizen"),
            "nationalIdNumber": obj.get("nationalIdNumber"),
            "secondarySanctionsRisk": obj.get("secondarySanctionsRisk"),
            "digitalCurrencyAddress": [DigitalCurrencyAddressM.from_dict(_item) for _item in obj["digitalCurrencyAddress"]] if obj.get("digitalCurrencyAddress") is not None else None,
            "websites": obj.get("websites"),
            "emailAddress": obj.get("emailAddress"),
            "callSign": obj.get("callSign"),
            "vesselType": obj.get("vesselType"),
            "tonnage": obj.get("tonnage"),
            "grt": obj.get("grt"),
            "vesselFlag": obj.get("vesselFlag"),
            "vesselOwner": obj.get("vesselOwner"),
            "alsoKnownAs": obj.get("alsoKnownAs"),
            "linkedIndividuals": [IndividualSanctionRecordM.from_dict(_item) for _item in obj["linkedIndividuals"]] if obj.get("linkedIndividuals") is not None else None,
            "linkedEntity": [OtherSanctionRecordM.from_dict(_item) for _item in obj["linkedEntity"]] if obj.get("linkedEntity") is not None else None
        })
        return _obj

# TODO: Rewrite to not use raise_errors
OtherSanctionRecordM.model_rebuild(raise_errors=False)

