# 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.offline_conversion_alert import OfflineConversionAlert
from openapi_client.models.campaign.offline_goal_daily_summary import OfflineGoalDailySummary
from typing_extensions import Self

class OfflineGoalConversionSummary(BaseModel):
    """
    OfflineGoalConversionSummary
    """ # noqa: E501
    goal_id: Optional[StrictStr] = Field(default=None, alias="GoalId")
    conversion_name: Optional[StrictStr] = Field(default=None, alias="ConversionName")
    overall_success_count: Optional[StrictStr] = Field(default=None, alias="OverallSuccessCount")
    overall_unattributed_count: Optional[StrictStr] = Field(default=None, alias="OverallUnattributedCount")
    overall_success_rate: Optional[StrictFloat] = Field(default=None, alias="OverallSuccessRate")
    overall_alerts: Optional[List[Optional[OfflineConversionAlert]]] = Field(default=None, alias="OverallAlerts")
    daily_summaries: Optional[List[Optional[OfflineGoalDailySummary]]] = Field(default=None, alias="DailySummaries")
    __properties: ClassVar[List[str]] = ["GoalId", "ConversionName", "OverallSuccessCount", "OverallUnattributedCount", "OverallSuccessRate", "OverallAlerts", "DailySummaries"]

    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 overall_alerts (list)
        _items = []
        if self.overall_alerts:
            for _item_overall_alerts in self.overall_alerts:
                if _item_overall_alerts:
                    _items.append(_item_overall_alerts.to_dict())
            _dict['OverallAlerts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in daily_summaries (list)
        _items = []
        if self.daily_summaries:
            for _item_daily_summaries in self.daily_summaries:
                if _item_daily_summaries:
                    _items.append(_item_daily_summaries.to_dict())
            _dict['DailySummaries'] = _items
        # set to None if goal_id (nullable) is None
        # and model_fields_set contains the field
        if self.goal_id is None and "goal_id" in self.model_fields_set:
            _dict['GoalId'] = None

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "GoalId": obj.get("GoalId") if obj.get("GoalId") is not None else None,
                        "ConversionName": obj.get("ConversionName") if obj.get("ConversionName") is not None else None,
                        "OverallSuccessCount": obj.get("OverallSuccessCount") if obj.get("OverallSuccessCount") is not None else None,
                        "OverallUnattributedCount": obj.get("OverallUnattributedCount") if obj.get("OverallUnattributedCount") is not None else None,
                        "OverallSuccessRate": obj.get("OverallSuccessRate") if obj.get("OverallSuccessRate") is not None else None,
                        "OverallAlerts": [OfflineConversionAlert.from_dict(_item) for _item in obj["OverallAlerts"]] if obj.get("OverallAlerts") is not None else None,
                        "DailySummaries": [OfflineGoalDailySummary.from_dict(_item) for _item in obj["DailySummaries"]] if obj.get("DailySummaries") is not None else None
        })
        return _obj
