Get posts by userprofile

This commit is contained in:
simonwt 2026-03-31 10:33:30 +01:00
parent 6c69c6d6c8
commit 3188595f4a
3 changed files with 20 additions and 2 deletions

View file

@ -3,7 +3,8 @@ def get(API, post_slug: str,) -> dict:
Fetches the post data from the API. Fetches the post data from the API.
Args: Args:
post_slug (str): Slug of the post to fetch. post_slug (str): Slug of the post to fetch data for.
Returns: Returns:
dict: The post data. dict: The post data.
""" """

View file

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

View file

@ -40,5 +40,8 @@ if not API.is_token_valid():
# post = API.run_job('post.get', "1774875037-170a46a9") # post = API.run_job('post.get', "1774875037-170a46a9")
# print(post) # print(post)
# print("-----------------------------") # 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) print(feed)