# coding: utf-8

"""
Immich

Immich API

The version of the OpenAPI document: 2.4.1
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
from typing import Any, ClassVar, Dict, List, Optional
from immich.client.models.albums_update import AlbumsUpdate
from immich.client.models.avatar_update import AvatarUpdate
from immich.client.models.cast_update import CastUpdate
from immich.client.models.download_update import DownloadUpdate
from immich.client.models.email_notifications_update import EmailNotificationsUpdate
from immich.client.models.folders_update import FoldersUpdate
from immich.client.models.memories_update import MemoriesUpdate
from immich.client.models.people_update import PeopleUpdate
from immich.client.models.purchase_update import PurchaseUpdate
from immich.client.models.ratings_update import RatingsUpdate
from immich.client.models.shared_links_update import SharedLinksUpdate
from immich.client.models.tags_update import TagsUpdate
from typing import Set
from typing_extensions import Self


class UserPreferencesUpdateDto(BaseModel):
    """
    UserPreferencesUpdateDto
    """  # noqa: E501

    albums: Optional[AlbumsUpdate] = None
    avatar: Optional[AvatarUpdate] = None
    cast: Optional[CastUpdate] = None
    download: Optional[DownloadUpdate] = None
    email_notifications: Optional[EmailNotificationsUpdate] = Field(
        default=None, alias="emailNotifications"
    )
    folders: Optional[FoldersUpdate] = None
    memories: Optional[MemoriesUpdate] = None
    people: Optional[PeopleUpdate] = None
    purchase: Optional[PurchaseUpdate] = None
    ratings: Optional[RatingsUpdate] = None
    shared_links: Optional[SharedLinksUpdate] = Field(default=None, alias="sharedLinks")
    tags: Optional[TagsUpdate] = None
    __properties: ClassVar[List[str]] = [
        "albums",
        "avatar",
        "cast",
        "download",
        "emailNotifications",
        "folders",
        "memories",
        "people",
        "purchase",
        "ratings",
        "sharedLinks",
        "tags",
    ]

    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 UserPreferencesUpdateDto 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 albums
        if self.albums:
            _dict["albums"] = self.albums.to_dict()
        # override the default output from pydantic by calling `to_dict()` of avatar
        if self.avatar:
            _dict["avatar"] = self.avatar.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cast
        if self.cast:
            _dict["cast"] = self.cast.to_dict()
        # override the default output from pydantic by calling `to_dict()` of download
        if self.download:
            _dict["download"] = self.download.to_dict()
        # override the default output from pydantic by calling `to_dict()` of email_notifications
        if self.email_notifications:
            _dict["emailNotifications"] = self.email_notifications.to_dict()
        # override the default output from pydantic by calling `to_dict()` of folders
        if self.folders:
            _dict["folders"] = self.folders.to_dict()
        # override the default output from pydantic by calling `to_dict()` of memories
        if self.memories:
            _dict["memories"] = self.memories.to_dict()
        # override the default output from pydantic by calling `to_dict()` of people
        if self.people:
            _dict["people"] = self.people.to_dict()
        # override the default output from pydantic by calling `to_dict()` of purchase
        if self.purchase:
            _dict["purchase"] = self.purchase.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ratings
        if self.ratings:
            _dict["ratings"] = self.ratings.to_dict()
        # override the default output from pydantic by calling `to_dict()` of shared_links
        if self.shared_links:
            _dict["sharedLinks"] = self.shared_links.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tags
        if self.tags:
            _dict["tags"] = self.tags.to_dict()
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "albums": AlbumsUpdate.from_dict(obj["albums"])
                if obj.get("albums") is not None
                else None,
                "avatar": AvatarUpdate.from_dict(obj["avatar"])
                if obj.get("avatar") is not None
                else None,
                "cast": CastUpdate.from_dict(obj["cast"])
                if obj.get("cast") is not None
                else None,
                "download": DownloadUpdate.from_dict(obj["download"])
                if obj.get("download") is not None
                else None,
                "emailNotifications": EmailNotificationsUpdate.from_dict(
                    obj["emailNotifications"]
                )
                if obj.get("emailNotifications") is not None
                else None,
                "folders": FoldersUpdate.from_dict(obj["folders"])
                if obj.get("folders") is not None
                else None,
                "memories": MemoriesUpdate.from_dict(obj["memories"])
                if obj.get("memories") is not None
                else None,
                "people": PeopleUpdate.from_dict(obj["people"])
                if obj.get("people") is not None
                else None,
                "purchase": PurchaseUpdate.from_dict(obj["purchase"])
                if obj.get("purchase") is not None
                else None,
                "ratings": RatingsUpdate.from_dict(obj["ratings"])
                if obj.get("ratings") is not None
                else None,
                "sharedLinks": SharedLinksUpdate.from_dict(obj["sharedLinks"])
                if obj.get("sharedLinks") is not None
                else None,
                "tags": TagsUpdate.from_dict(obj["tags"])
                if obj.get("tags") is not None
                else None,
            }
        )
        return _obj
