mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Fixes #2448. Forward slash is no longer appended to the URL. If a user wants a / at the end of the URL, they will have to enter it in the webhook baseUrl.
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Newtonsoft.Json.Serialization;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ombi.Api.Webhook
|
|
{
|
|
public class WebhookApi : IWebhookApi
|
|
{
|
|
private static readonly CamelCasePropertyNamesContractResolver _nameResolver = new CamelCasePropertyNamesContractResolver();
|
|
|
|
public WebhookApi(IApi api)
|
|
{
|
|
_api = api;
|
|
}
|
|
|
|
private readonly IApi _api;
|
|
|
|
public async Task PushAsync(string baseUrl, string accessToken, IDictionary<string, string> parameters)
|
|
{
|
|
var request = new Request("", baseUrl, HttpMethod.Post);
|
|
|
|
if (!string.IsNullOrWhiteSpace(accessToken))
|
|
{
|
|
request.AddHeader("Access-Token", accessToken);
|
|
}
|
|
|
|
var body = parameters.ToDictionary(
|
|
x => _nameResolver.GetResolvedPropertyName(x.Key),
|
|
x => x.Value
|
|
);
|
|
|
|
request.ApplicationJsonContentType();
|
|
request.AddJsonBody(body);
|
|
|
|
await _api.Request(request);
|
|
}
|
|
}
|
|
}
|