Created
October 2, 2019 09:42
-
-
Save beachside-project/d762b2318485b1f276007e74f9223229 to your computer and use it in GitHub Desktop.
CustomBindingsSamples.TeamsBinding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
namespace CustomBindingsSamples.TeamsBinding | |
{ | |
public class TeamsMessage | |
{ | |
private readonly JsonSerializerSettings _settings = new JsonSerializerSettings() | |
{ | |
ContractResolver = new CamelCasePropertyNamesContractResolver() | |
}; | |
public string Title { get; set; } // TODO: validation check | |
public string Text { get; set; } // TODO: validation check | |
public string LinkUri | |
{ | |
get => PotentialAction[0].Targets[0].Uri; | |
set | |
{ | |
// TODO: validation check | |
PotentialAction[0].Targets[0].Uri = value; | |
} | |
} | |
public string ThemeColor { get; set; } = "0072C6"; | |
[JsonProperty("@context")] | |
private string Context => "https://schema.org/extensions"; | |
[JsonProperty("@type")] | |
private string CardType => "MessageCard"; | |
[JsonProperty] | |
private PotentialAction[] PotentialAction { get; } = { new PotentialAction() }; | |
public string ToJson() => JsonConvert.SerializeObject(this, settings: _settings); | |
} | |
internal class PotentialAction | |
{ | |
[JsonProperty("@type")] | |
private string Type => "OpenUri"; | |
[JsonProperty] | |
private string Name => "View More"; | |
public Target[] Targets { get; } = { new Target() }; | |
} | |
internal class Target | |
{ | |
[JsonProperty] | |
private string Os => "default"; | |
public string Uri { get; internal set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment