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
1 change: 1 addition & 0 deletions src/ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}

// Delete campaign
public async Task<StreamResponse<DeleteCampaignResponse>> DeleteCampaignAsync(string id, object request = null,

Check warning on line 67 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 67 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand All @@ -80,7 +80,7 @@
}

// Get campaign by ID.
public async Task<StreamResponse<GetCampaignResponse>> GetCampaignAsync(string id, object request = null,

Check warning on line 83 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 83 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand Down Expand Up @@ -260,7 +260,7 @@

// Sends events:
// - channel.deleted
public async Task<StreamResponse<DeleteChannelResponse>> DeleteChannelAsync(string type, string id, object request = null,

Check warning on line 263 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 263 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand All @@ -278,7 +278,7 @@
}

// Returns a channel by its CID without creating it. Responds with 404 when the channel does not exist, so it doubles as an existence check. Pass state=true to also load messages, read state and watchers.
public async Task<StreamResponse<ChannelStateResponse>> GetChannelAsync(string type, string id, object request = null,

Check warning on line 281 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 281 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand Down Expand Up @@ -343,7 +343,7 @@

// Sends events:
// - draft.deleted
public async Task<StreamResponse<Response>> DeleteDraftAsync(string type, string id, object request = null,

Check warning on line 346 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 346 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand All @@ -361,7 +361,7 @@
}

// Get a draft
public async Task<StreamResponse<GetDraftResponse>> GetDraftAsync(string type, string id, object request = null,

Check warning on line 364 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 364 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand Down Expand Up @@ -396,7 +396,7 @@
}

// Deletes previously uploaded file
public async Task<StreamResponse<Response>> DeleteChannelFileAsync(string type, string id, object request = null,

Check warning on line 399 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 399 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand Down Expand Up @@ -451,7 +451,7 @@
}

// Deletes previously uploaded image
public async Task<StreamResponse<Response>> DeleteChannelImageAsync(string type, string id, object request = null,

Check warning on line 454 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 454 in src/ChatClient.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
Expand Down Expand Up @@ -506,6 +506,7 @@
// Sends new message to the specified channel

// Sends events:
// - channel.visible
// - message.new
// - message.updated
public async Task<StreamResponse<SendMessageResponse>> SendMessageAsync(string type, string id, SendMessageRequest request,
Expand Down
18 changes: 16 additions & 2 deletions src/CommonClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ public async Task<StreamResponse<CreateBlockListResponse>> CreateBlockListAsync(

return result;
}
public async Task<StreamResponse<ImportBlockListResponse>> ImportBlockListAsync(string id, ImportBlockListRequest request,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await MakeRequestAsync<ImportBlockListRequest, ImportBlockListResponse>(
"POST",
"/api/v2/blocklists/{id}/import", null, request, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<Response>> DeleteBlockListAsync(string name, object request = null,
CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -642,11 +657,10 @@ public async Task<StreamResponse<PollOptionResponse>> GetPollOptionAsync(string
["poll_id"] = pollID,
["option_id"] = optionID,
};
var queryParams = ExtractQueryParams(request);

var result = await MakeRequestAsync<object, PollOptionResponse>(
"GET",
"/api/v2/polls/{poll_id}/options/{option_id}", queryParams, null, pathParams,
"/api/v2/polls/{poll_id}/options/{option_id}", null, null, pathParams,
cancellationToken);

return result;
Expand Down
101 changes: 96 additions & 5 deletions src/ModerationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,25 +403,33 @@ public async Task<StreamResponse<UpsertModerationRuleResponse>> UpsertModeration

return result;
}
public async Task<StreamResponse<DeleteModerationRuleResponse>> DeleteModerationRuleAsync(object request = null,
public async Task<StreamResponse<DeleteModerationRuleResponse>> DeleteModerationRuleAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};
var queryParams = ExtractQueryParams(request);

var result = await _client.MakeRequestAsync<object, DeleteModerationRuleResponse>(
"DELETE",
"/api/v2/moderation/moderation_rule/{id}", queryParams, null, null,
"/api/v2/moderation/moderation_rule/{id}", queryParams, null, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<GetModerationRuleResponse>> GetModerationRuleAsync(object request = null,
public async Task<StreamResponse<GetModerationRuleResponse>> GetModerationRuleAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<object, GetModerationRuleResponse>(
"GET",
"/api/v2/moderation/moderation_rule/{id}", null, null, null,
"/api/v2/moderation/moderation_rule/{id}", null, null, pathParams,
cancellationToken);

return result;
Expand All @@ -448,13 +456,96 @@ public async Task<StreamResponse<MuteResponse>> MuteAsync(MuteRequest request,

return result;
}
public async Task<StreamResponse<PolicyTestRunResponse>> GetPolicyTestRunAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<object, PolicyTestRunResponse>(
"GET",
"/api/v2/moderation/policy_tests/runs/{id}", null, null, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<PolicyTestSetListResponse>> ListPolicyTestSetsAsync(object request = null,
CancellationToken cancellationToken = default)
{

var result = await _client.MakeRequestAsync<object, PolicyTestSetListResponse>(
"GET",
"/api/v2/moderation/policy_tests/sets", null, null, null,
cancellationToken);

return result;
}
public async Task<StreamResponse<PolicyTestSetResponse>> CreatePolicyTestSetAsync(CreatePolicyTestSetRequest request,
CancellationToken cancellationToken = default)
{

var result = await _client.MakeRequestAsync<CreatePolicyTestSetRequest, PolicyTestSetResponse>(
"POST",
"/api/v2/moderation/policy_tests/sets", null, request, null,
cancellationToken);

return result;
}
public async Task<StreamResponse<Response>> DeletePolicyTestSetAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<object, Response>(
"DELETE",
"/api/v2/moderation/policy_tests/sets/{id}", null, null, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<PolicyTestSetResponse>> GetPolicyTestSetAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<object, PolicyTestSetResponse>(
"GET",
"/api/v2/moderation/policy_tests/sets/{id}", null, null, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<PolicyTestRunResponse>> StartPolicyTestRunAsync(string id, object request = null,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<object, PolicyTestRunResponse>(
"POST",
"/api/v2/moderation/policy_tests/sets/{id}/runs", null, null, pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<ListQueuesResponse>> ListQueuesAsync(object request = null,
CancellationToken cancellationToken = default)
{
var queryParams = ExtractQueryParams(request);

var result = await _client.MakeRequestAsync<object, ListQueuesResponse>(
"GET",
"/api/v2/moderation/queues", null, null, null,
"/api/v2/moderation/queues", queryParams, null, null,
cancellationToken);

return result;
Expand Down
2 changes: 2 additions & 0 deletions src/Webhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static class WebhookEventType
public const string MessageUnblocked = "message.unblocked";
public const string MessageUndeleted = "message.undeleted";
public const string MessageUpdated = "message.updated";
public const string ModerationAnalysisFailed = "moderation.analysis.failed";
public const string ModerationCustomAction = "moderation.custom_action";
public const string ModerationFlagged = "moderation.flagged";
public const string ModerationImageAnalysisComplete = "moderation.image_analysis.complete";
Expand Down Expand Up @@ -415,6 +416,7 @@ private static Type GetEventTypeClass(string eventType)
"message.unblocked" => typeof(MessageUnblockedEvent),
"message.undeleted" => typeof(MessageUndeletedEvent),
"message.updated" => typeof(MessageUpdatedEvent),
"moderation.analysis.failed" => typeof(ModerationAnalysisFailedEvent),
"moderation.custom_action" => typeof(ModerationCustomActionEvent),
"moderation.flagged" => typeof(ModerationFlaggedEvent),
"moderation.image_analysis.complete" => typeof(ModerationImageAnalysisCompleteEvent),
Expand Down
Loading
Loading