# coding: utf-8

"""
    AdInsightService

    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.adinsight.performance_insights_url_category import PerformanceInsightsUrlCategory
from openapi_client.models.adinsight.performance_insights_url_id import PerformanceInsightsUrlId
from typing_extensions import Self

class UrlParameter(BaseModel):
    """
    UrlParameter
    """ # noqa: E501
    suggested_text: Optional[StrictStr] = Field(default=None, alias="SuggestedText")
    url_category: Optional[PerformanceInsightsUrlCategory] = Field(default=None, alias="UrlCategory")
    url_id: Optional[PerformanceInsightsUrlId] = Field(default=None, alias="UrlId")
    suggested_url: Optional[StrictStr] = Field(default=None, alias="SuggestedUrl")
    type: Optional[StrictStr] = Field(default='Url', alias="Type")
    __properties: ClassVar[List[str]] = ["SuggestedText", "UrlCategory", "UrlId", "SuggestedUrl", "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 UrlParameter 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 suggested_text (nullable) is None
        # and model_fields_set contains the field
        if self.suggested_text is None and "suggested_text" in self.model_fields_set:
            _dict['SuggestedText'] = None

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

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

        # set to None if suggested_url (nullable) is None
        # and model_fields_set contains the field
        if self.suggested_url is None and "suggested_url" in self.model_fields_set:
            _dict['SuggestedUrl'] = 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 UrlParameter from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "SuggestedText": obj.get("SuggestedText") if obj.get("SuggestedText") is not None else None,
                        "UrlCategory": obj.get("UrlCategory") if obj.get("UrlCategory") is not None else None,
                        "UrlId": obj.get("UrlId") if obj.get("UrlId") is not None else None,
                        "SuggestedUrl": obj.get("SuggestedUrl") if obj.get("SuggestedUrl") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'Url'
        })
        return _obj
