# coding: utf-8

"""
    Voucherify API

    Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details.

    The version of the OpenAPI document: v2018-08-01
    Contact: support@voucherify.io
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class FilterConditionsString(BaseModel):
    """
    Data filters used to narrow down the data records to be returned in the result.
    """ # noqa: E501
    var_in: Optional[List[StrictStr]] = Field(default=None, description="Array of resource values that should be included in the results (multiple values).", alias="$in")
    not_in: Optional[List[StrictStr]] = Field(default=None, description="Array of resource values that should be included in the results (multiple values).", alias="$not_in")
    var_is: Optional[StrictStr] = Field(default=None, description="Value is exactly this value (single value).", alias="$is")
    is_not: Optional[StrictStr] = Field(default=None, description="Results omit this value (single value).", alias="$is_not")
    has_value: Optional[StrictStr] = Field(default=None, description="Value is NOT null. The value for this parameter is an empty string.", alias="$has_value")
    is_unknown: Optional[StrictStr] = Field(default=None, description="Value is null. The value for this parameter is an empty string.", alias="$is_unknown")
    starts_with: Optional[StrictStr] = Field(default=None, description="Value starts with the specified string.", alias="$starts_with")
    ends_with: Optional[StrictStr] = Field(default=None, description="Value ends with the specified string.", alias="$ends_with")
    contains: Optional[StrictStr] = Field(default=None, description="Value includes the specified string.", alias="$contains")
    not_contain: Optional[StrictStr] = Field(default=None, description="Value does NOT include the specified string.", alias="$not_contain")
    __properties: ClassVar[List[str]] = ["$in", "$not_in", "$is", "$is_not", "$has_value", "$is_unknown", "$starts_with", "$ends_with", "$contains", "$not_contain"]

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "$in": obj.get("$in"),
            "$not_in": obj.get("$not_in"),
            "$is": obj.get("$is"),
            "$is_not": obj.get("$is_not"),
            "$has_value": obj.get("$has_value"),
            "$is_unknown": obj.get("$is_unknown"),
            "$starts_with": obj.get("$starts_with"),
            "$ends_with": obj.get("$ends_with"),
            "$contains": obj.get("$contains"),
            "$not_contain": obj.get("$not_contain")
        })
        return _obj


