feat: add webhooks
The following pull request is a toned down version of #29. This pull request focuses solely on adding a webhooks wrapper for ASP.NET Core/Blazor.
This is not how a ASP.NET Core webhook endpoint should look like. Prefer using the minimal API to create a route at build-time. This will let the internal ASP.NET core router handle all of the actual context.
public static class RoutingExtension {
public static void UseVoteWebhook(IRouteEndpointBuilder router, string path, ...) {
router.MapGet(path, (req) => {
...
});
}
}
Will work on it.
Done. Made it more similar to Node.js SDK' webhooks wrapper.
Example usage:
using DiscordBotsList.Api.Webhooks;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
var webhooks = new Webhooks("my webhook secret");
app.MapPost("/webhooks", webhooks.Listener((context, vote) =>
{
Console.WriteLine($"A user with the ID of {vote.VoterId} has voted us on Top.gg!");
return Task.CompletedTask;
}));
app.Run();
looks good to me
Most of this wouldn't work with the actual api. Refer to the docs here for more information.
https://docs.top.gg/docs/API/v1/webhooks/ https://docs.top.gg/docs/API/v1/integrations
So sorry! I was too fixated on top-gg/webhooks-v2-nodejs-example that I didn't notice the new webhook events. My bad. I've addressed them now.