# 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 FieldFormatOptions(BaseModel):
    """
    Format-specific options for field display.  Different format types support different options: - text: label, truncate_chars, show_empty - image: width, height, lazy_load, aspect_ratio, object_fit - date: label, date_format (iso, relative, custom) - number: label, decimals, prefix, suffix, show_empty - url: label, open_in_new_tab, show_domain - boolean: label, true_label, false_label - array: label, separator, max_items
    """ # noqa: E501
    label: Optional[StrictStr] = Field(default=None, description="Display label for this field")
    show_empty: Optional[StrictBool] = Field(default=True, description="Whether to show the field if value is empty/null")
    truncate_chars: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Maximum characters before truncation (for text fields)")
    width: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Image width in pixels")
    height: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Image height in pixels")
    lazy_load: Optional[StrictBool] = Field(default=True, description="Enable lazy loading for images (default: true)")
    aspect_ratio: Optional[StrictStr] = Field(default=None, description="Aspect ratio for image container")
    object_fit: Optional[StrictStr] = Field(default='cover', description="CSS object-fit property for images")
    date_format: Optional[StrictStr] = Field(default='relative', description="Date format type: 'iso', 'relative', or custom format string")
    decimals: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="Number of decimal places")
    prefix: Optional[StrictStr] = Field(default=None, description="Prefix for number display")
    suffix: Optional[StrictStr] = Field(default=None, description="Suffix for number display")
    open_in_new_tab: Optional[StrictBool] = Field(default=True, description="Open URLs in new tab (default: true)")
    show_domain: Optional[StrictBool] = Field(default=False, description="Show domain instead of full URL")
    true_label: Optional[StrictStr] = Field(default='Yes', description="Label for true values")
    false_label: Optional[StrictStr] = Field(default='No', description="Label for false values")
    separator: Optional[StrictStr] = Field(default=', ', description="Separator for array items (default: ', ')")
    max_items: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Maximum array items to display")
    __properties: ClassVar[List[str]] = ["label", "show_empty", "truncate_chars", "width", "height", "lazy_load", "aspect_ratio", "object_fit", "date_format", "decimals", "prefix", "suffix", "open_in_new_tab", "show_domain", "true_label", "false_label", "separator", "max_items"]

    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 FieldFormatOptions 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 FieldFormatOptions from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "label": obj.get("label"),
            "show_empty": obj.get("show_empty") if obj.get("show_empty") is not None else True,
            "truncate_chars": obj.get("truncate_chars"),
            "width": obj.get("width"),
            "height": obj.get("height"),
            "lazy_load": obj.get("lazy_load") if obj.get("lazy_load") is not None else True,
            "aspect_ratio": obj.get("aspect_ratio"),
            "object_fit": obj.get("object_fit") if obj.get("object_fit") is not None else 'cover',
            "date_format": obj.get("date_format") if obj.get("date_format") is not None else 'relative',
            "decimals": obj.get("decimals"),
            "prefix": obj.get("prefix"),
            "suffix": obj.get("suffix"),
            "open_in_new_tab": obj.get("open_in_new_tab") if obj.get("open_in_new_tab") is not None else True,
            "show_domain": obj.get("show_domain") if obj.get("show_domain") is not None else False,
            "true_label": obj.get("true_label") if obj.get("true_label") is not None else 'Yes',
            "false_label": obj.get("false_label") if obj.get("false_label") is not None else 'No',
            "separator": obj.get("separator") if obj.get("separator") is not None else ', ',
            "max_items": obj.get("max_items")
        })
        return _obj


