Skip to content

Add derived types to Suggestions#78

Merged
Alkiimista merged 6 commits intocmdotcom:masterfrom
Martijnvos:fix/suggestions-missing-derived-types
Jan 31, 2025
Merged

Add derived types to Suggestions#78
Alkiimista merged 6 commits intocmdotcom:masterfrom
Martijnvos:fix/suggestions-missing-derived-types

Conversation

@Martijnvos
Copy link

@Martijnvos Martijnvos commented Jan 29, 2025

Derived types declarations (similar to IRichMessage) are missing on BaseSuggestion, breaking serialization. This is shown with a simple test ran against the current master branch:

[TestClass]
public class SuggestionsTests
{
  [TestMethod]
  public void SerializationReplySuggestionTest()
  {
      var replySuggestion = new ReplySuggestion()
      {
          Label = "Some label",
          PostbackData = "LABEL",
          Description = "Description of the label",
          Media = new MediaContent("Test image", "https://example.com", "image/jpg")
      };
      var serialized= JsonSerializer.Serialize<SuggestionBase>(replySuggestion);
  }
}

serialized will then look as follows, missing the description field and media object:

{
  "action" : "reply",
  "label" : "Some label",
  "postbackdata" : "LABEL"
}

Couple extra notes:

  • I've kept the casing and the discriminator itself consistent
  • I've left in the Description field, though the summary says it only applies to Twitter which is now deprecated
  • I've had to add a getter and setter to EndTime and StartTime in CalendarOptions for those fields to be picked up during serialization
  • I'm considering this a patch version update since it's backwards compatible and fixes things that were previously overlooked

@Martijnvos Martijnvos marked this pull request as ready for review January 29, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants