Skip to content

Commit

Permalink
Fix serialization + version change + nuget update
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomez90 committed Aug 17, 2022
1 parent a0f2ee6 commit f26e5fc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.2.0-pre3</Version>
<Version>0.2.0-pre4</Version>
<Product>TeamsHook.NET</Product>
<Description>.NET Client for sending messages to Microsoft Teams via Webhooks</Description>
<Company>Rafael Gómez</Company>
Expand Down
11 changes: 6 additions & 5 deletions TeamsHook.NET.Tests/SystemTextJsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void JsonTestActionsMessageCard()
[Fact]
public async Task JsonTestMessageCardClient()
{
const string UriWebhook = @"https://outlook.office.com/webhook/d3470767-e202-4f22-8251-a42d92916355@4cccefa5-026f-4183-ba9d-ca1ff6e6bb59/IncomingWebhook/ba9e479c10b540a2bdffe7a1493879d3/e2d090c3-7509-4c54-a95f-678a5af6d85b";
const string UriWebhook = @"https://hengesbachgmbh.webhook.office.com/webhookb2/f4d42301-3481-42e4-8b9f-cc7616ccb768@4cccefa5-026f-4183-ba9d-ca1ff6e6bb59/IncomingWebhook/fe635dbed4b642a4aeb57eb7221a7ca1/e2d090c3-7509-4c54-a95f-678a5af6d85b";

var opt = new JsonSerializerOptions()
{
Expand Down Expand Up @@ -127,10 +127,11 @@ public async Task JsonTestMessageCardClient()
}
}
};
var json = JsonSerializer.Serialize(card, opt);
using var client = new HttpClient();
var response = await client.PostAsync(UriWebhook, new StringContent(json, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();

var client = new TeamsHookClient();
var response = await client.PostAsync(UriWebhook, card);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions TeamsHook.NET.Tests/TeamsHook.NET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0-preview-20220131-20" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.0-preview.4.22229.4" />
<PackageReference Include="xunit" Version="2.4.2-pre.12" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion TeamsHook.NET/TeamsHook.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Text.Json" Version="6.0.2" />
<PackageReference Include="System.Text.Json" Version="7.0.0-preview.4.22229.4" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TeamsHook.NET/TeamsHookClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TeamsHookClient(HttpClient client = null)

public Task<HttpResponseMessage> PostAsync(string webhookUrl, TeamsCard card)
{
var payload = JsonSerializer.Serialize(card, _jsonSettings);
var payload = JsonSerializer.Serialize(card, card.GetType(), _jsonSettings);
return _client.PostAsync(webhookUrl, new StringContent(payload, Encoding.UTF8, "application/json"));
}
}
Expand Down

0 comments on commit f26e5fc

Please sign in to comment.