Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add derived types to Suggestions #78

Merged

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
@Alkiimista Alkiimista merged commit d6b2d46 into cmdotcom:master Jan 31, 2025
1 check passed
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