# 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_delete_reason import CdmDeleteReason
from acre_api.models.cdm_document_metadata import CdmDocumentMetadata
from acre_api.models.cdm_file_type import CdmFileType
from acre_api.models.cdm_template_name import CdmTemplateName
from acre_api.models.document_document_source_type import DocumentDocumentSourceType
from acre_api.models.document_document_type import DocumentDocumentType
from typing import Optional, Set
from typing_extensions import Self

class PartialDetailsOfTheDocumentToBePatchedRequired(BaseModel):
    """
    PartialDetailsOfTheDocumentToBePatchedRequired
    """ # noqa: E501
    date_stored: Optional[StrictStr] = Field(default=None, description="Date when this document was generated/uploaded/received (RFC3339). **IMPORTANT:** This field cannot be updated and is populated automatically.")
    document_date: Optional[StrictStr] = None
    type: Optional[DocumentDocumentType] = DocumentDocumentType.INVALID_DOCUMENT_TYPE
    document_object_reference: Optional[StrictStr] = Field(default=None, description="The reference to the document storage location if this document is received/uploaded. **IMPORTANT:** This field cannot be updated.")
    template_id: Optional[StrictStr] = Field(default=None, description="If document is generated, template used to generate. **IMPORTANT:** This field cannot be updated and is populated automatically.")
    template_type: Optional[CdmTemplateName] = CdmTemplateName.INVALID_TEMPLATE_NAME
    template_sub_type: Optional[StrictStr] = Field(default=None, description="The template sub_type if applicable. Must be in SNAKE_CASE format.")
    metadata_version: Optional[Dict[str, StrictStr]] = Field(default=None, description="Reference to the metadata used to generate this document.**IMPORTANT:** This field cannot be updated and is populated automatically.")
    document_signature: Optional[StrictStr] = Field(default=None, description="A cryptographic signature of the document. **IMPORTANT:** This field cannot be updated and is populated automatically.")
    signature_key_id: Optional[StrictStr] = Field(default=None, description="The identifier of the key used to generate the document signature. **IMPORTANT:** This field cannot be updated and is populated automatically.")
    source: Optional[DocumentDocumentSourceType] = DocumentDocumentSourceType.INVALID_DOCUMENT_SOURCE_TYPE
    source_user_id: Optional[StrictStr] = Field(default=None, description="If a user uploaded this document or triggered its generation.  The identifier of said user. **IMPORTANT:** This field cannot be updated.")
    source_client_id: Optional[StrictStr] = Field(default=None, description="If a client uploaded this document. The identifier of said client. **IMPORTANT:** This field cannot be updated.")
    owning_client_ids: Optional[List[StrictStr]] = Field(default=None, description="Documents provided by a client, even if uploaded by a user, still belong to a client. Provides one mechanism of access control. A document may be owned by multiple clients. **IMPORTANT:** This field cannot be updated.")
    origination_fingerprint: Optional[Dict[str, StrictStr]] = Field(default=None, description="Metadata to trace the source of a document. **IMPORTANT:** This field cannot be updated.")
    document_expiry: Optional[StrictStr] = Field(default=None, description="The expiry date of the document. **IMPORTANT:** This field cannot be updated.")
    data_base64: Optional[StrictStr] = Field(default=None, description="The base64 encoded document. **IMPORTANT:** This field cannot be updated.")
    file_type: Optional[CdmFileType] = CdmFileType.INVALID_FILE_TYPE
    archived: Optional[StrictBool] = Field(default=None, description="Whether the document is archived. This field can be updated.")
    document_name: Optional[StrictStr] = Field(default=None, description="Name of the document. This field can be updated.")
    tags: Optional[List[StrictStr]] = Field(default=None, description="Tags associated with the document. This field can be updated.")
    rendered_organisation_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered organisation IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_user_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered user IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_client_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered client IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_case_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered case IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_mortgage_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered mortgage IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_product_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered product IDs, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_note_ids: Optional[List[StrictStr]] = Field(default=None, description="Rendered note IDs, when generated from a template. **IMPORTANT** This field cannot be updated.")
    rendered_compliance_email_recipients: Optional[List[StrictStr]] = Field(default=None, description="Rendered compliance email recipients, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    rendered_compliance_email_subject: Optional[StrictStr] = Field(default=None, description="Rendered compliance email subject, when generated from a template. **IMPORTANT:** This field cannot be updated.")
    verification_count: Optional[StrictInt] = Field(default=None, description="Number of verifications associated with this document. This field cannot be updated/set directly, and is populated by the backend automatically. **IMPORTANT:** This field cannot be updated.")
    case_ids: Optional[List[StrictStr]] = Field(default=None, description="Cases associated with this document. Note: can only be updated through Add / Delete case document endpoints.")
    other_type: Optional[StrictStr] = Field(default=None, description="Some other document type. Set if and only if type is OTHER.")
    metadata: Optional[CdmDocumentMetadata] = None
    delete_reason: Optional[CdmDeleteReason] = CdmDeleteReason.INVALID_DELETE_REASON
    __properties: ClassVar[List[str]] = ["date_stored", "document_date", "type", "document_object_reference", "template_id", "template_type", "template_sub_type", "metadata_version", "document_signature", "signature_key_id", "source", "source_user_id", "source_client_id", "owning_client_ids", "origination_fingerprint", "document_expiry", "data_base64", "file_type", "archived", "document_name", "tags", "rendered_organisation_ids", "rendered_user_ids", "rendered_client_ids", "rendered_case_ids", "rendered_mortgage_ids", "rendered_product_ids", "rendered_note_ids", "rendered_compliance_email_recipients", "rendered_compliance_email_subject", "verification_count", "case_ids", "other_type", "metadata", "delete_reason"]

    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 PartialDetailsOfTheDocumentToBePatchedRequired 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 metadata
        if self.metadata:
            _dict['metadata'] = self.metadata.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "date_stored": obj.get("date_stored"),
            "document_date": obj.get("document_date"),
            "type": obj.get("type") if obj.get("type") is not None else DocumentDocumentType.INVALID_DOCUMENT_TYPE,
            "document_object_reference": obj.get("document_object_reference"),
            "template_id": obj.get("template_id"),
            "template_type": obj.get("template_type") if obj.get("template_type") is not None else CdmTemplateName.INVALID_TEMPLATE_NAME,
            "template_sub_type": obj.get("template_sub_type"),
            "metadata_version": obj.get("metadata_version"),
            "document_signature": obj.get("document_signature"),
            "signature_key_id": obj.get("signature_key_id"),
            "source": obj.get("source") if obj.get("source") is not None else DocumentDocumentSourceType.INVALID_DOCUMENT_SOURCE_TYPE,
            "source_user_id": obj.get("source_user_id"),
            "source_client_id": obj.get("source_client_id"),
            "owning_client_ids": obj.get("owning_client_ids"),
            "origination_fingerprint": obj.get("origination_fingerprint"),
            "document_expiry": obj.get("document_expiry"),
            "data_base64": obj.get("data_base64"),
            "file_type": obj.get("file_type") if obj.get("file_type") is not None else CdmFileType.INVALID_FILE_TYPE,
            "archived": obj.get("archived"),
            "document_name": obj.get("document_name"),
            "tags": obj.get("tags"),
            "rendered_organisation_ids": obj.get("rendered_organisation_ids"),
            "rendered_user_ids": obj.get("rendered_user_ids"),
            "rendered_client_ids": obj.get("rendered_client_ids"),
            "rendered_case_ids": obj.get("rendered_case_ids"),
            "rendered_mortgage_ids": obj.get("rendered_mortgage_ids"),
            "rendered_product_ids": obj.get("rendered_product_ids"),
            "rendered_note_ids": obj.get("rendered_note_ids"),
            "rendered_compliance_email_recipients": obj.get("rendered_compliance_email_recipients"),
            "rendered_compliance_email_subject": obj.get("rendered_compliance_email_subject"),
            "verification_count": obj.get("verification_count"),
            "case_ids": obj.get("case_ids"),
            "other_type": obj.get("other_type"),
            "metadata": CdmDocumentMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None,
            "delete_reason": obj.get("delete_reason") if obj.get("delete_reason") is not None else CdmDeleteReason.INVALID_DELETE_REASON
        })
        return _obj


