-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageIntegration.cs
More file actions
59 lines (51 loc) · 2.1 KB
/
MessageIntegration.cs
File metadata and controls
59 lines (51 loc) · 2.1 KB
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
55
56
57
58
59
using AzureDevopsTracker.Entities;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace AzureDevopsTracker.Integrations
{
public abstract class MessageIntegration
{
internal abstract Task Send(ChangeLog changeLog);
private static readonly string MIMETYPE = "application/json";
private static readonly string CDN_URL = "https://cdn.typinghard.tech/";
private static readonly string MEGAFONE_GIF = "megafone.gif";
private static readonly string LOGO_TYPINGHARD_16X16 = "logo-typinghard-16x16.png";
protected internal static string GetTitle()
{
return $"Nova atualização da plataforma";
}
protected internal static string GetVersion(ChangeLog changeLog)
{
return $"Versão: {changeLog.Number}";
}
protected internal static string GetAnnouncementImageUrl()
{
return $"{CDN_URL}{MEGAFONE_GIF}";
}
protected internal static string GetLogoTypingHard16x16Url()
{
return $"{CDN_URL}{LOGO_TYPINGHARD_16X16}";
}
protected internal static string GetFileVersion()
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
return fileVersionInfo.FileVersion;
}
protected internal static string GetNugetVersion()
{
return $"Powered by **Typing Hard** • nuget version {GetFileVersion()}";
}
protected internal static async Task<HttpResponseMessage> Notify(object body)
{
var json = Newtonsoft.Json.JsonConvert.SerializeObject(body);
var content = new StringContent(json,
Encoding.UTF8,
MIMETYPE);
using HttpClient client = new();
return await client.PostAsync(new Uri(MessageConfig.URL), content);
}
}
}