Skip to content

Commit

Permalink
Merge pull request #75 from Martijnvos/feat/support-context-messageid…
Browse files Browse the repository at this point in the history
…-on-whatsapp

Support Context.MessageId field on Whatsapp
  • Loading branch information
Alkiimista authored Jan 13, 2025
2 parents ba0cb72 + 36292d0 commit 7001c91
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.11.0] - 2025-01-10
### Added
- Context.MessageId on RichMessages supporting WhatsApp for referencing a previous message

## [2.10.0] - 2024-12-30
### Added
- Polymorphic type discriminators on IRichMessage for deserialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public class ContactMessage : IRichMessage
/// </summary>
[JsonPropertyName("contacts")]
public Contact[] Contacts { get; set; }

/// <summary>
/// Contextual properties of the message
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@ public class LocationPushMessage : IRichMessage
/// </summary>
[JsonPropertyName("location")]
public ViewLocationOptions Location { get; set; }

/// <summary>
/// Contextual properties of the message. Only applicable to <see cref="Channel.WhatsApp"/>
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}
}
7 changes: 7 additions & 0 deletions CM.Text/BusinessMessaging/Model/MultiChannel/MediaMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@ public MediaMessage(string mediaName, string mediaUri, string mimeType)
/// </summary>
[JsonPropertyName("media")]
public MediaContent Media { get; set; }

/// <summary>
/// Contextual properties of the message. Only applicable to <see cref="Channel.WhatsApp"/>
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}
}
19 changes: 19 additions & 0 deletions CM.Text/BusinessMessaging/Model/MultiChannel/MessageContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Text.Json.Serialization;
using JetBrains.Annotations;

namespace CM.Text.BusinessMessaging.Model.MultiChannel
{
/// <summary>
/// Contextual properties of the message. Currently only applicable to <see cref="Channel.WhatsApp" />
/// Docs: https://developers.cm.com/messaging/docs/whatsapp-inbound#mt-replies-mo
/// </summary>
public class MessageContext
{
/// <summary>
/// Message ID to which the current message is a reply
/// </summary>
[JsonPropertyName("message_id")]
[CanBeNull]
public string MessageId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ public class TemplateMessage : IRichMessage
/// </remarks>
[JsonPropertyName("template")]
public TemplateMessageContent Content { get; set; }

/// <summary>
/// Contextual properties of the message
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}
}
7 changes: 7 additions & 0 deletions CM.Text/BusinessMessaging/Model/MultiChannel/TextMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@ public TextMessage(string text)
/// </summary>
[JsonPropertyName("suggestions")]
public SuggestionBase[] Suggestions { get; set; }

/// <summary>
/// Contextual properties of the message. Currently only applicable to <see cref="Channel.WhatsApp" />
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public class WhatsAppInteractiveMessage : IRichMessage
/// </summary>
[JsonPropertyName("interactive")]
public WhatsAppInteractiveContent whatsAppInteractiveContent { get; set; }

/// <summary>
/// Contextual properties of the message
/// </summary>
[JsonPropertyName("context")]
[CanBeNull]
public MessageContext MessageContext { get; set; }
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions CM.Text/CM.Text.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>icon.png</PackageIcon>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md"))</PackageReleaseNotes>
<Version>2.10.0</Version>
<Version>2.11.0</Version>
<PackageProjectUrl>https://github.com/cmdotcom/text-sdk-dotnet</PackageProjectUrl>
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyVersion>2.10.0</AssemblyVersion>
<FileVersion>2.10.0</FileVersion>
<AssemblyVersion>2.11.0</AssemblyVersion>
<FileVersion>2.11.0</FileVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

Expand Down

0 comments on commit 7001c91

Please sign in to comment.