# coding: utf-8

"""
    Acre Platform User API

    # CORS CORS is implemented by all Acre API endpoints and only certain hostnames are allowed for each deployment of the API. If your use case requires calling the Acre User API from a browser, please contact Acre to arrange the appropriate configuration. # API Authentication The primary method of authentication for users of the Acre API is with the use of JSON Web Tokens (JWTs), which are suplemented by an application specific API Key. The API key must be provided through the `X-API-KEY` HTTP header and will be provided by your Acre Customer Success Manager. The JWT must be provided through a cookie with key of `authorization`. The JWT must be generated and signed as per the following section. # Generating JWTs JWT must either be generated by a third-party such as Azure ADB2C that has been configured for the appropriate service and/or user account, or alternatively can be generated locally and signed by an private key for which the public key has been made available to Acre via a JWKS URL. In addition to being signed by your private key, the JWT will also need to contain at a minimum:  * An issuer `iss`, which must be a valid URI previously agreed with Acre.  * A subject `sub`, which must be a unique identifier for the user and/or service account previously agreed with Acre.  * An expiry time `exp` which must not be more than four hours in the future.  * A not before time `nbf` which must be in the past, but not greater than six hours in the past.  The JWT should be signed using RS256.

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.cdm_product_benefit_type_employee_benefit import CdmProductBenefitTypeEmployeeBenefit
from acre_api.models.cdm_product_benefit_type_family_income_benefit import CdmProductBenefitTypeFamilyIncomeBenefit
from acre_api.models.cdm_product_benefit_type_general import CdmProductBenefitTypeGeneral
from acre_api.models.cdm_product_benefit_type_income_protection import CdmProductBenefitTypeIncomeProtection
from acre_api.models.cdm_product_benefit_type_other import CdmProductBenefitTypeOther
from acre_api.models.cdm_product_benefit_type_pmi import CdmProductBenefitTypePmi
from acre_api.models.cdm_product_benefit_type_private_medical_insurance import CdmProductBenefitTypePrivateMedicalInsurance
from acre_api.models.cdm_product_benefit_type_term import CdmProductBenefitTypeTerm
from acre_api.models.cdm_product_benefit_type_units import CdmProductBenefitTypeUnits
from acre_api.models.cdm_product_benefit_type_whole_of_life import CdmProductBenefitTypeWholeOfLife
from typing import Optional, Set
from typing_extensions import Self

class CdmProtectionProductBenefits(BaseModel):
    """
    CdmProtectionProductBenefits
    """ # noqa: E501
    product_type_term: Optional[List[CdmProductBenefitTypeTerm]] = None
    product_type_family_income_benefit: Optional[List[CdmProductBenefitTypeFamilyIncomeBenefit]] = None
    product_type_whole_of_life: Optional[List[CdmProductBenefitTypeWholeOfLife]] = None
    product_type_income_protection: Optional[List[CdmProductBenefitTypeIncomeProtection]] = None
    product_type_other: Optional[List[CdmProductBenefitTypeOther]] = None
    product_type_group_life: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_group_pmi: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_group_asu: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_group_cic: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_group_ip: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_group_private_medical_insurance: Optional[List[CdmProductBenefitTypePrivateMedicalInsurance]] = None
    product_type_relevant_life: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_key_man: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_pmi: Optional[List[CdmProductBenefitTypePmi]] = None
    product_type_shareholder_protection: Optional[List[CdmProductBenefitTypeGeneral]] = None
    product_type_core_accident_sickness: Optional[List[CdmProductBenefitTypeUnits]] = None
    product_type_child_accident_sickness: Optional[List[CdmProductBenefitTypeUnits]] = None
    product_type_sports_lifestyle: Optional[List[CdmProductBenefitTypeUnits]] = None
    product_type_specialist_healthcare_cover: Optional[List[CdmProductBenefitTypeUnits]] = None
    product_type_private_medical_insurance: Optional[List[CdmProductBenefitTypePrivateMedicalInsurance]] = None
    product_type_employee_benefit: Optional[List[CdmProductBenefitTypeEmployeeBenefit]] = None
    __properties: ClassVar[List[str]] = ["product_type_term", "product_type_family_income_benefit", "product_type_whole_of_life", "product_type_income_protection", "product_type_other", "product_type_group_life", "product_type_group_pmi", "product_type_group_asu", "product_type_group_cic", "product_type_group_ip", "product_type_group_private_medical_insurance", "product_type_relevant_life", "product_key_man", "product_type_pmi", "product_type_shareholder_protection", "product_type_core_accident_sickness", "product_type_child_accident_sickness", "product_type_sports_lifestyle", "product_type_specialist_healthcare_cover", "product_type_private_medical_insurance", "product_type_employee_benefit"]

    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 CdmProtectionProductBenefits 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 product_type_term (list)
        _items = []
        if self.product_type_term:
            for _item_product_type_term in self.product_type_term:
                if _item_product_type_term:
                    _items.append(_item_product_type_term.to_dict())
            _dict['product_type_term'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_family_income_benefit (list)
        _items = []
        if self.product_type_family_income_benefit:
            for _item_product_type_family_income_benefit in self.product_type_family_income_benefit:
                if _item_product_type_family_income_benefit:
                    _items.append(_item_product_type_family_income_benefit.to_dict())
            _dict['product_type_family_income_benefit'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_whole_of_life (list)
        _items = []
        if self.product_type_whole_of_life:
            for _item_product_type_whole_of_life in self.product_type_whole_of_life:
                if _item_product_type_whole_of_life:
                    _items.append(_item_product_type_whole_of_life.to_dict())
            _dict['product_type_whole_of_life'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_income_protection (list)
        _items = []
        if self.product_type_income_protection:
            for _item_product_type_income_protection in self.product_type_income_protection:
                if _item_product_type_income_protection:
                    _items.append(_item_product_type_income_protection.to_dict())
            _dict['product_type_income_protection'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_other (list)
        _items = []
        if self.product_type_other:
            for _item_product_type_other in self.product_type_other:
                if _item_product_type_other:
                    _items.append(_item_product_type_other.to_dict())
            _dict['product_type_other'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_life (list)
        _items = []
        if self.product_type_group_life:
            for _item_product_type_group_life in self.product_type_group_life:
                if _item_product_type_group_life:
                    _items.append(_item_product_type_group_life.to_dict())
            _dict['product_type_group_life'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_pmi (list)
        _items = []
        if self.product_type_group_pmi:
            for _item_product_type_group_pmi in self.product_type_group_pmi:
                if _item_product_type_group_pmi:
                    _items.append(_item_product_type_group_pmi.to_dict())
            _dict['product_type_group_pmi'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_asu (list)
        _items = []
        if self.product_type_group_asu:
            for _item_product_type_group_asu in self.product_type_group_asu:
                if _item_product_type_group_asu:
                    _items.append(_item_product_type_group_asu.to_dict())
            _dict['product_type_group_asu'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_cic (list)
        _items = []
        if self.product_type_group_cic:
            for _item_product_type_group_cic in self.product_type_group_cic:
                if _item_product_type_group_cic:
                    _items.append(_item_product_type_group_cic.to_dict())
            _dict['product_type_group_cic'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_ip (list)
        _items = []
        if self.product_type_group_ip:
            for _item_product_type_group_ip in self.product_type_group_ip:
                if _item_product_type_group_ip:
                    _items.append(_item_product_type_group_ip.to_dict())
            _dict['product_type_group_ip'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_group_private_medical_insurance (list)
        _items = []
        if self.product_type_group_private_medical_insurance:
            for _item_product_type_group_private_medical_insurance in self.product_type_group_private_medical_insurance:
                if _item_product_type_group_private_medical_insurance:
                    _items.append(_item_product_type_group_private_medical_insurance.to_dict())
            _dict['product_type_group_private_medical_insurance'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_relevant_life (list)
        _items = []
        if self.product_type_relevant_life:
            for _item_product_type_relevant_life in self.product_type_relevant_life:
                if _item_product_type_relevant_life:
                    _items.append(_item_product_type_relevant_life.to_dict())
            _dict['product_type_relevant_life'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_key_man (list)
        _items = []
        if self.product_key_man:
            for _item_product_key_man in self.product_key_man:
                if _item_product_key_man:
                    _items.append(_item_product_key_man.to_dict())
            _dict['product_key_man'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_pmi (list)
        _items = []
        if self.product_type_pmi:
            for _item_product_type_pmi in self.product_type_pmi:
                if _item_product_type_pmi:
                    _items.append(_item_product_type_pmi.to_dict())
            _dict['product_type_pmi'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_shareholder_protection (list)
        _items = []
        if self.product_type_shareholder_protection:
            for _item_product_type_shareholder_protection in self.product_type_shareholder_protection:
                if _item_product_type_shareholder_protection:
                    _items.append(_item_product_type_shareholder_protection.to_dict())
            _dict['product_type_shareholder_protection'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_core_accident_sickness (list)
        _items = []
        if self.product_type_core_accident_sickness:
            for _item_product_type_core_accident_sickness in self.product_type_core_accident_sickness:
                if _item_product_type_core_accident_sickness:
                    _items.append(_item_product_type_core_accident_sickness.to_dict())
            _dict['product_type_core_accident_sickness'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_child_accident_sickness (list)
        _items = []
        if self.product_type_child_accident_sickness:
            for _item_product_type_child_accident_sickness in self.product_type_child_accident_sickness:
                if _item_product_type_child_accident_sickness:
                    _items.append(_item_product_type_child_accident_sickness.to_dict())
            _dict['product_type_child_accident_sickness'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_sports_lifestyle (list)
        _items = []
        if self.product_type_sports_lifestyle:
            for _item_product_type_sports_lifestyle in self.product_type_sports_lifestyle:
                if _item_product_type_sports_lifestyle:
                    _items.append(_item_product_type_sports_lifestyle.to_dict())
            _dict['product_type_sports_lifestyle'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_specialist_healthcare_cover (list)
        _items = []
        if self.product_type_specialist_healthcare_cover:
            for _item_product_type_specialist_healthcare_cover in self.product_type_specialist_healthcare_cover:
                if _item_product_type_specialist_healthcare_cover:
                    _items.append(_item_product_type_specialist_healthcare_cover.to_dict())
            _dict['product_type_specialist_healthcare_cover'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_private_medical_insurance (list)
        _items = []
        if self.product_type_private_medical_insurance:
            for _item_product_type_private_medical_insurance in self.product_type_private_medical_insurance:
                if _item_product_type_private_medical_insurance:
                    _items.append(_item_product_type_private_medical_insurance.to_dict())
            _dict['product_type_private_medical_insurance'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in product_type_employee_benefit (list)
        _items = []
        if self.product_type_employee_benefit:
            for _item_product_type_employee_benefit in self.product_type_employee_benefit:
                if _item_product_type_employee_benefit:
                    _items.append(_item_product_type_employee_benefit.to_dict())
            _dict['product_type_employee_benefit'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "product_type_term": [CdmProductBenefitTypeTerm.from_dict(_item) for _item in obj["product_type_term"]] if obj.get("product_type_term") is not None else None,
            "product_type_family_income_benefit": [CdmProductBenefitTypeFamilyIncomeBenefit.from_dict(_item) for _item in obj["product_type_family_income_benefit"]] if obj.get("product_type_family_income_benefit") is not None else None,
            "product_type_whole_of_life": [CdmProductBenefitTypeWholeOfLife.from_dict(_item) for _item in obj["product_type_whole_of_life"]] if obj.get("product_type_whole_of_life") is not None else None,
            "product_type_income_protection": [CdmProductBenefitTypeIncomeProtection.from_dict(_item) for _item in obj["product_type_income_protection"]] if obj.get("product_type_income_protection") is not None else None,
            "product_type_other": [CdmProductBenefitTypeOther.from_dict(_item) for _item in obj["product_type_other"]] if obj.get("product_type_other") is not None else None,
            "product_type_group_life": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_group_life"]] if obj.get("product_type_group_life") is not None else None,
            "product_type_group_pmi": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_group_pmi"]] if obj.get("product_type_group_pmi") is not None else None,
            "product_type_group_asu": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_group_asu"]] if obj.get("product_type_group_asu") is not None else None,
            "product_type_group_cic": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_group_cic"]] if obj.get("product_type_group_cic") is not None else None,
            "product_type_group_ip": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_group_ip"]] if obj.get("product_type_group_ip") is not None else None,
            "product_type_group_private_medical_insurance": [CdmProductBenefitTypePrivateMedicalInsurance.from_dict(_item) for _item in obj["product_type_group_private_medical_insurance"]] if obj.get("product_type_group_private_medical_insurance") is not None else None,
            "product_type_relevant_life": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_relevant_life"]] if obj.get("product_type_relevant_life") is not None else None,
            "product_key_man": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_key_man"]] if obj.get("product_key_man") is not None else None,
            "product_type_pmi": [CdmProductBenefitTypePmi.from_dict(_item) for _item in obj["product_type_pmi"]] if obj.get("product_type_pmi") is not None else None,
            "product_type_shareholder_protection": [CdmProductBenefitTypeGeneral.from_dict(_item) for _item in obj["product_type_shareholder_protection"]] if obj.get("product_type_shareholder_protection") is not None else None,
            "product_type_core_accident_sickness": [CdmProductBenefitTypeUnits.from_dict(_item) for _item in obj["product_type_core_accident_sickness"]] if obj.get("product_type_core_accident_sickness") is not None else None,
            "product_type_child_accident_sickness": [CdmProductBenefitTypeUnits.from_dict(_item) for _item in obj["product_type_child_accident_sickness"]] if obj.get("product_type_child_accident_sickness") is not None else None,
            "product_type_sports_lifestyle": [CdmProductBenefitTypeUnits.from_dict(_item) for _item in obj["product_type_sports_lifestyle"]] if obj.get("product_type_sports_lifestyle") is not None else None,
            "product_type_specialist_healthcare_cover": [CdmProductBenefitTypeUnits.from_dict(_item) for _item in obj["product_type_specialist_healthcare_cover"]] if obj.get("product_type_specialist_healthcare_cover") is not None else None,
            "product_type_private_medical_insurance": [CdmProductBenefitTypePrivateMedicalInsurance.from_dict(_item) for _item in obj["product_type_private_medical_insurance"]] if obj.get("product_type_private_medical_insurance") is not None else None,
            "product_type_employee_benefit": [CdmProductBenefitTypeEmployeeBenefit.from_dict(_item) for _item in obj["product_type_employee_benefit"]] if obj.get("product_type_employee_benefit") is not None else None
        })
        return _obj


