I'm developing a Telegram bot in C# but have difficulty with implementing Message type. According to API documentation, chat field can be either of type User or of type GroupChat. How do I implement that in C#?
So far I could only come up with following code using Newtonsoft.Json:
public class Update {
....
[JsonProperty("chat")]
public User chat { get; set; }
[JsonProperty("chat")]
public GroupChat group_chat { get; set; }
....
}
But it doesn't work with my WebAPI 2 controller method since I deserialize Message using FromBody attribute:
public async Task<HttpResponseMessage> Post(string token, [FromBody] Update update)
(type Update has a field message of type Message)
Is there any better way to implement Message type?