# 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_address import CdmAddress
from acre_api.models.cdm_client_employment_income_employment_basis import CdmClientEmploymentIncomeEmploymentBasis
from acre_api.models.cdm_client_income_detail import CdmClientIncomeDetail
from acre_api.models.client_employment_income_employment_type import ClientEmploymentIncomeEmploymentType
from typing import Optional, Set
from typing_extensions import Self

class CdmClientEmploymentIncome(BaseModel):
    """
    CdmClientEmploymentIncome
    """ # noqa: E501
    job_title: Optional[StrictStr] = Field(default=None, description="DEPRECATED: standardised_occupation_code or occupation_title should be used instead. Client's job title.")
    employment_type: Optional[ClientEmploymentIncomeEmploymentType] = ClientEmploymentIncomeEmploymentType.INVALID_EMPLOYMENT_TYPE
    employment_start_date: Optional[StrictStr] = Field(default=None, description="The employment start date (YYYY-MM-DD).")
    employment_end_date: Optional[StrictStr] = Field(default=None, description="The employment end date (YYYY-MM-DD).")
    no_other_recent_employment: Optional[StrictBool] = Field(default=None, description="If the start date is in the last two years; has the individual not been otherwise employed in the last ten years.")
    employer_name: Optional[StrictStr] = Field(default=None, description="The employer's name.")
    will_contract_be_renewed: Optional[StrictBool] = Field(default=None, description="Flag indicating whether the contract will be renewed.")
    contract_renewal_details: Optional[StrictStr] = Field(default=None, description="Additional details on the contract renewal.")
    time_in_industry_years: Optional[StrictInt] = Field(default=None, description="The number of years the applicant has been in the industry.")
    time_contracting_months: Optional[StrictInt] = Field(default=None, description="The number of months the applicant has been contracting.")
    on_probation: Optional[StrictBool] = Field(default=None, description="Flag indicating whether the individual is on probation.")
    probation_details: Optional[StrictStr] = Field(default=None, description="Additional details on the probation.")
    shareholding_percentage: Optional[StrictInt] = Field(default=None, description="The percentage shareholding in the company, represented as 1/100000 of a percent (precision for up to 5 decimal places).")
    months_in_continuous_employment: Optional[StrictInt] = Field(default=None, description="How long in months applicant has been in continuous employment.")
    employer_address: Optional[CdmAddress] = None
    employer_work_phone: Optional[StrictStr] = Field(default=None, description="Employer's work phone number.")
    employer_mobile_phone: Optional[StrictStr] = Field(default=None, description="Employer's mobile phone number.")
    employer_email: Optional[StrictStr] = Field(default=None, description="Employer's email address.")
    employer_alternate_email: Optional[StrictStr] = Field(default=None, description="Employer's alternate email address.")
    incomes: Optional[List[CdmClientIncomeDetail]] = Field(default=None, description="Details of income client earned in this employment.")
    total_guaranteed_annual: Optional[StrictStr] = Field(default=None, description="Total amount of guaranteed income. **IMPORTANT:** This field cannot be updated and is populated automatically.")
    total_additional_annual: Optional[StrictStr] = Field(default=None, description="Total amount of non guaranteed income. **IMPORTANT:** This field cannot be updated and is populated automatically.  DEPRECATED: due to percentage conversion to 5 decimal places.  string shareholding_percentage = 13;")
    employment_basis: Optional[CdmClientEmploymentIncomeEmploymentBasis] = CdmClientEmploymentIncomeEmploymentBasis.INVALID_EMPLOYED_BASIS
    __properties: ClassVar[List[str]] = ["job_title", "employment_type", "employment_start_date", "employment_end_date", "no_other_recent_employment", "employer_name", "will_contract_be_renewed", "contract_renewal_details", "time_in_industry_years", "time_contracting_months", "on_probation", "probation_details", "shareholding_percentage", "months_in_continuous_employment", "employer_address", "employer_work_phone", "employer_mobile_phone", "employer_email", "employer_alternate_email", "incomes", "total_guaranteed_annual", "total_additional_annual", "employment_basis"]

    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 CdmClientEmploymentIncome 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 employer_address
        if self.employer_address:
            _dict['employer_address'] = self.employer_address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in incomes (list)
        _items = []
        if self.incomes:
            for _item_incomes in self.incomes:
                if _item_incomes:
                    _items.append(_item_incomes.to_dict())
            _dict['incomes'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "job_title": obj.get("job_title"),
            "employment_type": obj.get("employment_type") if obj.get("employment_type") is not None else ClientEmploymentIncomeEmploymentType.INVALID_EMPLOYMENT_TYPE,
            "employment_start_date": obj.get("employment_start_date"),
            "employment_end_date": obj.get("employment_end_date"),
            "no_other_recent_employment": obj.get("no_other_recent_employment"),
            "employer_name": obj.get("employer_name"),
            "will_contract_be_renewed": obj.get("will_contract_be_renewed"),
            "contract_renewal_details": obj.get("contract_renewal_details"),
            "time_in_industry_years": obj.get("time_in_industry_years"),
            "time_contracting_months": obj.get("time_contracting_months"),
            "on_probation": obj.get("on_probation"),
            "probation_details": obj.get("probation_details"),
            "shareholding_percentage": obj.get("shareholding_percentage"),
            "months_in_continuous_employment": obj.get("months_in_continuous_employment"),
            "employer_address": CdmAddress.from_dict(obj["employer_address"]) if obj.get("employer_address") is not None else None,
            "employer_work_phone": obj.get("employer_work_phone"),
            "employer_mobile_phone": obj.get("employer_mobile_phone"),
            "employer_email": obj.get("employer_email"),
            "employer_alternate_email": obj.get("employer_alternate_email"),
            "incomes": [CdmClientIncomeDetail.from_dict(_item) for _item in obj["incomes"]] if obj.get("incomes") is not None else None,
            "total_guaranteed_annual": obj.get("total_guaranteed_annual"),
            "total_additional_annual": obj.get("total_additional_annual"),
            "employment_basis": obj.get("employment_basis") if obj.get("employment_basis") is not None else CdmClientEmploymentIncomeEmploymentBasis.INVALID_EMPLOYED_BASIS
        })
        return _obj


