Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Add the following to your `Package.swift` file:

```swift
dependencies: [
.package(url: "https://github.com/fastcomments/fastcomments-swift.git", from: "2.0.0")
.package(url: "https://github.com/fastcomments/fastcomments-swift.git", from: "3.0.0")
]
```

Expand Down Expand Up @@ -46,12 +46,9 @@ The FastComments Swift SDK consists of several modules:
```swift
import FastCommentsSwift

// Create API client
let publicApi = PublicAPI()

// Fetch comments for a page
do {
let response = try await publicApi.getCommentsPublic(
let response = try await PublicAPI.getCommentsPublic(
tenantId: "your-tenant-id",
urlId: "page-url-id"
)
Expand All @@ -70,15 +67,14 @@ do {
```swift
import FastCommentsSwift

// Create configuration with API key
let defaultApi = DefaultAPI()
defaultApi.apiKey = "your-api-key"
// Configure your API key on the shared configuration (sent as the x-api-key header)
FastCommentsSwiftAPIConfiguration.shared.customHeaders["x-api-key"] = "your-api-key"

// Fetch comments using authenticated API
do {
let response = try await defaultApi.getComments(
let response = try await DefaultAPI.getComments(
tenantId: "your-tenant-id",
urlId: "page-url-id"
options: .init(urlId: "page-url-id")
)

print("Total comments: \(response.count ?? 0)")
Expand All @@ -99,9 +95,11 @@ import FastCommentsSwift
// (generate it with FastCommentsSSO, see the SSO section above).
do {
let response = try await ModerationAPI.getApiComments(
page: 0,
count: 30,
sso: ssoToken
options: .init(
page: 0,
count: 30,
sso: ssoToken
)
)

print("Found \(response.comments.count) comments to moderate")
Expand Down Expand Up @@ -190,13 +188,7 @@ The `DefaultAPI` contains authenticated methods that require an API key. These m

### ModerationAPI - Moderator Dashboard Methods

The `ModerationAPI` contains methods that power the moderator dashboard. These methods cover:
- **Comment moderation** - list, count, search, retrieve logs, and export comments
- **Moderation actions** - remove/restore comments, flag, set review/spam/approval status, manage votes, and reopen/close threads
- **Bans** - ban a user from a comment, undo bans, fetch pre-ban summaries, check ban status and preferences, and read banned-user counts
- **Badges & trust** - award/remove badges, list manual badges, get/set a user's trust factor, and read a user's internal profile

Every `ModerationAPI` method accepts an `sso` parameter so moderators can be authenticated via SSO.
The `ModerationAPI` provides an extensive suite of live and fast moderation APIs. Every `ModerationAPI` method accepts an `sso` parameter and can authenticate via SSO or a FastComments.com session cookie.

**Example use case**: Building a moderation experience for moderators of your community

Expand All @@ -207,7 +199,7 @@ Every `ModerationAPI` method accepts an `sso` parameter so moderators can be aut
The Swift SDK uses modern async/await syntax for all API calls:

```swift
let response = try await publicApi.getCommentsPublic(
let response = try await PublicAPI.getCommentsPublic(
tenantId: "your-tenant-id",
urlId: "page-url-id"
)
Expand All @@ -221,11 +213,10 @@ If you're getting 401 errors when using the authenticated API:

1. **Check your API key**: Ensure you're using the correct API key from your FastComments dashboard
2. **Verify the tenant ID**: Make sure the tenant ID matches your account
3. **API key format**: The API key should be set on the API client:
3. **API key format**: The API key should be set as the `x-api-key` header on the shared configuration:

```swift
let defaultApi = DefaultAPI()
defaultApi.apiKey = "YOUR_API_KEY"
FastCommentsSwiftAPIConfiguration.shared.customHeaders["x-api-key"] = "YOUR_API_KEY"
```

4. **Using the wrong API**: Make sure you're using `DefaultAPI` (not `PublicAPI`) for authenticated calls
Expand Down
12 changes: 6 additions & 6 deletions Tests/FastCommentsSwiftTests/SSOIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class SSOIntegrationTests: XCTestCase {
urlId: testUrlId,
broadcastId: "swift-test-\(timestamp)",
commentData: commentData,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(createResponse.status, .success, "Create comment should succeed")
Expand All @@ -71,7 +71,7 @@ final class SSOIntegrationTests: XCTestCase {
let getResponse = try await PublicAPI.getCommentsPublic(
tenantId: tenantId,
urlId: testUrlId,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(getResponse.status, "success", "Get comments should succeed")
Expand Down Expand Up @@ -124,7 +124,7 @@ final class SSOIntegrationTests: XCTestCase {
urlId: testUrlId,
broadcastId: "swift-opts-\(timestamp)",
commentData: commentData,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(createResponse.status, .success, "Create comment with optional SSO fields should succeed")
Expand All @@ -140,7 +140,7 @@ final class SSOIntegrationTests: XCTestCase {
let getResponse = try await PublicAPI.getCommentsPublic(
tenantId: tenantId,
urlId: testUrlId,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(getResponse.status, "success")
Expand Down Expand Up @@ -191,7 +191,7 @@ final class SSOIntegrationTests: XCTestCase {
urlId: testUrlId,
broadcastId: "swift-simple-\(timestamp)",
commentData: commentData,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(createResponse.status, .success, "Create comment with simple SSO should succeed")
Expand All @@ -208,7 +208,7 @@ final class SSOIntegrationTests: XCTestCase {
let getResponse = try await PublicAPI.getCommentsPublic(
tenantId: tenantId,
urlId: testUrlId,
sso: token
options: .init(sso: token)
)

XCTAssertEqual(getResponse.status, "success", "Get comments with simple SSO should succeed")
Expand Down
5 changes: 5 additions & 0 deletions client/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

# Preserve manually-patched infrastructure files from being overwritten.
# NOTE: update.sh's `rm -rf ./client` wipes this file before generation, so the ignore
# alone is not enough -- update.sh also restores these files from git after generation.
FastCommentsSwift/Infrastructure/URLSessionImplementations.swift
4 changes: 2 additions & 2 deletions client/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ FastCommentsSwift/Models/PatchDomainConfigResponse.swift
FastCommentsSwift/Models/PatchPageAPIResponse.swift
FastCommentsSwift/Models/PatchSSOUserAPIResponse.swift
FastCommentsSwift/Models/PendingCommentToSyncOutbound.swift
FastCommentsSwift/Models/PostRemoveCommentResponse.swift
FastCommentsSwift/Models/PostRemoveCommentApiResponse.swift
FastCommentsSwift/Models/PreBanSummary.swift
FastCommentsSwift/Models/PubSubComment.swift
FastCommentsSwift/Models/PubSubCommentBase.swift
Expand Down Expand Up @@ -642,7 +642,7 @@ docs/PatchDomainConfigResponse.md
docs/PatchPageAPIResponse.md
docs/PatchSSOUserAPIResponse.md
docs/PendingCommentToSyncOutbound.md
docs/PostRemoveCommentResponse.md
docs/PostRemoveCommentApiResponse.md
docs/PreBanSummary.md
docs/PubSubComment.md
docs/PubSubCommentBase.md
Expand Down
4 changes: 2 additions & 2 deletions client/FastCommentsSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.15'
s.tvos.deployment_target = '13.0'
s.watchos.deployment_target = '6.0'
s.version = '1.3.2'
s.source = {"git":"https://github.com/fastcomments/fastcomments-swift.git","tag":"1.3.2"}
s.version = '3.0.0'
s.source = {"git":"https://github.com/fastcomments/fastcomments-swift.git","tag":"3.0.0"}
s.authors = 'FastComments'
s.license = MIT
s.homepage = 'https://fastcomments.com'
Expand Down
Loading
Loading