# 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.bidding_scheme import BiddingScheme
from openapi_client.models.campaign.budget_limit_type import BudgetLimitType
from openapi_client.models.campaign.campaign_status import CampaignStatus
from openapi_client.models.campaign.campaign_type import CampaignType
from openapi_client.models.campaign.custom_parameters import CustomParameters
from openapi_client.models.campaign.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from openapi_client.models.campaign.setting import Setting
from typing_extensions import Self

class Campaign(BaseModel):
    """
    Campaign
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    status: Optional[CampaignStatus] = Field(default=None, alias="Status")
    daily_budget: Optional[StrictFloat] = Field(default=None, alias="DailyBudget")
    budget_type: Optional[BudgetLimitType] = Field(default=None, alias="BudgetType")
    time_zone: Optional[StrictStr] = Field(default=None, alias="TimeZone")
    settings: Optional[List[Optional[Setting]]] = Field(default=None, alias="Settings")
    campaign_type: Optional[CampaignType] = Field(default=None, alias="CampaignType")
    sub_type: Optional[StrictStr] = Field(default=None, alias="SubType")
    audience_ads_bid_adjustment: Optional[StrictInt] = Field(default=None, alias="AudienceAdsBidAdjustment")
    tracking_url_template: Optional[StrictStr] = Field(default=None, alias="TrackingUrlTemplate")
    final_url_suffix: Optional[StrictStr] = Field(default=None, alias="FinalUrlSuffix")
    url_custom_parameters: Optional[CustomParameters] = Field(default=None, alias="UrlCustomParameters")
    bidding_scheme: Optional[BiddingScheme] = Field(default=None, alias="BiddingScheme")
    budget_id: Optional[StrictStr] = Field(default=None, alias="BudgetId")
    languages: Optional[List[StrictStr]] = Field(default=None, alias="Languages")
    experiment_id: Optional[StrictStr] = Field(default=None, alias="ExperimentId")
    ad_schedule_use_searcher_time_zone: Optional[StrictBool] = Field(default=None, alias="AdScheduleUseSearcherTimeZone")
    bid_strategy_id: Optional[StrictStr] = Field(default=None, alias="BidStrategyId")
    multimedia_ads_bid_adjustment: Optional[StrictInt] = Field(default=None, alias="MultimediaAdsBidAdjustment")
    goal_ids: Optional[List[StrictStr]] = Field(default=None, alias="GoalIds")
    deal_ids: Optional[List[StrictStr]] = Field(default=None, alias="DealIds")
    is_deal_campaign: Optional[StrictBool] = Field(default=None, alias="IsDealCampaign")
    start_date: Optional[datetime] = Field(default=None, alias="StartDate")
    end_date: Optional[datetime] = Field(default=None, alias="EndDate")
    use_campaign_level_dates: Optional[StrictBool] = Field(default=None, alias="UseCampaignLevelDates")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["Id", "Name", "Status", "DailyBudget", "BudgetType", "TimeZone", "Settings", "CampaignType", "SubType", "AudienceAdsBidAdjustment", "TrackingUrlTemplate", "FinalUrlSuffix", "UrlCustomParameters", "BiddingScheme", "BudgetId", "Languages", "ExperimentId", "AdScheduleUseSearcherTimeZone", "BidStrategyId", "MultimediaAdsBidAdjustment", "GoalIds", "DealIds", "IsDealCampaign", "StartDate", "EndDate", "UseCampaignLevelDates", "ForwardCompatibilityMap"]

    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 each item in settings (list)
        _items = []
        if self.settings:
            for _item_settings in self.settings:
                if _item_settings:
                    _items.append(_item_settings.to_dict())
            _dict['Settings'] = _items
        # override the default output from pydantic by calling `to_dict()` of url_custom_parameters
        if self.url_custom_parameters:
            _dict['UrlCustomParameters'] = self.url_custom_parameters.to_dict()
        # override the default output from pydantic by calling `to_dict()` of bidding_scheme
        if self.bidding_scheme:
            _dict['BiddingScheme'] = self.bidding_scheme.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in forward_compatibility_map (list)
        _items = []
        if self.forward_compatibility_map:
            for _item_forward_compatibility_map in self.forward_compatibility_map:
                if _item_forward_compatibility_map:
                    _items.append(_item_forward_compatibility_map.to_dict())
            _dict['ForwardCompatibilityMap'] = _items
        # 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 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Campaign 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,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "DailyBudget": obj.get("DailyBudget") if obj.get("DailyBudget") is not None else None,
                        "BudgetType": obj.get("BudgetType") if obj.get("BudgetType") is not None else None,
                        "TimeZone": obj.get("TimeZone") if obj.get("TimeZone") is not None else None,
                        "Settings": [Setting.from_dict(_item) for _item in obj["Settings"]] if obj.get("Settings") is not None else None,
                        "CampaignType": obj.get("CampaignType") if obj.get("CampaignType") is not None else None,
                        "SubType": obj.get("SubType") if obj.get("SubType") is not None else None,
                        "AudienceAdsBidAdjustment": obj.get("AudienceAdsBidAdjustment") if obj.get("AudienceAdsBidAdjustment") is not None else None,
                        "TrackingUrlTemplate": obj.get("TrackingUrlTemplate") if obj.get("TrackingUrlTemplate") is not None else None,
                        "FinalUrlSuffix": obj.get("FinalUrlSuffix") if obj.get("FinalUrlSuffix") is not None else None,
                        "UrlCustomParameters": CustomParameters.from_dict(obj["UrlCustomParameters"]) if obj.get("UrlCustomParameters") is not None else None,
                        "BiddingScheme": BiddingScheme.from_dict(obj["BiddingScheme"]) if obj.get("BiddingScheme") is not None else None,
                        "BudgetId": obj.get("BudgetId") if obj.get("BudgetId") is not None else None,
                        "Languages": obj.get("Languages"),
                        "ExperimentId": obj.get("ExperimentId") if obj.get("ExperimentId") is not None else None,
                        "AdScheduleUseSearcherTimeZone": obj.get("AdScheduleUseSearcherTimeZone") if obj.get("AdScheduleUseSearcherTimeZone") is not None else None,
                        "BidStrategyId": obj.get("BidStrategyId") if obj.get("BidStrategyId") is not None else None,
                        "MultimediaAdsBidAdjustment": obj.get("MultimediaAdsBidAdjustment") if obj.get("MultimediaAdsBidAdjustment") is not None else None,
                        "GoalIds": obj.get("GoalIds"),
                        "DealIds": obj.get("DealIds"),
                        "IsDealCampaign": obj.get("IsDealCampaign") if obj.get("IsDealCampaign") is not None else None,
                        "StartDate": obj.get("StartDate") if obj.get("StartDate") is not None else None,
                        "EndDate": obj.get("EndDate") if obj.get("EndDate") is not None else None,
                        "UseCampaignLevelDates": obj.get("UseCampaignLevelDates") if obj.get("UseCampaignLevelDates") is not None else None,
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None
        })
        return _obj
