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

class ManagementProjectsBrandingCreateRequestBodyCockpits(BaseModel):
    """
    Defines customer cockpit details.
    """ # noqa: E501
    campaigns_overview_enabled: Optional[StrictBool] = Field(default=False, description="Enables the campaign overview for customers.")
    loyalty_enabled: Optional[StrictBool] = Field(default=True, description="Enables the loyalty campaign overview for customers.")
    gift_cards_enabled: Optional[StrictBool] = Field(default=True, description="Enables the gift card overview for customers.")
    coupons_enabled: Optional[StrictBool] = Field(default=True, description="Enables the discount coupon overview for customers.")
    referrals_enabled: Optional[StrictBool] = Field(default=True, description="Enables the referral campaign overview for customers.")
    theme: Optional[StrictStr] = Field(default='default', description="Determines the color scheme of the customer cockpit.")
    use_custom_double_opt_in_redirect_url: Optional[StrictBool] = Field(default=False, description="Enables the double opt-in option. It must be a valid URL format.")
    custom_double_opt_in_redirect_url: Optional[StrictStr] = Field(default=None, description="Defines the URL for the double opt-in consent. It must be a valid URL format.")
    __properties: ClassVar[List[str]] = ["campaigns_overview_enabled", "loyalty_enabled", "gift_cards_enabled", "coupons_enabled", "referrals_enabled", "theme", "use_custom_double_opt_in_redirect_url", "custom_double_opt_in_redirect_url"]

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

        if value not in set(['blue', 'dark-green', 'default', 'green', 'grey', 'orange', 'purple', 'red']):
            raise ValueError("must be one of enum values ('blue', 'dark-green', 'default', 'green', 'grey', 'orange', 'purple', 'red')")
        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 ManagementProjectsBrandingCreateRequestBodyCockpits 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 campaigns_overview_enabled (nullable) is None
        # and model_fields_set contains the field
        if self.campaigns_overview_enabled is None and "campaigns_overview_enabled" in self.model_fields_set:
            _dict['campaigns_overview_enabled'] = None

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "campaigns_overview_enabled": obj.get("campaigns_overview_enabled") if obj.get("campaigns_overview_enabled") is not None else False,
            "loyalty_enabled": obj.get("loyalty_enabled") if obj.get("loyalty_enabled") is not None else True,
            "gift_cards_enabled": obj.get("gift_cards_enabled") if obj.get("gift_cards_enabled") is not None else True,
            "coupons_enabled": obj.get("coupons_enabled") if obj.get("coupons_enabled") is not None else True,
            "referrals_enabled": obj.get("referrals_enabled") if obj.get("referrals_enabled") is not None else True,
            "theme": obj.get("theme") if obj.get("theme") is not None else 'default',
            "use_custom_double_opt_in_redirect_url": obj.get("use_custom_double_opt_in_redirect_url") if obj.get("use_custom_double_opt_in_redirect_url") is not None else False,
            "custom_double_opt_in_redirect_url": obj.get("custom_double_opt_in_redirect_url")
        })
        return _obj


