# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    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 pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from pinterestsdk.models.app_type_multipliers import AppTypeMultipliers
from pinterestsdk.models.campaign_audience_multipliers import CampaignAudienceMultipliers
from pinterestsdk.models.placement_multipliers import PlacementMultipliers
from typing import Optional, Set
from typing_extensions import Self

class CampaignBidOptionsUpdate(BaseModel):
    """
    Object describing an update to the campaign level bid multipliers.
    """ # noqa: E501
    app_type_multipliers: Optional[AppTypeMultipliers] = None
    audience_multipliers: Optional[CampaignAudienceMultipliers] = None
    placement_multipliers: Optional[PlacementMultipliers] = None
    update_mask: List[StrictStr] = Field(description="List of fields to update, only the fields in the list will be updated.")
    __properties: ClassVar[List[str]] = ["app_type_multipliers", "audience_multipliers", "placement_multipliers", "update_mask"]

    @field_validator('update_mask')
    def update_mask_validate_enum(cls, value):
        """Validates the enum"""
        for i in value:
            if i not in set(['AUDIENCE', 'APP_TYPE', 'PLACEMENT', 'GENDER', 'AGE_BUCKET']):
                raise ValueError("each list item must be one of ('AUDIENCE', 'APP_TYPE', 'PLACEMENT', 'GENDER', 'AGE_BUCKET')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    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 CampaignBidOptionsUpdate 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 app_type_multipliers
        if self.app_type_multipliers:
            _dict['app_type_multipliers'] = self.app_type_multipliers.to_dict()
        # override the default output from pydantic by calling `to_dict()` of audience_multipliers
        if self.audience_multipliers:
            _dict['audience_multipliers'] = self.audience_multipliers.to_dict()
        # override the default output from pydantic by calling `to_dict()` of placement_multipliers
        if self.placement_multipliers:
            _dict['placement_multipliers'] = self.placement_multipliers.to_dict()
        # set to None if app_type_multipliers (nullable) is None
        # and model_fields_set contains the field
        if self.app_type_multipliers is None and "app_type_multipliers" in self.model_fields_set:
            _dict['app_type_multipliers'] = None

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CampaignBidOptionsUpdate from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "app_type_multipliers": AppTypeMultipliers.from_dict(obj["app_type_multipliers"]) if obj.get("app_type_multipliers") is not None else None,
            "audience_multipliers": CampaignAudienceMultipliers.from_dict(obj["audience_multipliers"]) if obj.get("audience_multipliers") is not None else None,
            "placement_multipliers": PlacementMultipliers.from_dict(obj["placement_multipliers"]) if obj.get("placement_multipliers") is not None else None,
            "update_mask": obj.get("update_mask")
        })
        return _obj


