# 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.recommendation_crop_setting import RecommendationCropSetting
from openapi_client.models.campaign.recommendation_image_size import RecommendationImageSize
from typing_extensions import Self

class RecommendationImage(BaseModel):
    """
    RecommendationImage
    """ # noqa: E501
    asset_id: Optional[StrictStr] = Field(default=None, alias="assetId")
    url: Optional[StrictStr] = Field(default=None, alias="url")
    editable: Optional[StrictBool] = Field(default=None, alias="editable")
    source: Optional[StrictStr] = Field(default=None, alias="source")
    recommendation_id: Optional[StrictStr] = Field(default=None, alias="recommendationId")
    image_size: Optional[RecommendationImageSize] = Field(default=None, alias="imageSize")
    crop_setting: Optional[List[Optional[RecommendationCropSetting]]] = Field(default=None, alias="cropSetting")
    __properties: ClassVar[List[str]] = ["assetId", "url", "editable", "source", "recommendationId", "imageSize", "cropSetting"]

    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 image_size
        if self.image_size:
            _dict['imageSize'] = self.image_size.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in crop_setting (list)
        _items = []
        if self.crop_setting:
            for _item_crop_setting in self.crop_setting:
                if _item_crop_setting:
                    _items.append(_item_crop_setting.to_dict())
            _dict['CropSetting'] = _items
        # set to None if asset_id (nullable) is None
        # and model_fields_set contains the field
        if self.asset_id is None and "asset_id" in self.model_fields_set:
            _dict['assetId'] = None

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "assetId": obj.get("AssetId") if obj.get("AssetId") is not None else None,
                        "url": obj.get("Url") if obj.get("Url") is not None else None,
                        "editable": obj.get("Editable") if obj.get("Editable") is not None else None,
                        "source": obj.get("Source") if obj.get("Source") is not None else None,
                        "recommendationId": obj.get("RecommendationId") if obj.get("RecommendationId") is not None else None,
                        "imageSize": RecommendationImageSize.from_dict(obj["ImageSize"]) if obj.get("ImageSize") is not None else None,
                        "cropSetting": [RecommendationCropSetting.from_dict(_item) for _item in obj["CropSetting"]] if obj.get("CropSetting") is not None else None
        })
        return _obj
