Skip to content

Commit c6d2a67

Browse files
authored
Merge pull request #4 from FastComments/regen-moderation-api
Add Moderation API and stable response types
2 parents 7f26b11 + e9b554b commit c6d2a67

1,103 files changed

Lines changed: 71845 additions & 23306 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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: '3.1'
25+
- name: Install dependencies
26+
run: |
27+
bundle config set --local frozen false
28+
bundle install --jobs 4
29+
- name: Run tests
30+
run: bundle exec rspec
31+
env:
32+
FASTCOMMENTS_API_KEY: ${{ secrets.FASTCOMMENTS_API_KEY }}
33+
FASTCOMMENTS_TENANT_ID: ${{ secrets.FASTCOMMENTS_TENANT_ID }}

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ This library contains the generated API client and the SSO utilities to make wor
2929

3030
### Public vs Secured APIs
3131

32-
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
33-
that can be made directly from a browser/mobile device/etc without authentication.
32+
For the API client, there are three classes, `DefaultApi`, `PublicApi`, and `ModerationApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains api calls
33+
that can be made directly from a browser/mobile device/etc without authentication. The `ModerationApi` contains the methods that power the moderator dashboard.
34+
35+
The `ModerationApi` covers comment moderation (list, count, search, logs, export), moderation actions (remove/restore, flag, set review/spam/approval status, votes, reopen/close thread),
36+
bans (ban from a 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).
37+
Each `ModerationApi` method accepts an `sso` parameter so the request can be made on behalf of an SSO-authenticated moderator.
3438

3539
## Quick Start
3640

@@ -91,10 +95,30 @@ rescue FastCommentsClient::ApiError => e
9195
end
9296
```
9397

98+
### Using Moderation APIs (ModerationApi)
99+
100+
The moderation methods power the moderator dashboard. Pass an `sso` token so the request is made on behalf of an SSO-authenticated moderator:
101+
102+
```ruby
103+
require 'fastcomments'
104+
105+
moderation_api = FastCommentsClient::ModerationApi.new
106+
107+
begin
108+
# Example: List comments in the moderation queue
109+
response = moderation_api.get_api_comments(
110+
sso: 'YOUR_MODERATOR_SSO_TOKEN'
111+
)
112+
puts response
113+
rescue FastCommentsClient::ApiError => e
114+
puts e.message
115+
end
116+
```
117+
94118
### Common Issues
95119

96120
1. **401 "missing-api-key" error**: Make sure you set `config.api_key['x-api-key'] = 'YOUR_KEY'` before creating the DefaultApi instance.
97-
2. **Wrong API class**: Use `DefaultApi` for server-side authenticated requests, `PublicApi` for client-side/public requests.
121+
2. **Wrong API class**: Use `DefaultApi` for server-side authenticated requests, `PublicApi` for client-side/public requests, and `ModerationApi` for moderator dashboard requests.
98122
3. **Null API key**: The SDK will silently skip authentication if the API key is null, leading to 401 errors.
99123

100124
## Notes

0 commit comments

Comments
 (0)