# 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, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ExportParameters(BaseModel):
    """
    ExportParameters
    """ # noqa: E501
    order: Optional[StrictStr] = None
    fields: Optional[List[StrictStr]] = Field(default=None, description="Array of strings containing the data in the export. These fields define the headers in the CSV file.")
    filters: Optional[Dict[str, Any]] = Field(default=None, description="Allowed additional properties must start with \"metadata.\" or \"redemption.\" and Allowed additional properties must start with \"metadata.\" and Allowed additional properties must start with \"metadata.\" or \"address.\" or \"summary.\" or \"loyalty.\" or \"loyalty_tier.\" or \"loyalty_points.\" or \"system_metadata.\"")
    __properties: ClassVar[List[str]] = ["order", "fields", "filters"]

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

        if value not in set(['-created_at', 'created_at', '-updated_at', 'updated_at', '-code', 'code', '-id', 'id', '-voucher_code', 'voucher_code', '-tracking_id', 'tracking_id', '-customer_id', 'customer_id', '-name', 'name', '-email', 'email', '-source_id', 'source_id', '-channel', 'channel', '-status', 'status', '-expires_at', 'expires_at']):
            raise ValueError("must be one of enum values ('-created_at', 'created_at', '-updated_at', 'updated_at', '-code', 'code', '-id', 'id', '-voucher_code', 'voucher_code', '-tracking_id', 'tracking_id', '-customer_id', 'customer_id', '-name', 'name', '-email', 'email', '-source_id', 'source_id', '-channel', 'channel', '-status', 'status', '-expires_at', 'expires_at')")
        return value

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

        for i in value:
            if i not in set(['code', 'voucher_type', 'value', 'formula', 'discount_type', 'campaign', 'category', 'start_date', 'expiration_date', 'gift_balance', 'loyalty_balance', 'redemption_quantity', 'redemption_count', 'active', 'qr_code', 'bar_code', 'metadata', 'id', 'is_referral_code', 'created_at', 'updated_at', 'validity_timeframe_interval', 'validity_timeframe_duration', 'validity_day_of_week', 'discount_amount_limit', 'campaign_id', 'additional_info', 'customer_id', 'discount_effect', 'discount_unit_type', 'discount_unit_effect', 'validation_rules_id', 'customer_source_id', 'object', 'date', 'voucher_code', 'promotion_tier_id', 'customer_name', 'tracking_id', 'order_id', 'order_amount', 'gift_amount', 'loyalty_points', 'result', 'failure_code', 'failure_message', 'name', 'description', 'email', 'source_id', 'address_city', 'address_state', 'address_line_1', 'address_line_2', 'address_country', 'address_postal_code', 'redemptions_total_redeemed', 'redemptions_total_failed', 'redemptions_total_succeeded', 'redemptions_total_rolled_back', 'redemptions_total_rollback_failed', 'redemptions_total_rollback_succeeded', 'orders_total_amount', 'orders_total_count', 'orders_average_amount', 'orders_last_order_amount', 'orders_last_order_date', 'loyalty_referred_customers', 'phone', 'birthday', 'birthdate', 'channel', 'is_winner', 'status', 'amount', 'discount_amount', 'items_discount_amount', 'total_discount_amount', 'total_amount', 'referrer_id', 'voucher_id', 'points', 'expires_at', 'type', 'reason', 'source', 'balance', 'related_transaction_id', 'details']):
                raise ValueError("each list item must be one of ('code', 'voucher_type', 'value', 'formula', 'discount_type', 'campaign', 'category', 'start_date', 'expiration_date', 'gift_balance', 'loyalty_balance', 'redemption_quantity', 'redemption_count', 'active', 'qr_code', 'bar_code', 'metadata', 'id', 'is_referral_code', 'created_at', 'updated_at', 'validity_timeframe_interval', 'validity_timeframe_duration', 'validity_day_of_week', 'discount_amount_limit', 'campaign_id', 'additional_info', 'customer_id', 'discount_effect', 'discount_unit_type', 'discount_unit_effect', 'validation_rules_id', 'customer_source_id', 'object', 'date', 'voucher_code', 'promotion_tier_id', 'customer_name', 'tracking_id', 'order_id', 'order_amount', 'gift_amount', 'loyalty_points', 'result', 'failure_code', 'failure_message', 'name', 'description', 'email', 'source_id', 'address_city', 'address_state', 'address_line_1', 'address_line_2', 'address_country', 'address_postal_code', 'redemptions_total_redeemed', 'redemptions_total_failed', 'redemptions_total_succeeded', 'redemptions_total_rolled_back', 'redemptions_total_rollback_failed', 'redemptions_total_rollback_succeeded', 'orders_total_amount', 'orders_total_count', 'orders_average_amount', 'orders_last_order_amount', 'orders_last_order_date', 'loyalty_referred_customers', 'phone', 'birthday', 'birthdate', 'channel', 'is_winner', 'status', 'amount', 'discount_amount', 'items_discount_amount', 'total_discount_amount', 'total_amount', 'referrer_id', 'voucher_id', 'points', 'expires_at', 'type', 'reason', 'source', 'balance', 'related_transaction_id', 'details')")
        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 ExportParameters 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 order (nullable) is None
        # and model_fields_set contains the field
        if self.order is None and "order" in self.model_fields_set:
            _dict['order'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "order": obj.get("order"),
            "fields": obj.get("fields"),
            "filters": obj.get("filters")
        })
        return _obj


