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

class OfflineGoalDailySummary(BaseModel):
    """
    OfflineGoalDailySummary
    """ # noqa: E501
    goal_id: Optional[StrictStr] = Field(default=None, alias="GoalId")
    upload_date: Optional[datetime] = Field(default=None, alias="UploadDate")
    success_count: Optional[StrictInt] = Field(default=None, alias="SuccessCount")
    unattributed_count: Optional[StrictInt] = Field(default=None, alias="UnattributedCount")
    success_rate: Optional[StrictFloat] = Field(default=None, alias="SuccessRate")
    alerts: Optional[List[Optional[OfflineConversionAlert]]] = Field(default=None, alias="Alerts")
    __properties: ClassVar[List[str]] = ["GoalId", "UploadDate", "SuccessCount", "UnattributedCount", "SuccessRate", "Alerts"]

    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 alerts (list)
        _items = []
        if self.alerts:
            for _item_alerts in self.alerts:
                if _item_alerts:
                    _items.append(_item_alerts.to_dict())
            _dict['Alerts'] = _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 upload_date (nullable) is None
        # and model_fields_set contains the field
        if self.upload_date is None and "upload_date" in self.model_fields_set:
            _dict['UploadDate'] = None

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of OfflineGoalDailySummary 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,
                        "UploadDate": obj.get("UploadDate") if obj.get("UploadDate") is not None else None,
                        "SuccessCount": obj.get("SuccessCount") if obj.get("SuccessCount") is not None else None,
                        "UnattributedCount": obj.get("UnattributedCount") if obj.get("UnattributedCount") is not None else None,
                        "SuccessRate": obj.get("SuccessRate") if obj.get("SuccessRate") is not None else None,
                        "Alerts": [OfflineConversionAlert.from_dict(_item) for _item in obj["Alerts"]] if obj.get("Alerts") is not None else None
        })
        return _obj
