# 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.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from typing_extensions import Self

class NegativeKeywordList(BaseModel):
    """
    NegativeKeywordList
    """ # noqa: E501
    item_count: Optional[StrictInt] = Field(default=None, alias="ItemCount")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    type: Optional[StrictStr] = Field(default='NegativeKeywordList', alias="Type")
    association_count: Optional[StrictInt] = Field(default=None, alias="AssociationCount")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["ItemCount", "Id", "Name", "Type", "AssociationCount", "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 NegativeKeywordList 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 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 item_count (nullable) is None
        # and model_fields_set contains the field
        if self.item_count is None and "item_count" in self.model_fields_set:
            _dict['ItemCount'] = 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 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 association_count (nullable) is None
        # and model_fields_set contains the field
        if self.association_count is None and "association_count" in self.model_fields_set:
            _dict['AssociationCount'] = 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 NegativeKeywordList from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "ItemCount": obj.get("ItemCount") if obj.get("ItemCount") 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,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'NegativeKeywordList',
                        "AssociationCount": obj.get("AssociationCount") if obj.get("AssociationCount") 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
