Skip to content

Commit

Permalink
feat: Antennaの型とモデルを追加 #74
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Jun 16, 2023
1 parent 7b9afa4 commit 1e45726
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
72 changes: 72 additions & 0 deletions mipac/models/antenna.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from __future__ import annotations
from datetime import datetime

from typing import TYPE_CHECKING
from mipac.types.antenna import IAntenna, IAntennaReceiveSource
from mipac.utils.format import str_to_datetime


if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class Antenna:
def __init__(self, antenna: IAntenna, *, client: ClientManager) -> None:
self.__antenna: IAntenna = antenna
self.__client: ClientManager = client

@property
def case_sensitive(self) -> bool:
return self.__antenna['case_sensitive']

@property
def created_at(self) -> datetime:
return str_to_datetime(self.__antenna['created_at'])

@property
def exclude_keywords(self) -> list[str]:
return self.__antenna['exclude_keywords']

@property
def has_unread_note(self) -> bool:
return self.__antenna['has_unread_note']

@property
def id(self) -> str:
return self.__antenna['id']

@property
def is_actor(self) -> bool:
return self.__antenna['is_actor']

@property
def keywords(self) -> list[str]:
return self.__antenna['keywords']

@property
def name(self) -> str:
return self.__antenna['name']

@property
def notify(self) -> bool:
return self.__antenna['notify']

@property
def src(self) -> IAntennaReceiveSource:
return self.__antenna['src']

@property
def user_list_id(self) -> str | None:
return self.__antenna['user_list_id']

@property
def users(self) -> list[str]:
return self.__antenna['users']

@property
def with_file(self) -> bool:
return self.__antenna['with_file']

@property
def with_replies(self) -> bool:
return self.__antenna['with_replies']
20 changes: 20 additions & 0 deletions mipac/types/antenna.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import Literal, TypedDict

IAntennaReceiveSource = Literal['home', 'all', 'users', 'list']


class IAntenna(TypedDict):
case_sensitive: bool
created_at: str
exclude_keywords: list[str]
has_unread_note: bool
id: str
is_actor: bool
keywords: list[str]
name: str
notify: bool
src: IAntennaReceiveSource
user_list_id: str | None
users: list[str]
with_file: bool
with_replies: bool

0 comments on commit 1e45726

Please sign in to comment.