-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
11 changed files
with
575 additions
and
52 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
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,62 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from httpx import Response | ||
|
||
from .client import Client | ||
from .tweet import Tweet | ||
from .utils import Result | ||
|
||
|
||
class BookmarkFolder: | ||
""" | ||
Attributes | ||
---------- | ||
id : :class:`str` | ||
The ID of the folder. | ||
name : :class:`str` | ||
The name of the folder | ||
media : :class:`str` | ||
Icon image data. | ||
""" | ||
def __init__(self, client: Client, data: dict) -> None: | ||
self._client = client | ||
|
||
self.id: str = data['id'] | ||
self.name: str = data['name'] | ||
self.media: dict = data['media'] | ||
|
||
def get_tweets(self, cursor: str | None = None) -> Result[Tweet]: | ||
""" | ||
Retrieves tweets from the folder. | ||
""" | ||
return self._client.get_bookmarks(cursor=cursor, folder_id=self.id) | ||
|
||
def edit(self, name: str) -> BookmarkFolder: | ||
""" | ||
Edits the folder. | ||
""" | ||
return self._client.edit_bookmark_folder(self.id, name) | ||
|
||
def delete(self) -> Response: | ||
""" | ||
Deletes the folder. | ||
""" | ||
return self._client.delete_bookmark_folder(self.id) | ||
|
||
def add(self, tweet_id: str) -> Response: | ||
""" | ||
Adds a tweet to the folder. | ||
""" | ||
return self._client.bookmark_tweet(tweet_id, self.id) | ||
|
||
def __eq__(self, __value: object) -> bool: | ||
return isinstance(__value, BookmarkFolder) and self.id == __value.id | ||
|
||
def __ne__(self, __value: object) -> bool: | ||
return not self == __value | ||
|
||
def __repr__(self) -> str: | ||
return f'<BookmarkFolder id="{self.id}">' |
Oops, something went wrong.