Get post by slug
This commit is contained in:
parent
5516568521
commit
8e8de42d15
4 changed files with 21 additions and 2 deletions
2
jobs/post/__init__.py
Normal file
2
jobs/post/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from .get import get
|
||||
from .get import get
|
||||
12
jobs/post/get.py
Normal file
12
jobs/post/get.py
Normal file
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
print(branch)
|
||||
print("-----------------------------")
|
||||
post = API.run_job('post.get', "1774875037-170a46a9")
|
||||
print(post)
|
||||
2
uv.lock
generated
2
uv.lock
generated
|
|
@ -213,7 +213,7 @@ wheels = [
|
|||
|
||||
[[package]]
|
||||
name = "trustcafeapiwrapper"
|
||||
version = "0.1.0"
|
||||
version = "0.1.0.1"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "dotenv" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue