Skip to content

Commit 62f3bc2

Browse files
authored
Merge pull request #4 from FastComments/regen-moderation-api
Add Moderation API and stable response types
2 parents e5a499d + ed7f654 commit 62f3bc2

616 files changed

Lines changed: 56196 additions & 41725 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
# Runs on PRs and pushes to the default branch. We use `pull_request` (never
4+
# `pull_request_target`), so secrets are NOT exposed to pull requests from forks.
5+
on:
6+
pull_request:
7+
push:
8+
branches: [main, master]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.12'
25+
- name: Install dependencies
26+
run: pip install -e ".[dev]"
27+
- name: Run tests
28+
run: pytest tests/ -v
29+
env:
30+
FASTCOMMENTS_API_KEY: ${{ secrets.FASTCOMMENTS_API_KEY }}
31+
FASTCOMMENTS_TENANT_ID: ${{ secrets.FASTCOMMENTS_TENANT_ID }}

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This library contains two modules: the generated API client and the core Python
1818

1919
### Public vs Secured APIs
2020

21-
For the API client, there are two classes, `DefaultApi` and `PublicApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains API calls that can be made directly from a browser/mobile device/etc without authentication.
21+
For the API client, there are three classes, `DefaultApi`, `PublicApi`, and `ModerationApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains methods that can be made directly from a browser/mobile device/etc without authentication. The `ModerationApi` powers the moderator dashboard and contains methods for moderating comments (list, count, search, logs, export), moderation actions (remove/restore, flag, set review/spam/approval status, votes, reopen/close thread), bans (ban from comment, undo, pre-ban summaries, ban status/preferences, banned-user counts), and badges & trust (award/remove badge, manual badges, get/set trust factor, user internal profile). Every `ModerationApi` method accepts an `sso` parameter so it can be called on behalf of an SSO-authenticated moderator.
2222

2323
## Quick Start
2424

@@ -86,6 +86,27 @@ except Exception as e:
8686
print(f"Error: {e}")
8787
```
8888

89+
### Using the Moderation Dashboard (ModerationApi)
90+
91+
The `ModerationApi` powers the moderator dashboard. Methods are called on behalf of a moderator by passing an `sso` token:
92+
93+
```python
94+
from client import ApiClient, Configuration, ModerationApi
95+
96+
config = Configuration()
97+
config.host = "https://fastcomments.com/api"
98+
99+
api_client = ApiClient(configuration=config)
100+
moderation_api = ModerationApi(api_client)
101+
102+
try:
103+
# Count the comments awaiting moderation
104+
response = moderation_api.get_count(sso="SSO_TOKEN")
105+
print(response)
106+
except Exception as e:
107+
print(f"Error: {e}")
108+
```
109+
89110
### Using SSO (Single Sign-On)
90111

91112
The SDK includes utilities for generating secure SSO tokens:
@@ -131,7 +152,7 @@ sso_token = sso.create_token()
131152
### Common Issues
132153

133154
1. **401 "missing-api-key" error**: Make sure you set `config.api_key = {"ApiKeyAuth": "YOUR_KEY"}` before creating the DefaultApi instance.
134-
2. **Wrong API class**: Use `DefaultApi` for server-side authenticated requests, `PublicApi` for client-side/public requests.
155+
2. **Wrong API class**: Use `DefaultApi` for server-side authenticated requests, `PublicApi` for client-side/public requests, and `ModerationApi` for moderator dashboard requests.
135156
3. **Import errors**: Make sure you're importing from the correct module:
136157
- API client: `from client import ...`
137158
- SSO utilities: `from sso import ...`

0 commit comments

Comments
 (0)