# coding: utf-8

"""
    CampaignManagementService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.campaign.audience_condition import AudienceCondition
from openapi_client.models.campaign.conversion_value_rule_operator import ConversionValueRuleOperator
from openapi_client.models.campaign.conversion_value_rule_status import ConversionValueRuleStatus
from openapi_client.models.campaign.device_condition import DeviceCondition
from openapi_client.models.campaign.location_condition import LocationCondition
from typing_extensions import Self

class ConversionValueRule(BaseModel):
    """
    ConversionValueRule
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    location_condition: Optional[LocationCondition] = Field(default=None, alias="LocationCondition")
    audience_condition: Optional[AudienceCondition] = Field(default=None, alias="AudienceCondition")
    device_condition: Optional[DeviceCondition] = Field(default=None, alias="DeviceCondition")
    value: Optional[StrictFloat] = Field(default=None, alias="Value")
    operation: Optional[ConversionValueRuleOperator] = Field(default=None, alias="Operation")
    currency_code: Optional[StrictStr] = Field(default=None, alias="CurrencyCode")
    status: Optional[ConversionValueRuleStatus] = Field(default=None, alias="Status")
    __properties: ClassVar[List[str]] = ["Id", "Name", "LocationCondition", "AudienceCondition", "DeviceCondition", "Value", "Operation", "CurrencyCode", "Status"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

    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,
        )
        # override the default output from pydantic by calling `to_dict()` of location_condition
        if self.location_condition:
            _dict['LocationCondition'] = self.location_condition.to_dict()
        # override the default output from pydantic by calling `to_dict()` of audience_condition
        if self.audience_condition:
            _dict['AudienceCondition'] = self.audience_condition.to_dict()
        # override the default output from pydantic by calling `to_dict()` of device_condition
        if self.device_condition:
            _dict['DeviceCondition'] = self.device_condition.to_dict()
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['Id'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Id": obj.get("Id") if obj.get("Id") is not None else None,
                        "Name": obj.get("Name") if obj.get("Name") is not None else None,
                        "LocationCondition": LocationCondition.from_dict(obj["LocationCondition"]) if obj.get("LocationCondition") is not None else None,
                        "AudienceCondition": AudienceCondition.from_dict(obj["AudienceCondition"]) if obj.get("AudienceCondition") is not None else None,
                        "DeviceCondition": DeviceCondition.from_dict(obj["DeviceCondition"]) if obj.get("DeviceCondition") is not None else None,
                        "Value": obj.get("Value") if obj.get("Value") is not None else None,
                        "Operation": obj.get("Operation") if obj.get("Operation") is not None else None,
                        "CurrencyCode": obj.get("CurrencyCode") if obj.get("CurrencyCode") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None
        })
        return _obj
