# 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, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.cdm_premium_frequency import CdmPremiumFrequency
from acre_api.models.cdm_sbg_provider_id import CdmSBGProviderID
from acre_api.models.cdm_specified_item import CdmSpecifiedItem
from acre_api.models.general_insurance_product_details_gi_product_status import GeneralInsuranceProductDetailsGIProductStatus
from acre_api.models.general_insurance_product_details_gi_product_type import GeneralInsuranceProductDetailsGIProductType
from acre_api.models.general_insurance_product_details_years_no_claims import GeneralInsuranceProductDetailsYearsNoClaims
from typing import Optional, Set
from typing_extensions import Self

class CdmGeneralInsuranceProductDetails(BaseModel):
    """
    General insurance product details.
    """ # noqa: E501
    quote_reference: Optional[StrictStr] = Field(default=None, description="Quote reference.")
    premium_amount: Optional[StrictStr] = Field(default=None, description="Premium amount for a general insurance product (in pence, not GBP).")
    premium_frequency: Optional[CdmPremiumFrequency] = CdmPremiumFrequency.INVALID_PREMIUM_FREQUENCY
    term: Optional[StrictInt] = Field(default=None, description="Product term, in months.")
    provider_id: Optional[CdmSBGProviderID] = CdmSBGProviderID.SBG_PROVIDER_ID_INVALID
    commission_sacrifice: Optional[StrictInt] = Field(default=None, description="The percentage of commission sacrificed for an insurance product.")
    status: Optional[GeneralInsuranceProductDetailsGIProductStatus] = GeneralInsuranceProductDetailsGIProductStatus.GI_PRODUCT_STATUS_INVALID
    buildings_cover_level: Optional[StrictStr] = Field(default=None, description="The level of cover, that applies to the building for this policy (in pence, not GBP).")
    contents_cover_level: Optional[StrictStr] = Field(default=None, description="The level of cover, that applies to the contents of a buildings for this policy (in pence, not GBP).")
    modified_at: Optional[StrictStr] = Field(default=None, description="The datetime that the product was last modified (RFC3339).")
    interest_rate: Optional[StrictInt] = Field(default=None, description="Interest rate on gi product, represented as 1/100000 of a percent (precision for up to 5 decimal places).")
    start_date: Optional[StrictStr] = Field(default=None, description="Start date of the general insurance (YYYY-MM-DD).")
    end_date: Optional[StrictStr] = Field(default=None, description="End date or renewal date of the general insurance (YYYY-MM-DD).")
    provider: Optional[StrictStr] = Field(default=None, description="Name of the GI provider.")
    excess: Optional[StrictInt] = Field(default=None, description="Amount of excess on the policy. Excess for contents cover if buildings and contents excess are separate (in pence, not GBP).")
    buildings_excess_if_different: Optional[StrictInt] = Field(default=None, description="Amount of excess on the policy for buildings cover if different from contents cover (see excess) (in pence, not GBP).")
    specified_rebuild_cost: Optional[StrictInt] = Field(default=None, description="Specified rebuild cost of the policy (in pence, not GBP).")
    includes_legal_cover: Optional[StrictBool] = Field(default=None, description="True if the policy includes legal cover.")
    legal_cover_premium: Optional[StrictInt] = Field(default=None, description="Legal cover premium (in pence, not GBP).")
    includes_accidental_damage: Optional[StrictBool] = Field(default=None, description="True if includes accidental damage.")
    accidental_damage_premium: Optional[StrictInt] = Field(default=None, description="Premium for accidental damage (in pence, not GBP).")
    policy_number: Optional[StrictStr] = Field(default=None, description="Policy number.")
    includes_personal_possessions_cover: Optional[StrictBool] = Field(default=None, description="True if includes personal possessions cover.")
    personal_possessions_sum_assured: Optional[StrictInt] = Field(default=None, description="Personal possessions sum assured (in pence, not GBP).")
    personal_possessions_premium: Optional[StrictInt] = Field(default=None, description="Personal possessions premium (in pence, not GBP).")
    includes_home_emergency_cover: Optional[StrictBool] = Field(default=None, description="True if includes home emergency cover.")
    home_emergency_premium: Optional[StrictInt] = Field(default=None, description="Home emergency premium (in pence, not GBP).")
    specified_items: Optional[List[CdmSpecifiedItem]] = Field(default=None, description="Specified items covered under the general insurance, for example clocks and furs.")
    years_no_claims: Optional[GeneralInsuranceProductDetailsYearsNoClaims] = GeneralInsuranceProductDetailsYearsNoClaims.INVALID_YEARS_NO_CLAIMS
    manufacture_of_drugs_cover: Optional[StrictBool] = Field(default=None, description="Includes manufacture of drugs cover.")
    manufacture_of_drugs_cover_premium: Optional[StrictInt] = Field(default=None, description="Manufacture of drugs cover premium (in pence, not GBP).")
    underwriter: Optional[StrictStr] = Field(default=None, description="Underwriter of the product.")
    type: Optional[GeneralInsuranceProductDetailsGIProductType] = GeneralInsuranceProductDetailsGIProductType.INVALID_GI_PRODUCT_TYPE
    annual_premium: Optional[StrictInt] = Field(default=None, description="Annual premium amount of the product (in pence, not GBP).")
    rental_cover: Optional[StrictInt] = Field(default=None, description="Rental cover of the product (in pence, not GBP).")
    commission: Optional[StrictInt] = Field(default=None, description="Commission of the product (in pence, not GBP).")
    buildings_years_no_claims_if_different: Optional[GeneralInsuranceProductDetailsYearsNoClaims] = GeneralInsuranceProductDetailsYearsNoClaims.INVALID_YEARS_NO_CLAIMS
    __properties: ClassVar[List[str]] = ["quote_reference", "premium_amount", "premium_frequency", "term", "provider_id", "commission_sacrifice", "status", "buildings_cover_level", "contents_cover_level", "modified_at", "interest_rate", "start_date", "end_date", "provider", "excess", "buildings_excess_if_different", "specified_rebuild_cost", "includes_legal_cover", "legal_cover_premium", "includes_accidental_damage", "accidental_damage_premium", "policy_number", "includes_personal_possessions_cover", "personal_possessions_sum_assured", "personal_possessions_premium", "includes_home_emergency_cover", "home_emergency_premium", "specified_items", "years_no_claims", "manufacture_of_drugs_cover", "manufacture_of_drugs_cover_premium", "underwriter", "type", "annual_premium", "rental_cover", "commission", "buildings_years_no_claims_if_different"]

    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 CdmGeneralInsuranceProductDetails 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 specified_items (list)
        _items = []
        if self.specified_items:
            for _item_specified_items in self.specified_items:
                if _item_specified_items:
                    _items.append(_item_specified_items.to_dict())
            _dict['specified_items'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "quote_reference": obj.get("quote_reference"),
            "premium_amount": obj.get("premium_amount"),
            "premium_frequency": obj.get("premium_frequency") if obj.get("premium_frequency") is not None else CdmPremiumFrequency.INVALID_PREMIUM_FREQUENCY,
            "term": obj.get("term"),
            "provider_id": obj.get("provider_id") if obj.get("provider_id") is not None else CdmSBGProviderID.SBG_PROVIDER_ID_INVALID,
            "commission_sacrifice": obj.get("commission_sacrifice"),
            "status": obj.get("status") if obj.get("status") is not None else GeneralInsuranceProductDetailsGIProductStatus.GI_PRODUCT_STATUS_INVALID,
            "buildings_cover_level": obj.get("buildings_cover_level"),
            "contents_cover_level": obj.get("contents_cover_level"),
            "modified_at": obj.get("modified_at"),
            "interest_rate": obj.get("interest_rate"),
            "start_date": obj.get("start_date"),
            "end_date": obj.get("end_date"),
            "provider": obj.get("provider"),
            "excess": obj.get("excess"),
            "buildings_excess_if_different": obj.get("buildings_excess_if_different"),
            "specified_rebuild_cost": obj.get("specified_rebuild_cost"),
            "includes_legal_cover": obj.get("includes_legal_cover"),
            "legal_cover_premium": obj.get("legal_cover_premium"),
            "includes_accidental_damage": obj.get("includes_accidental_damage"),
            "accidental_damage_premium": obj.get("accidental_damage_premium"),
            "policy_number": obj.get("policy_number"),
            "includes_personal_possessions_cover": obj.get("includes_personal_possessions_cover"),
            "personal_possessions_sum_assured": obj.get("personal_possessions_sum_assured"),
            "personal_possessions_premium": obj.get("personal_possessions_premium"),
            "includes_home_emergency_cover": obj.get("includes_home_emergency_cover"),
            "home_emergency_premium": obj.get("home_emergency_premium"),
            "specified_items": [CdmSpecifiedItem.from_dict(_item) for _item in obj["specified_items"]] if obj.get("specified_items") is not None else None,
            "years_no_claims": obj.get("years_no_claims") if obj.get("years_no_claims") is not None else GeneralInsuranceProductDetailsYearsNoClaims.INVALID_YEARS_NO_CLAIMS,
            "manufacture_of_drugs_cover": obj.get("manufacture_of_drugs_cover"),
            "manufacture_of_drugs_cover_premium": obj.get("manufacture_of_drugs_cover_premium"),
            "underwriter": obj.get("underwriter"),
            "type": obj.get("type") if obj.get("type") is not None else GeneralInsuranceProductDetailsGIProductType.INVALID_GI_PRODUCT_TYPE,
            "annual_premium": obj.get("annual_premium"),
            "rental_cover": obj.get("rental_cover"),
            "commission": obj.get("commission"),
            "buildings_years_no_claims_if_different": obj.get("buildings_years_no_claims_if_different") if obj.get("buildings_years_no_claims_if_different") is not None else GeneralInsuranceProductDetailsYearsNoClaims.INVALID_YEARS_NO_CLAIMS
        })
        return _obj


