diff --git a/examples/draft_post.py b/examples/draft_post.py index c3a0966..337dec4 100644 --- a/examples/draft_post.py +++ b/examples/draft_post.py @@ -2,13 +2,16 @@ from lunduke.client import DiscourseClient def main(): - client = DiscourseClient() + categories = client.get('/categories.json').json()['category_list'] + print(categories) + try: draft_data = { - "title": "Simple forum post", - "raw": "Simple forum post content" - } + "title": "Testing 1 2 3", + "raw": "This is only a test", + "category": 15 + } response = client.post('/posts.json', data=draft_data) print(f"Draft created successfully: {response}") diff --git a/examples/get_latest.py b/examples/get_latest.py new file mode 100644 index 0000000..01296b8 --- /dev/null +++ b/examples/get_latest.py @@ -0,0 +1,22 @@ +from lunduke.client import DiscourseClient + + +def main(): + + client = DiscourseClient() + params = { + 'order': 'created', + 'ascending': 'false' + } + try: + response = client.get('/latest.json', params=params) + topics = response.json()['topic_list']['topics'] + print(f"Found {len(topics)} topics") + for topic in topics: + print(topic['title']) + except Exception as e: + print(f"Error: {e}") + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/lunduke/forum/__init__.py b/lunduke/forum/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lunduke/forum/mappings.py b/lunduke/forum/mappings.py new file mode 100644 index 0000000..8d1a4c5 --- /dev/null +++ b/lunduke/forum/mappings.py @@ -0,0 +1,9 @@ +class Categories: + """Category mappings""" + def __init__(self): + + self.categories = { + 15: "Politics OK", + 16: "No Politics", + 23: "Forum Stuff" + } \ No newline at end of file