diff --git a/jobs/post/get.py b/jobs/post/get.py index 9bb99ff..e8c27fd 100644 --- a/jobs/post/get.py +++ b/jobs/post/get.py @@ -3,7 +3,8 @@ def get(API, post_slug: str,) -> dict: Fetches the post data from the API. Args: - post_slug (str): Slug of the post to fetch. + post_slug (str): Slug of the post to fetch data for. + Returns: dict: The post data. """ diff --git a/jobs/post/listbyuserprofile.py b/jobs/post/listbyuserprofile.py new file mode 100644 index 0000000..40a8acb --- /dev/null +++ b/jobs/post/listbyuserprofile.py @@ -0,0 +1,14 @@ +def listbyuserprofile(API, user_slug: str,) -> dict: + """ + Fetches the list of posts for a given user profile from the API. + + Args: + user_slug (str): Slug of the user profile to fetch posts for. + Returns: + dict: The list of posts for the user profile. + """ + print(f"Fetching posts for user profile: {user_slug}") + # Note there is actually a reference to `/branch` in the API url + # and it should be considered for removal because that's confusing + post_list = API.make_request("GET", "content", f"post/ref-userprofile/branch/{user_slug}", authenticate=True) + return post_list \ No newline at end of file diff --git a/testing.py b/testing.py index 8dc64ef..fed9251 100644 --- a/testing.py +++ b/testing.py @@ -40,5 +40,8 @@ if not API.is_token_valid(): # post = API.run_job('post.get', "1774875037-170a46a9") # print(post) # print("-----------------------------") -feed = API.run_job('post.listbybranch', "music") +# feed = API.run_job('post.listbybranch', "music") +# print(feed) +print("-----------------------------") +feed = API.run_job('post.listbyuserprofile', "simon-little") print(feed) \ No newline at end of file