# 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, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.side_image_settings import SideImageSettings
from typing import Optional, Set
from typing_extensions import Self

class VersionProperties(BaseModel):
    """
    VersionProperties
    """ # noqa: E501
    side_image_settings: Optional[SideImageSettings] = None
    click_outside_to_close: Optional[List[StrictStr]] = None
    rule_based_trigger_evaluation: Optional[StrictStr] = Field(default='any', description="Side image alignment enumeration.")
    record_utm_params_on_submit: Optional[StrictBool] = False
    show_close_button: Optional[StrictBool] = True
    __properties: ClassVar[List[str]] = ["side_image_settings", "click_outside_to_close", "rule_based_trigger_evaluation", "record_utm_params_on_submit", "show_close_button"]

    @field_validator('click_outside_to_close')
    def click_outside_to_close_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        for i in value:
            if i not in set(['both', 'desktop', 'mobile']):
                raise ValueError("each list item must be one of ('both', 'desktop', 'mobile')")
        return value

    @field_validator('rule_based_trigger_evaluation')
    def rule_based_trigger_evaluation_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['all', 'any']):
            raise ValueError("must be one of enum values ('all', 'any')")
        return value

    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 VersionProperties 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 side_image_settings
        if self.side_image_settings:
            _dict['side_image_settings'] = self.side_image_settings.to_dict()
        # set to None if click_outside_to_close (nullable) is None
        # and model_fields_set contains the field
        if self.click_outside_to_close is None and "click_outside_to_close" in self.model_fields_set:
            _dict['click_outside_to_close'] = None

        # set to None if rule_based_trigger_evaluation (nullable) is None
        # and model_fields_set contains the field
        if self.rule_based_trigger_evaluation is None and "rule_based_trigger_evaluation" in self.model_fields_set:
            _dict['rule_based_trigger_evaluation'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "side_image_settings": SideImageSettings.from_dict(obj["side_image_settings"]) if obj.get("side_image_settings") is not None else None,
            "click_outside_to_close": obj.get("click_outside_to_close"),
            "rule_based_trigger_evaluation": obj.get("rule_based_trigger_evaluation") if obj.get("rule_based_trigger_evaluation") is not None else 'any',
            "record_utm_params_on_submit": obj.get("record_utm_params_on_submit") if obj.get("record_utm_params_on_submit") is not None else False,
            "show_close_button": obj.get("show_close_button") if obj.get("show_close_button") is not None else True
        })
        return _obj


