-
Notifications
You must be signed in to change notification settings - Fork 4
/
Webhook.cs
54 lines (46 loc) · 1.34 KB
/
Webhook.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.IO;
using System.Text;
namespace TownCrier
{
public class Webhook
{
public string Name { get; set; }
public string Method { get; set; }
public string URLFormatString { get; set; }
public string PayloadFormatString { get; set; }
public Webhook(string name, string url, string method, string payload)
{
Name = name;
URLFormatString = url;
Method = method;
PayloadFormatString = payload;
}
public override string ToString()
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append("Webhook: Name: '");
sb.Append(Name);
sb.Append("', URL: '");
sb.Append(URLFormatString);
sb.Append(" (");
sb.Append(Method);
sb.Append(") with payload '");
sb.Append(PayloadFormatString);
sb.Append("'.");
return sb.ToString();
}
catch (Exception ex)
{
Utilities.LogError(ex);
return "Failed to print Webhook";
}
}
public string ToJSON()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
}
}
}