diff --git a/jobs/post/__init__.py b/jobs/post/__init__.py new file mode 100644 index 0000000..73717f8 --- /dev/null +++ b/jobs/post/__init__.py @@ -0,0 +1,2 @@ +from .get import get +from .get import get \ No newline at end of file diff --git a/jobs/post/get.py b/jobs/post/get.py new file mode 100644 index 0000000..9bb99ff --- /dev/null +++ b/jobs/post/get.py @@ -0,0 +1,12 @@ +def get(API, post_slug: str,) -> dict: + """ + Fetches the post data from the API. + + Args: + post_slug (str): Slug of the post to fetch. + Returns: + dict: The post data. + """ + print(f"Fetching post from slug: {post_slug}") + post_data = API.make_request("GET", "content", f"post/id/{post_slug}", authenticate=True) + return post_data \ No newline at end of file diff --git a/testing.py b/testing.py index b426a73..cbc4f97 100644 --- a/testing.py +++ b/testing.py @@ -7,6 +7,8 @@ import os, simplejson as json # Handle environment variables from dotenv import load_dotenv load_dotenv() +if not os.getenv("client_id") or not os.getenv("client_secret"): + raise Exception("Please set client_id and client_secret in your environment variables.") # Initialize API client with credentials from environment variables API = APIClient( @@ -33,4 +35,7 @@ profile = API.run_job('userprofile.get', "simon-little") print(profile) print("-----------------------------") branch = API.run_job('branch.get', "music") -print(branch) \ No newline at end of file +print(branch) +print("-----------------------------") +post = API.run_job('post.get', "1774875037-170a46a9") +print(post) \ No newline at end of file diff --git a/uv.lock b/uv.lock index a1bd361..be365aa 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "trustcafeapiwrapper" -version = "0.1.0" +version = "0.1.0.1" source = { virtual = "." } dependencies = [ { name = "dotenv" },