# 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.app_url import AppUrl
from openapi_client.models.campaign.bid import Bid
from openapi_client.models.campaign.bidding_scheme import BiddingScheme
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.keyword_editorial_status import KeywordEditorialStatus
from openapi_client.models.campaign.keyword_status import KeywordStatus
from openapi_client.models.campaign.match_type import MatchType
from typing_extensions import Self

class Keyword(BaseModel):
    """
    Keyword
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    bid: Optional[Bid] = Field(default=None, alias="Bid")
    match_type: Optional[MatchType] = Field(default=None, alias="MatchType")
    param1: Optional[StrictStr] = Field(default=None, alias="Param1")
    param2: Optional[StrictStr] = Field(default=None, alias="Param2")
    param3: Optional[StrictStr] = Field(default=None, alias="Param3")
    text: Optional[StrictStr] = Field(default=None, alias="Text")
    status: Optional[KeywordStatus] = Field(default=None, alias="Status")
    editorial_status: Optional[KeywordEditorialStatus] = Field(default=None, alias="EditorialStatus")
    destination_url: Optional[StrictStr] = Field(default=None, alias="DestinationUrl")
    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")
    final_urls: Optional[List[StrictStr]] = Field(default=None, alias="FinalUrls")
    final_mobile_urls: Optional[List[StrictStr]] = Field(default=None, alias="FinalMobileUrls")
    final_app_urls: Optional[List[Optional[AppUrl]]] = Field(default=None, alias="FinalAppUrls")
    bidding_scheme: Optional[BiddingScheme] = Field(default=None, alias="BiddingScheme")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["Id", "Bid", "MatchType", "Param1", "Param2", "Param3", "Text", "Status", "EditorialStatus", "DestinationUrl", "TrackingUrlTemplate", "FinalUrlSuffix", "UrlCustomParameters", "FinalUrls", "FinalMobileUrls", "FinalAppUrls", "BiddingScheme", "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 bid
        if self.bid:
            _dict['Bid'] = self.bid.to_dict()
        # 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 each item in final_app_urls (list)
        _items = []
        if self.final_app_urls:
            for _item_final_app_urls in self.final_app_urls:
                if _item_final_app_urls:
                    _items.append(_item_final_app_urls.to_dict())
            _dict['FinalAppUrls'] = _items
        # 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 bid (nullable) is None
        # and model_fields_set contains the field
        if self.bid is None and "bid" in self.model_fields_set:
            _dict['Bid'] = None

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

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

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

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

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

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

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

        # set to None if final_app_urls (nullable) is None
        # and model_fields_set contains the field
        if self.final_app_urls is None and "final_app_urls" in self.model_fields_set:
            _dict['FinalAppUrls'] = 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 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 Keyword 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,
                        "Bid": Bid.from_dict(obj["Bid"]) if obj.get("Bid") is not None else None,
                        "MatchType": obj.get("MatchType") if obj.get("MatchType") is not None else None,
                        "Param1": obj.get("Param1") if obj.get("Param1") is not None else None,
                        "Param2": obj.get("Param2") if obj.get("Param2") is not None else None,
                        "Param3": obj.get("Param3") if obj.get("Param3") is not None else None,
                        "Text": obj.get("Text") if obj.get("Text") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "EditorialStatus": obj.get("EditorialStatus") if obj.get("EditorialStatus") is not None else None,
                        "DestinationUrl": obj.get("DestinationUrl") if obj.get("DestinationUrl") 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,
                        "FinalUrls": obj.get("FinalUrls"),
                        "FinalMobileUrls": obj.get("FinalMobileUrls"),
                        "FinalAppUrls": [AppUrl.from_dict(_item) for _item in obj["FinalAppUrls"]] if obj.get("FinalAppUrls") is not None else None,
                        "BiddingScheme": BiddingScheme.from_dict(obj["BiddingScheme"]) if obj.get("BiddingScheme") 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
