129 lines
4 KiB
Python
129 lines
4 KiB
Python
from collections.abc import Mapping
|
|
from typing import TYPE_CHECKING, Any, TypeVar
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
if TYPE_CHECKING:
|
|
from .ad_visit_statistic import AdVisitStatistic
|
|
|
|
|
|
T = TypeVar("T", bound="Statistic")
|
|
|
|
|
|
@_attrs_define
|
|
class Statistic:
|
|
"""
|
|
Attributes:
|
|
total_reward_input (int):
|
|
total_visit_count (int):
|
|
total_ads_count (int):
|
|
monthly_data (list['AdVisitStatistic']):
|
|
daily_data (list['AdVisitStatistic']):
|
|
hourly_data (list['AdVisitStatistic']):
|
|
"""
|
|
|
|
total_reward_input: int
|
|
total_visit_count: int
|
|
total_ads_count: int
|
|
monthly_data: list["AdVisitStatistic"]
|
|
daily_data: list["AdVisitStatistic"]
|
|
hourly_data: list["AdVisitStatistic"]
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
total_reward_input = self.total_reward_input
|
|
|
|
total_visit_count = self.total_visit_count
|
|
|
|
total_ads_count = self.total_ads_count
|
|
|
|
monthly_data = []
|
|
for monthly_data_item_data in self.monthly_data:
|
|
monthly_data_item = monthly_data_item_data.to_dict()
|
|
monthly_data.append(monthly_data_item)
|
|
|
|
daily_data = []
|
|
for daily_data_item_data in self.daily_data:
|
|
daily_data_item = daily_data_item_data.to_dict()
|
|
daily_data.append(daily_data_item)
|
|
|
|
hourly_data = []
|
|
for hourly_data_item_data in self.hourly_data:
|
|
hourly_data_item = hourly_data_item_data.to_dict()
|
|
hourly_data.append(hourly_data_item)
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"total_reward_input": total_reward_input,
|
|
"total_visit_count": total_visit_count,
|
|
"total_ads_count": total_ads_count,
|
|
"monthly_data": monthly_data,
|
|
"daily_data": daily_data,
|
|
"hourly_data": hourly_data,
|
|
}
|
|
)
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from .ad_visit_statistic import AdVisitStatistic
|
|
|
|
d = dict(src_dict)
|
|
total_reward_input = d.pop("total_reward_input")
|
|
|
|
total_visit_count = d.pop("total_visit_count")
|
|
|
|
total_ads_count = d.pop("total_ads_count")
|
|
|
|
monthly_data = []
|
|
_monthly_data = d.pop("monthly_data")
|
|
for monthly_data_item_data in _monthly_data:
|
|
monthly_data_item = AdVisitStatistic.from_dict(monthly_data_item_data)
|
|
|
|
monthly_data.append(monthly_data_item)
|
|
|
|
daily_data = []
|
|
_daily_data = d.pop("daily_data")
|
|
for daily_data_item_data in _daily_data:
|
|
daily_data_item = AdVisitStatistic.from_dict(daily_data_item_data)
|
|
|
|
daily_data.append(daily_data_item)
|
|
|
|
hourly_data = []
|
|
_hourly_data = d.pop("hourly_data")
|
|
for hourly_data_item_data in _hourly_data:
|
|
hourly_data_item = AdVisitStatistic.from_dict(hourly_data_item_data)
|
|
|
|
hourly_data.append(hourly_data_item)
|
|
|
|
statistic = cls(
|
|
total_reward_input=total_reward_input,
|
|
total_visit_count=total_visit_count,
|
|
total_ads_count=total_ads_count,
|
|
monthly_data=monthly_data,
|
|
daily_data=daily_data,
|
|
hourly_data=hourly_data,
|
|
)
|
|
|
|
statistic.additional_properties = d
|
|
return statistic
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|