# 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 typing_extensions import Self

class ImageAsset(BaseModel):
    """
    ImageAsset
    """ # noqa: E501
    sub_type: Optional[StrictStr] = Field(default=None, alias="SubType")
    crop_x: Optional[StrictInt] = Field(default=None, alias="CropX")
    crop_y: Optional[StrictInt] = Field(default=None, alias="CropY")
    crop_width: Optional[StrictInt] = Field(default=None, alias="CropWidth")
    crop_height: Optional[StrictInt] = Field(default=None, alias="CropHeight")
    target_width: Optional[StrictInt] = Field(default=None, alias="TargetWidth")
    target_height: Optional[StrictInt] = Field(default=None, alias="TargetHeight")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    type: Optional[StrictStr] = Field(default='ImageAsset', alias="Type")
    __properties: ClassVar[List[str]] = ["SubType", "CropX", "CropY", "CropWidth", "CropHeight", "TargetWidth", "TargetHeight", "Id", "Name", "Type"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "SubType": obj.get("SubType") if obj.get("SubType") is not None else None,
                        "CropX": obj.get("CropX") if obj.get("CropX") is not None else None,
                        "CropY": obj.get("CropY") if obj.get("CropY") is not None else None,
                        "CropWidth": obj.get("CropWidth") if obj.get("CropWidth") is not None else None,
                        "CropHeight": obj.get("CropHeight") if obj.get("CropHeight") is not None else None,
                        "TargetWidth": obj.get("TargetWidth") if obj.get("TargetWidth") is not None else None,
                        "TargetHeight": obj.get("TargetHeight") if obj.get("TargetHeight") 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 'ImageAsset'
        })
        return _obj
