# 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.campaign_association import CampaignAssociation
from openapi_client.models.campaign.campaign_type import CampaignType
from openapi_client.models.campaign.device_type import DeviceType
from typing_extensions import Self

class SeasonalityAdjustment(BaseModel):
    """
    SeasonalityAdjustment
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    description: Optional[StrictStr] = Field(default=None, alias="Description")
    adjustment_percentage: Optional[StrictFloat] = Field(default=None, alias="AdjustmentPercentage")
    start_date: Optional[datetime] = Field(default=None, alias="StartDate")
    end_date: Optional[datetime] = Field(default=None, alias="EndDate")
    device_type_filter: Optional[DeviceType] = Field(default=None, alias="DeviceTypeFilter")
    campaign_type_filter: Optional[CampaignType] = Field(default=None, alias="CampaignTypeFilter")
    campaign_associations: Optional[List[Optional[CampaignAssociation]]] = Field(default=None, alias="CampaignAssociations")
    __properties: ClassVar[List[str]] = ["Id", "Name", "Description", "AdjustmentPercentage", "StartDate", "EndDate", "DeviceTypeFilter", "CampaignTypeFilter", "CampaignAssociations"]

    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 campaign_associations (list)
        _items = []
        if self.campaign_associations:
            for _item_campaign_associations in self.campaign_associations:
                if _item_campaign_associations:
                    _items.append(_item_campaign_associations.to_dict())
            _dict['CampaignAssociations'] = _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 description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['Description'] = None

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SeasonalityAdjustment 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,
                        "Description": obj.get("Description") if obj.get("Description") is not None else None,
                        "AdjustmentPercentage": obj.get("AdjustmentPercentage") if obj.get("AdjustmentPercentage") 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,
                        "DeviceTypeFilter": obj.get("DeviceTypeFilter") if obj.get("DeviceTypeFilter") is not None else None,
                        "CampaignTypeFilter": obj.get("CampaignTypeFilter") if obj.get("CampaignTypeFilter") is not None else None,
                        "CampaignAssociations": [CampaignAssociation.from_dict(_item) for _item in obj["CampaignAssociations"]] if obj.get("CampaignAssociations") is not None else None
        })
        return _obj
