# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.cdm_mortgage_totals import CdmMortgageTotals
from typing import Optional, Set
from typing_extensions import Self

class CdmCaseCalculatedValues(BaseModel):
    """
    CdmCaseCalculatedValues
    """ # noqa: E501
    current_mortgage_comparison_cost: Optional[StrictStr] = Field(default=None, description="This is the cost of staying on the existing mortgage.  If there is more than one current mortgage, this will be the addition of the cost of all the mortgages.")
    lender_proposed_comparison_cost: Optional[StrictStr] = Field(default=None, description="This is the cost of the lender proposed mortgage.")
    selected_mortgage_comparison_cost: Optional[StrictStr] = Field(default=None, description="This is the cost of the selected mortgage.  If any of the current mortgages are marked as continuing (Porting), their monthly payments will be included in the calculation and some charges will be skipped for them.")
    selected_mortgage_extra_comparison_cost: Optional[StrictStr] = Field(default=None, description="This is the extra cost of the selected mortgage, without taking into account the continuing mortgages monthly payments.  This calculation is only run if assumes_continuing is not empty, as otherwise the value would be the same as selected_mortgage_comparison_cost. If any of the current mortgages are marked as continuing (Porting), some charges will be skipped for them in the calculation.")
    total_required_loan_amount: Optional[StrictStr] = None
    total_additional_borrowing: Optional[StrictStr] = None
    current_totals: Optional[CdmMortgageTotals] = None
    selected_totals: Optional[CdmMortgageTotals] = None
    __properties: ClassVar[List[str]] = ["current_mortgage_comparison_cost", "lender_proposed_comparison_cost", "selected_mortgage_comparison_cost", "selected_mortgage_extra_comparison_cost", "total_required_loan_amount", "total_additional_borrowing", "current_totals", "selected_totals"]

    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 CdmCaseCalculatedValues 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 current_totals
        if self.current_totals:
            _dict['current_totals'] = self.current_totals.to_dict()
        # override the default output from pydantic by calling `to_dict()` of selected_totals
        if self.selected_totals:
            _dict['selected_totals'] = self.selected_totals.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "current_mortgage_comparison_cost": obj.get("current_mortgage_comparison_cost"),
            "lender_proposed_comparison_cost": obj.get("lender_proposed_comparison_cost"),
            "selected_mortgage_comparison_cost": obj.get("selected_mortgage_comparison_cost"),
            "selected_mortgage_extra_comparison_cost": obj.get("selected_mortgage_extra_comparison_cost"),
            "total_required_loan_amount": obj.get("total_required_loan_amount"),
            "total_additional_borrowing": obj.get("total_additional_borrowing"),
            "current_totals": CdmMortgageTotals.from_dict(obj["current_totals"]) if obj.get("current_totals") is not None else None,
            "selected_totals": CdmMortgageTotals.from_dict(obj["selected_totals"]) if obj.get("selected_totals") is not None else None
        })
        return _obj


