Skip to content

Commit 88fe167

Browse files
Message integration base class functions
1 parent 9be9ebb commit 88fe167

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed
Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
using AzureDevopsTracker.Entities;
22
using System;
3-
using System.Collections.Generic;
3+
using System.Net.Http;
44
using System.Text;
5+
using System.Text.Json;
56

67
namespace AzureDevopsTracker.Integrations
78
{
8-
internal abstract class MessageIntegration
9+
public abstract class MessageIntegration
910
{
10-
internal abstract void Send(ChangeLog changeLog);
11+
public abstract void Send(ChangeLog changeLog);
12+
private static readonly string MIMETYPE = "application/json";
1113

12-
internal string GetTitle(ChangeLog changeLog)
14+
protected string GetTitle(ChangeLog changeLog)
1315
{
14-
System.Resources.ResourceManager mgr = new
15-
System.Resources.ResourceManager("AzureDvevopsTracker.Resource",
16-
System.Reflection.Assembly.GetExecutingAssembly());
16+
return $"Nova atualização da plataforma";
17+
}
18+
19+
protected string GetVersion(ChangeLog changeLog)
20+
{
21+
return $"Versao: { changeLog.Number}";
22+
}
1723

18-
return "";
24+
protected string GetNugetVersion()
25+
{
26+
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
27+
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
28+
return $"Powered by Typing Hard • { fileVersionInfo.FileVersion }";
29+
}
30+
31+
protected HttpResponseMessage Notify(object body)
32+
{
33+
var json = JsonSerializer.Serialize(body);
34+
var content = new StringContent(json,
35+
Encoding.UTF8,
36+
MIMETYPE);
37+
HttpClient client = new HttpClient();
38+
return client.PostAsync(new Uri(MessageConfig.URL),
39+
content).Result;
1940
}
2041
}
2142
}

0 commit comments

Comments
 (0)