# 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.annotation_opt_out import AnnotationOptOut
from openapi_client.models.campaign.batch_error import BatchError
from typing_extensions import Self

class GetAnnotationOptOutResponse(BaseModel):
    """
    GetAnnotationOptOutResponse
    """ # noqa: E501
    justification: Optional[StrictStr] = Field(default=None, alias="Justification")
    annotation_opt_outs: Optional[List[Optional[AnnotationOptOut]]] = Field(default=None, alias="AnnotationOptOuts")
    is_account_opt_out: Optional[StrictBool] = Field(default=None, alias="IsAccountOptOut")
    is_customer_opt_out: Optional[StrictBool] = Field(default=None, alias="IsCustomerOptOut")
    is_customer_opt_out_of_everything: Optional[StrictBool] = Field(default=None, alias="IsCustomerOptOutOfEverything")
    partial_errors: Optional[List[Optional[BatchError]]] = Field(default=None, alias="PartialErrors")
    __properties: ClassVar[List[str]] = ["Justification", "AnnotationOptOuts", "IsAccountOptOut", "IsCustomerOptOut", "IsCustomerOptOutOfEverything", "PartialErrors"]

    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 each item in annotation_opt_outs (list)
        _items = []
        if self.annotation_opt_outs:
            for _item_annotation_opt_outs in self.annotation_opt_outs:
                if _item_annotation_opt_outs:
                    _items.append(_item_annotation_opt_outs.to_dict())
            _dict['AnnotationOptOuts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in partial_errors (list)
        _items = []
        if self.partial_errors:
            for _item_partial_errors in self.partial_errors:
                if _item_partial_errors:
                    _items.append(_item_partial_errors.to_dict())
            _dict['PartialErrors'] = _items
        # set to None if justification (nullable) is None
        # and model_fields_set contains the field
        if self.justification is None and "justification" in self.model_fields_set:
            _dict['Justification'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Justification": obj.get("Justification") if obj.get("Justification") is not None else None,
                        "AnnotationOptOuts": [AnnotationOptOut.from_dict(_item) for _item in obj["AnnotationOptOuts"]] if obj.get("AnnotationOptOuts") is not None else None,
                        "IsAccountOptOut": obj.get("IsAccountOptOut") if obj.get("IsAccountOptOut") is not None else None,
                        "IsCustomerOptOut": obj.get("IsCustomerOptOut") if obj.get("IsCustomerOptOut") is not None else None,
                        "IsCustomerOptOutOfEverything": obj.get("IsCustomerOptOutOfEverything") if obj.get("IsCustomerOptOutOfEverything") is not None else None,
                        "PartialErrors": [BatchError.from_dict(_item) for _item in obj["PartialErrors"]] if obj.get("PartialErrors") is not None else None
        })
        return _obj
