# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.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
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class ResultCardProperties(BaseModel):
    """
    Properties for result card display configuration.
    """ # noqa: E501
    layout: Optional[StrictStr] = Field(default='vertical', description="Card layout orientation")
    show_thumbnail: Optional[StrictBool] = Field(default=True, description="Whether to show thumbnail image in results")
    thumbnail_aspect_ratio: Optional[StrictStr] = Field(default='16/9', description="Aspect ratio for thumbnail images")
    thumbnail_fit: Optional[StrictStr] = Field(default='cover', description="How thumbnail should fit in container")
    show_score: Optional[StrictBool] = Field(default=False, description="Whether to display relevance score")
    truncate_title: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Maximum characters for title before truncation")
    truncate_description: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Maximum characters for description before truncation")
    field_order: Optional[List[StrictStr]] = Field(default=None, description="Order of fields to display in result card. Fields not in this list won't be shown. Must be subset of exposed_fields.")
    show_find_similar: Optional[StrictBool] = Field(default=False, description="Whether to show a 'Find Similar' button on result cards")
    card_click_action: Optional[StrictStr] = Field(default='viewDetails', description="Action when card is clicked: none (no action), findSimilar (trigger similar search), viewDetails (open detail modal)")
    thumbnail_field: Optional[StrictStr] = Field(default=None, description="Field name to use as thumbnail image source")
    title_field: Optional[StrictStr] = Field(default=None, description="Field name to use as card title")
    card_fields: Optional[List[StrictStr]] = Field(default=None, description="Fields to display on the card (alternative to field_order for template compatibility)")
    modal_fields: Optional[List[StrictStr]] = Field(default=None, description="Fields to display in the detail modal when card is clicked")
    card_style: Optional[StrictStr] = Field(default='default', description="Card style preset: default, portrait-discovery, media-search, document-search, or custom template-specific styles")
    __properties: ClassVar[List[str]] = ["layout", "show_thumbnail", "thumbnail_aspect_ratio", "thumbnail_fit", "show_score", "truncate_title", "truncate_description", "field_order", "show_find_similar", "card_click_action", "thumbnail_field", "title_field", "card_fields", "modal_fields", "card_style"]

    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 ResultCardProperties 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "layout": obj.get("layout") if obj.get("layout") is not None else 'vertical',
            "show_thumbnail": obj.get("show_thumbnail") if obj.get("show_thumbnail") is not None else True,
            "thumbnail_aspect_ratio": obj.get("thumbnail_aspect_ratio") if obj.get("thumbnail_aspect_ratio") is not None else '16/9',
            "thumbnail_fit": obj.get("thumbnail_fit") if obj.get("thumbnail_fit") is not None else 'cover',
            "show_score": obj.get("show_score") if obj.get("show_score") is not None else False,
            "truncate_title": obj.get("truncate_title"),
            "truncate_description": obj.get("truncate_description"),
            "field_order": obj.get("field_order"),
            "show_find_similar": obj.get("show_find_similar") if obj.get("show_find_similar") is not None else False,
            "card_click_action": obj.get("card_click_action") if obj.get("card_click_action") is not None else 'viewDetails',
            "thumbnail_field": obj.get("thumbnail_field"),
            "title_field": obj.get("title_field"),
            "card_fields": obj.get("card_fields"),
            "modal_fields": obj.get("modal_fields"),
            "card_style": obj.get("card_style") if obj.get("card_style") is not None else 'default'
        })
        return _obj


