Post update
This commit is contained in:
parent
1995e0479f
commit
a42a3b65d9
9 changed files with 116 additions and 17 deletions
|
|
@ -1,7 +1,8 @@
|
|||
from .update import update
|
||||
from .create import create
|
||||
from .get import get
|
||||
from .listbybranch import listbybranch
|
||||
from .listbyuserprofile import listbyuserprofile
|
||||
from .create import create
|
||||
from .listall import listall
|
||||
from .listpublic import listpublic
|
||||
from .listremoved import listremoved
|
||||
12
src/trustcafeapiwrapper/jobs/post/update.py
Normal file
12
src/trustcafeapiwrapper/jobs/post/update.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def update(API, payload: dict) -> dict:
|
||||
"""
|
||||
Updates an existing post in the API.
|
||||
|
||||
Args:
|
||||
payload (dict): The data for the post update.
|
||||
|
||||
Returns:
|
||||
dict: The post data.
|
||||
"""
|
||||
post_data = API.make_request("PUT", "content", "post/update", data=payload, authenticate=True)
|
||||
return post_data
|
||||
|
|
@ -1 +1,2 @@
|
|||
from .create_post import create_post
|
||||
from .create_post import create_post
|
||||
from .update_post import update_post
|
||||
37
src/trustcafeapiwrapper/wrappers/post/update_post.py
Normal file
37
src/trustcafeapiwrapper/wrappers/post/update_post.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from trustcafeapiwrapper.utils import get_post_pksk, get_parent_pksk_from_path
|
||||
|
||||
def update_post(parent_path, post_path, post_text, blur_label=None, card_url=None, collaborative=False):
|
||||
"""
|
||||
Updates an existing post.
|
||||
|
||||
Args:
|
||||
post_slug (str): The slug of the post to update.
|
||||
post_text (str): The new text for the post.
|
||||
parent_path (str, optional): The parent path for the post. Defaults to '/'.
|
||||
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.
|
||||
|
||||
Returns:
|
||||
dict: The updated post data.
|
||||
"""
|
||||
parent_pksk = get_parent_pksk_from_path(parent_path)
|
||||
post_pksk = get_post_pksk(parent_pksk, post_path)
|
||||
|
||||
payload = {
|
||||
"key": {
|
||||
"pk": post_pksk.get('pk', None),
|
||||
"sk": post_pksk.get('sk', None)
|
||||
},
|
||||
"postSlug": post_path.strip('/post/'),
|
||||
"blurLabel": blur_label,
|
||||
"cardUrl": card_url,
|
||||
"postText": post_text,
|
||||
"collaborative": collaborative,
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
"job_function": "post.update",
|
||||
"payload": payload
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue