Documentation and version

This commit is contained in:
simonwt 2026-04-13 22:47:20 +01:00
parent 8453c10efe
commit 5705c05189
4 changed files with 31 additions and 2 deletions

View file

@ -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.

View file

@ -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"

View file

@ -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.

View file

@ -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.