# 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.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from typing_extensions import Self
from openapi_client.models.campaign.batch_error import BatchError
class EditorialError(BatchError):
    """
    EditorialError
    """ # noqa: E501
    field_path: Optional[StrictStr] = Field(default=None, alias="FieldPath")
    error_code: Optional[StrictStr] = Field(default=None, alias="ErrorCode")
    message: Optional[StrictStr] = Field(default=None, alias="Message")
    code: Optional[StrictInt] = Field(default=None, alias="Code")
    details: Optional[StrictStr] = Field(default=None, alias="Details")
    index: Optional[StrictInt] = Field(default=None, alias="Index")
    type: Optional[StrictStr] = Field(default='BatchError', alias="Type")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    disapproved_text: Optional[StrictStr] = Field(default=None, alias="DisapprovedText")
    reason_code: Optional[StrictInt] = Field(default=None, alias="ReasonCode")
    location: Optional[StrictStr] = Field(default=None, alias="Location")
    appealable: Optional[StrictBool] = Field(default=None, alias="Appealable")
    publisher_country: Optional[StrictStr] = Field(default=None, alias="PublisherCountry")
    __properties: ClassVar[List[str]] = ["FieldPath", "ErrorCode", "Message", "Code", "Details", "Index", "Type", "ForwardCompatibilityMap", "DisapprovedText", "ReasonCode", "Location", "Appealable", "PublisherCountry"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

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

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

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

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

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

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

        # 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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "FieldPath": obj.get("FieldPath") if obj.get("FieldPath") is not None else None,
                        "ErrorCode": obj.get("ErrorCode") if obj.get("ErrorCode") is not None else None,
                        "Message": obj.get("Message") if obj.get("Message") is not None else None,
                        "Code": obj.get("Code") if obj.get("Code") is not None else None,
                        "Details": obj.get("Details") if obj.get("Details") is not None else None,
                        "Index": obj.get("Index") if obj.get("Index") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'BatchError',
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None,
                        "DisapprovedText": obj.get("DisapprovedText") if obj.get("DisapprovedText") is not None else None,
                        "ReasonCode": obj.get("ReasonCode") if obj.get("ReasonCode") is not None else None,
                        "Location": obj.get("Location") if obj.get("Location") is not None else None,
                        "Appealable": obj.get("Appealable") if obj.get("Appealable") is not None else None,
                        "PublisherCountry": obj.get("PublisherCountry") if obj.get("PublisherCountry") is not None else None
        })
        return _obj
