From 499c5aee98945943ee5504f5f164bf5b8ec9bc7d Mon Sep 17 00:00:00 2001 From: simonwt Date: Tue, 31 Mar 2026 11:03:31 +0100 Subject: [PATCH] Post create --- jobs/post/__init__.py | 3 ++- jobs/post/create.py | 13 +++++++++++++ testing.py | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 jobs/post/create.py diff --git a/jobs/post/__init__.py b/jobs/post/__init__.py index 215a5a5..32a1ac2 100644 --- a/jobs/post/__init__.py +++ b/jobs/post/__init__.py @@ -1,3 +1,4 @@ from .get import get from .listbybranch import listbybranch -from .listbyuserprofile import listbyuserprofile \ No newline at end of file +from .listbyuserprofile import listbyuserprofile +from .create import create \ No newline at end of file diff --git a/jobs/post/create.py b/jobs/post/create.py new file mode 100644 index 0000000..3f823ed --- /dev/null +++ b/jobs/post/create.py @@ -0,0 +1,13 @@ +def create(API, payload: dict) -> dict: + """ + Creates a new post in the API. + + Args: + payload (dict): The data for the new post. + + Returns: + dict: The post data. + """ + print(f"Creating a new post with payload: {payload}") + post_data = API.make_request("POST", "content", "post", data=payload, authenticate=True) + return post_data \ No newline at end of file diff --git a/testing.py b/testing.py index fed9251..84bc226 100644 --- a/testing.py +++ b/testing.py @@ -42,6 +42,18 @@ if not API.is_token_valid(): # print("-----------------------------") # feed = API.run_job('post.listbybranch', "music") # print(feed) +# print("-----------------------------") +# feed = API.run_job('post.listbyuserprofile', "simon-little") +# print(feed) print("-----------------------------") -feed = API.run_job('post.listbyuserprofile', "simon-little") -print(feed) \ No newline at end of file +post = API.run_job('post.create', { + "blurLabel": None, + "cardUrl": None, + "postText": "This is a test post created via the API wrapper.", + "collaborative": False, + "parent": { + "pk": "maintrunk#maintrunk", + "sk": "maintrunk#maintrunk" + } +}) +print(post) \ No newline at end of file