# 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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.cdm_external import CdmExternal
from acre_api.models.cdm_note_assignee_type import CdmNoteAssigneeType
from acre_api.models.cdm_note_note_status import CdmNoteNoteStatus
from acre_api.models.cdm_note_note_type import CdmNoteNoteType
from acre_api.models.document_document_type import DocumentDocumentType
from acre_api.models.note_communication_type import NoteCommunicationType
from acre_api.models.note_event_note import NoteEventNote
from acre_api.models.note_ui_reference import NoteUiReference
from typing import Optional, Set
from typing_extensions import Self

class PartialDetailsOfTheNoteToBeUpdated(BaseModel):
    """
    PartialDetailsOfTheNoteToBeUpdated
    """ # noqa: E501
    created_at: Optional[StrictStr] = Field(default=None, description="The timestamp of when the note was created (RFC3339). **IMPORTANT:** This field cannot be updated and is populated automatically.")
    modified_at: Optional[StrictStr] = Field(default=None, description="The last time the note was updated (RFC3339). **IMPORTANT:** This field cannot be updated and is populated automatically.")
    title: Optional[StrictStr] = Field(default=None, description="A quick reference title for the note.")
    priority: Optional[StrictInt] = Field(default=None, description="Used by the frontend to determine the order in which the notes will appear.")
    status: Optional[CdmNoteNoteStatus] = CdmNoteNoteStatus.INVALID_NOTE_STATUS
    body: Optional[StrictStr] = Field(default=None, description="The note content.")
    primary_type: Optional[CdmNoteNoteType] = CdmNoteNoteType.INVALID_NOTE_TYPE
    deadline: Optional[StrictStr] = Field(default=None, description="When the action is due (RFC3339).")
    assignee_id: Optional[StrictStr] = Field(default=None, description="User, group or client to whom a given reminder is assigned.")
    assignee_type: Optional[CdmNoteAssigneeType] = CdmNoteAssigneeType.INVALID_ASSIGNEE_TYPE
    case_id: Optional[StrictStr] = Field(default=None, description="Case to which the note is linked to.")
    client_id: Optional[StrictStr] = Field(default=None, description="Client to whom the note is linked to.")
    property_id: Optional[StrictStr] = Field(default=None, description="Property to which the note is linked to.")
    mortgage_id: Optional[StrictStr] = Field(default=None, description="Mortgage to which the note is linked to.")
    verification_id: Optional[StrictStr] = Field(default=None, description="Verification to which the note is linked to. Must also provided at least case_id.")
    organisation_ids: Optional[List[StrictStr]] = Field(default=None, description="Organisations to which the note is linked to. It must always have at least 1 value and be set on note creation.  It's generally expected to be set to the organisation of the user creating the note. It doesn't default by the backend and a value must be set. **IMPORTANT:** This field cannot be updated.")
    created_by: Optional[StrictStr] = Field(default=None, description="The user id of the note's creator. **IMPORTANT:** This field cannot be updated and is populated automatically.")
    document_type_hint: Optional[DocumentDocumentType] = DocumentDocumentType.INVALID_DOCUMENT_TYPE
    communication_type: Optional[NoteCommunicationType] = NoteCommunicationType.INVALID_COMMUNICATION_TYPE
    event_note: Optional[NoteEventNote] = None
    template_id: Optional[StrictStr] = Field(default=None, description="Id of the organisational note template that applies to the note.")
    ui_reference: Optional[NoteUiReference] = None
    external: Optional[List[CdmExternal]] = Field(default=None, description="Identifiers for the note in third-party systems.")
    __properties: ClassVar[List[str]] = ["created_at", "modified_at", "title", "priority", "status", "body", "primary_type", "deadline", "assignee_id", "assignee_type", "case_id", "client_id", "property_id", "mortgage_id", "verification_id", "organisation_ids", "created_by", "document_type_hint", "communication_type", "event_note", "template_id", "ui_reference", "external"]

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

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

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

        _obj = cls.model_validate({
            "created_at": obj.get("created_at"),
            "modified_at": obj.get("modified_at"),
            "title": obj.get("title"),
            "priority": obj.get("priority"),
            "status": obj.get("status") if obj.get("status") is not None else CdmNoteNoteStatus.INVALID_NOTE_STATUS,
            "body": obj.get("body"),
            "primary_type": obj.get("primary_type") if obj.get("primary_type") is not None else CdmNoteNoteType.INVALID_NOTE_TYPE,
            "deadline": obj.get("deadline"),
            "assignee_id": obj.get("assignee_id"),
            "assignee_type": obj.get("assignee_type") if obj.get("assignee_type") is not None else CdmNoteAssigneeType.INVALID_ASSIGNEE_TYPE,
            "case_id": obj.get("case_id"),
            "client_id": obj.get("client_id"),
            "property_id": obj.get("property_id"),
            "mortgage_id": obj.get("mortgage_id"),
            "verification_id": obj.get("verification_id"),
            "organisation_ids": obj.get("organisation_ids"),
            "created_by": obj.get("created_by"),
            "document_type_hint": obj.get("document_type_hint") if obj.get("document_type_hint") is not None else DocumentDocumentType.INVALID_DOCUMENT_TYPE,
            "communication_type": obj.get("communication_type") if obj.get("communication_type") is not None else NoteCommunicationType.INVALID_COMMUNICATION_TYPE,
            "event_note": NoteEventNote.from_dict(obj["event_note"]) if obj.get("event_note") is not None else None,
            "template_id": obj.get("template_id"),
            "ui_reference": NoteUiReference.from_dict(obj["ui_reference"]) if obj.get("ui_reference") is not None else None,
            "external": [CdmExternal.from_dict(_item) for _item in obj["external"]] if obj.get("external") is not None else None
        })
        return _obj


