diff --git a/documentation.md b/documentation.md index 6363b30..5f07d0f 100644 --- a/documentation.md +++ b/documentation.md @@ -24,6 +24,30 @@ API = APIClient( debug=False, ) ``` +## Handle token (easy way) + +```python +API.handle_token() +``` +## Handling the token yourself + +```python + +def getMyToken(): + # get the token from your personal store + # initially this will be None + return token_data + +def saveMyToken(): + # save your token to your personal store + return True + +# Use the old token or None if we haven't logged in ever from here +API.set_token(getMyToken()) +# Get a new one if we don't have one or if the existing one is expired +if not API.is_token_valid(): + saveMyToken(API.sign_in()) +``` ## Use a wrapper Wrappers make it as simple as possible to perform an action. diff --git a/pyproject.toml b/pyproject.toml index 66daa47..c2eafcc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "trustcafeapiwrapper" -version = "0.1.0.10" +version = "0.1.0.11" description = "Wraps the Trust Cafe API" readme = "README.md" requires-python = ">=3.11" diff --git a/src/trustcafeapiwrapper/wrappers/comment/create_comment.py b/src/trustcafeapiwrapper/wrappers/comment/create_comment.py index 5c86c1e..32f4f1d 100644 --- a/src/trustcafeapiwrapper/wrappers/comment/create_comment.py +++ b/src/trustcafeapiwrapper/wrappers/comment/create_comment.py @@ -6,8 +6,11 @@ def create_comment(comment_text, post_slug=None, parent_path=None, post_key=None Creates a new comment. Args: + comment_text (str): The text content of the comment. - parent_path (str): The parent path for the comment, in the format 'userprofile/slug' or 'subwiki/slug'. + post_slug (str, optional): The slug of the post to which the comment belongs. + parent_path (str, optional): The parent path for the comment, in the format 'userprofile/slug' or 'subwiki/slug'. + post_key (dict, optional): A dictionary containing the primary key (pk) and sort key (sk) of the post. blur_label (str, optional): An optional label for blurring the comment content. version (int, optional): The version of the comment structure to use, default is 3. diff --git a/src/trustcafeapiwrapper/wrappers/post/update_post.py b/src/trustcafeapiwrapper/wrappers/post/update_post.py index f289124..c4b3cfe 100644 --- a/src/trustcafeapiwrapper/wrappers/post/update_post.py +++ b/src/trustcafeapiwrapper/wrappers/post/update_post.py @@ -7,7 +7,9 @@ def update_post( post_text, post_path=None, parent_path='/', post_key=None, blur Args: post_slug (str): The slug of the post to update. post_text (str): The new text for the post. + post_path (str, optional): The path of the post to update. Defaults to None. parent_path (str, optional): The parent path for the post. Defaults to '/'. + post_key (dict, optional): A dictionary containing the primary key (pk) and sort key (sk) of the post. Defaults to None. blur_label (str, optional): The blur label for the post. Defaults to None. card_url (str, optional): The card URL for the post. Defaults to None. collaborative (bool, optional): Whether the post is collaborative. Defaults to False.