# coding: utf-8

"""
    Klaviyo API

    The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.

    Contact: developers@klaviyo.com
    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
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.link_styles import LinkStyles
from openapi_client.models.rich_text_style import RichTextStyle
from typing import Optional, Set
from typing_extensions import Self

class RichTextStyles(BaseModel):
    """
    RichTextStyles
    """ # noqa: E501
    body: Optional[RichTextStyle] = None
    link: Optional[LinkStyles] = None
    h1: Optional[RichTextStyle] = None
    h2: Optional[RichTextStyle] = None
    h3: Optional[RichTextStyle] = None
    h4: Optional[RichTextStyle] = None
    h5: Optional[RichTextStyle] = None
    h6: Optional[RichTextStyle] = None
    __properties: ClassVar[List[str]] = ["body", "link", "h1", "h2", "h3", "h4", "h5", "h6"]

    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 RichTextStyles 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 body
        if self.body:
            _dict['body'] = self.body.to_dict()
        # override the default output from pydantic by calling `to_dict()` of link
        if self.link:
            _dict['link'] = self.link.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h1
        if self.h1:
            _dict['h1'] = self.h1.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h2
        if self.h2:
            _dict['h2'] = self.h2.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h3
        if self.h3:
            _dict['h3'] = self.h3.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h4
        if self.h4:
            _dict['h4'] = self.h4.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h5
        if self.h5:
            _dict['h5'] = self.h5.to_dict()
        # override the default output from pydantic by calling `to_dict()` of h6
        if self.h6:
            _dict['h6'] = self.h6.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "body": RichTextStyle.from_dict(obj["body"]) if obj.get("body") is not None else None,
            "link": LinkStyles.from_dict(obj["link"]) if obj.get("link") is not None else None,
            "h1": RichTextStyle.from_dict(obj["h1"]) if obj.get("h1") is not None else None,
            "h2": RichTextStyle.from_dict(obj["h2"]) if obj.get("h2") is not None else None,
            "h3": RichTextStyle.from_dict(obj["h3"]) if obj.get("h3") is not None else None,
            "h4": RichTextStyle.from_dict(obj["h4"]) if obj.get("h4") is not None else None,
            "h5": RichTextStyle.from_dict(obj["h5"]) if obj.get("h5") is not None else None,
            "h6": RichTextStyle.from_dict(obj["h6"]) if obj.get("h6") is not None else None
        })
        return _obj


