# 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.customer_share import CustomerShare
from openapi_client.models.campaign.entity_scope import EntityScope
from openapi_client.models.campaign.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from typing_extensions import Self

class SimilarRemarketingList(BaseModel):
    """
    SimilarRemarketingList
    """ # noqa: E501
    source_id: Optional[StrictStr] = Field(default=None, alias="SourceId")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    description: Optional[StrictStr] = Field(default=None, alias="Description")
    scope: Optional[EntityScope] = Field(default=None, alias="Scope")
    parent_id: Optional[StrictStr] = Field(default=None, alias="ParentId")
    membership_duration: Optional[StrictInt] = Field(default=None, alias="MembershipDuration")
    type: Optional[StrictStr] = Field(default='SimilarRemarketingList', alias="Type")
    search_size: Optional[StrictStr] = Field(default=None, alias="SearchSize")
    audience_network_size: Optional[StrictStr] = Field(default=None, alias="AudienceNetworkSize")
    supported_campaign_types: Optional[List[StrictStr]] = Field(default=None, alias="SupportedCampaignTypes")
    customer_share: Optional[CustomerShare] = Field(default=None, alias="CustomerShare")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["SourceId", "Id", "Name", "Description", "Scope", "ParentId", "MembershipDuration", "Type", "SearchSize", "AudienceNetworkSize", "SupportedCampaignTypes", "CustomerShare", "ForwardCompatibilityMap"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	
    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 SimilarRemarketingList 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,
        )
        # override the default output from pydantic by calling `to_dict()` of customer_share
        if self.customer_share:
            _dict['CustomerShare'] = self.customer_share.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 source_id (nullable) is None
        # and model_fields_set contains the field
        if self.source_id is None and "source_id" in self.model_fields_set:
            _dict['SourceId'] = None

        # 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 scope (nullable) is None
        # and model_fields_set contains the field
        if self.scope is None and "scope" in self.model_fields_set:
            _dict['Scope'] = None

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

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

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

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

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

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

        # set to None if customer_share (nullable) is None
        # and model_fields_set contains the field
        if self.customer_share is None and "customer_share" in self.model_fields_set:
            _dict['CustomerShare'] = 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 SimilarRemarketingList from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "SourceId": obj.get("SourceId") if obj.get("SourceId") is not None else None,
                        "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,
                        "Scope": obj.get("Scope") if obj.get("Scope") is not None else None,
                        "ParentId": obj.get("ParentId") if obj.get("ParentId") is not None else None,
                        "MembershipDuration": obj.get("MembershipDuration") if obj.get("MembershipDuration") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'SimilarRemarketingList',
                        "SearchSize": obj.get("SearchSize") if obj.get("SearchSize") is not None else None,
                        "AudienceNetworkSize": obj.get("AudienceNetworkSize") if obj.get("AudienceNetworkSize") is not None else None,
                        "SupportedCampaignTypes": obj.get("SupportedCampaignTypes"),
                        "CustomerShare": CustomerShare.from_dict(obj["CustomerShare"]) if obj.get("CustomerShare") 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
