-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, TypeVar, Generic | ||
from mipac.abstract.model import AbstractModel | ||
from mipac.types.ads import IPartialAd, IAdPlaces | ||
|
||
if TYPE_CHECKING: | ||
from mipac.manager.client import ClientManager | ||
|
||
|
||
T = TypeVar("T", bound=IPartialAd) | ||
|
||
|
||
class PartialAd(AbstractModel, Generic[T]): | ||
def __init__(self, raw_ad: T, *, client: ClientManager) -> None: | ||
self._raw_ad: T = raw_ad | ||
|
||
@property | ||
def id(self) -> str: | ||
return self._raw_ad["id"] | ||
|
||
@property | ||
def url(self) -> str: | ||
return self._raw_ad["url"] | ||
|
||
@property | ||
def place(self) -> IAdPlaces: | ||
return self._raw_ad["place"] | ||
|
||
@property | ||
def ratio(self) -> int: | ||
return self._raw_ad["ratio"] | ||
|
||
@property | ||
def image_url(self) -> str: | ||
return self._raw_ad["image_url"] | ||
|
||
@property | ||
def day_of_week(self) -> int: | ||
return self._raw_ad["day_of_week"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters