Skip to content

Commit

Permalink
feat: 広告を最新のMisskeyに合わせて修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Oct 3, 2023
1 parent e1bc5f9 commit 425f843
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
40 changes: 40 additions & 0 deletions mipac/models/lite/ad.py
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"]
9 changes: 6 additions & 3 deletions mipac/types/ads.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from typing import Literal, TypedDict


class IAds(TypedDict):
IAdPlaces = Literal["square" "horizontal" "horizontal-big"]

class IPartialAd(TypedDict):
id: str
ratio: int
place: str
url: str
place: IAdPlaces
ratio: int
image_url: str
day_of_week: int


class IAd(TypedDict):
Expand Down

0 comments on commit 425f843

Please sign in to comment.