diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.Serialization.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.Serialization.cs
index c2465e016973a..b36083b5ec869 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.Serialization.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.Serialization.cs
@@ -15,41 +15,41 @@ public partial class WhatsAppMessageTemplateBindings : IUtf8JsonSerializable
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
- if (Optional.IsCollectionDefined(Header))
+ if (Optional.IsCollectionDefined(HeaderInternal))
{
writer.WritePropertyName("header"u8);
writer.WriteStartArray();
- foreach (var item in Header)
+ foreach (var item in HeaderInternal)
{
writer.WriteObjectValue(item);
}
writer.WriteEndArray();
}
- if (Optional.IsCollectionDefined(Body))
+ if (Optional.IsCollectionDefined(BodyInternal))
{
writer.WritePropertyName("body"u8);
writer.WriteStartArray();
- foreach (var item in Body)
+ foreach (var item in BodyInternal)
{
writer.WriteObjectValue(item);
}
writer.WriteEndArray();
}
- if (Optional.IsCollectionDefined(Footer))
+ if (Optional.IsCollectionDefined(FooterInternal))
{
writer.WritePropertyName("footer"u8);
writer.WriteStartArray();
- foreach (var item in Footer)
+ foreach (var item in FooterInternal)
{
writer.WriteObjectValue(item);
}
writer.WriteEndArray();
}
- if (Optional.IsCollectionDefined(Buttons))
+ if (Optional.IsCollectionDefined(ButtonsInternal))
{
writer.WritePropertyName("buttons"u8);
writer.WriteStartArray();
- foreach (var item in Buttons)
+ foreach (var item in ButtonsInternal)
{
writer.WriteObjectValue(item);
}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.cs b/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.cs
index 850738342aba7..9fbf505d28f25 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Generated/WhatsAppMessageTemplateBindings.cs
@@ -14,37 +14,5 @@ namespace Azure.Communication.Messages.Models.Channels
/// The template bindings for WhatsApp.
public partial class WhatsAppMessageTemplateBindings : MessageTemplateBindings
{
- /// Initializes a new instance of .
- public WhatsAppMessageTemplateBindings()
- {
- Kind = "whatsApp";
- Header = new ChangeTrackingList();
- Body = new ChangeTrackingList();
- Footer = new ChangeTrackingList();
- Buttons = new ChangeTrackingList();
- }
-
- /// Initializes a new instance of .
- /// Discriminator.
- /// The header template bindings.
- /// The body template bindings.
- /// The footer template bindings.
- /// The button template bindings.
- internal WhatsAppMessageTemplateBindings(string kind, IList header, IList body, IList footer, IList buttons) : base(kind)
- {
- Header = header;
- Body = body;
- Footer = footer;
- Buttons = buttons;
- }
-
- /// The header template bindings.
- public IList Header { get; }
- /// The body template bindings.
- public IList Body { get; }
- /// The footer template bindings.
- public IList Footer { get; }
- /// The button template bindings.
- public IList Buttons { get; }
}
}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppMessageTemplateBindings.cs b/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppMessageTemplateBindings.cs
new file mode 100644
index 0000000000000..4abae496ffb9b
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppMessageTemplateBindings.cs
@@ -0,0 +1,111 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using Azure.Communication.Messages;
+using Azure.Core;
+
+namespace Azure.Communication.Messages.Models.Channels
+{
+
+ /// The template bindings for WhatsApp.
+ [CodeGenModel("WhatsAppMessageTemplateBindings")]
+ public partial class WhatsAppMessageTemplateBindings
+ {
+
+ /// The header template bindings.
+ [CodeGenMember("Header")]
+ internal IList HeaderInternal {
+ get
+ {
+ var header = new ChangeTrackingList();
+ foreach (string item in Header)
+ {
+ header.Add(new WhatsAppMessageTemplateBindingsComponent(item));
+ }
+
+ return header;
+ }
+ }
+
+ /// The body template bindings.
+ [CodeGenMember("Body")]
+ internal IList BodyInternal
+ {
+ get
+ {
+ var body = new ChangeTrackingList();
+ foreach (string item in Body)
+ {
+ body.Add(new WhatsAppMessageTemplateBindingsComponent(item));
+ }
+
+ return body;
+ }
+ }
+
+ /// The footer template bindings.
+ [CodeGenMember("Footer")]
+ internal IList FooterInternal
+ {
+ get
+ {
+ var footer = new ChangeTrackingList();
+ foreach (string item in Footer)
+ {
+ footer.Add(new WhatsAppMessageTemplateBindingsComponent(item));
+ }
+
+ return footer;
+ }
+ }
+ /// The button template bindings.
+ [CodeGenMember("Buttons")]
+ internal IList ButtonsInternal
+ {
+ get
+ {
+ var buttons = new ChangeTrackingList();
+ foreach (var item in Buttons)
+ {
+ buttons.Add(new WhatsAppMessageTemplateBindingsButton(item.Key) { SubType = item.Value.ToString() });
+ }
+
+ return buttons;
+ }
+ }
+
+ /// The header template bindings.
+ public IList Header { get; set; } = new List();
+
+ /// The body template bindings.
+ public IList Body { get; set; } = new List();
+
+ /// The footer template bindings.
+ public IList Footer { get; set; } = new List();
+
+ /// The button template bindings.
+ public IList> Buttons { get; set; } = new List> ();
+
+ /// Initializes a new instance of .
+ public WhatsAppMessageTemplateBindings()
+ {
+ Kind = "whatsApp";
+ }
+
+ // This is a direct copy of the auto-rest generated constructor but we want to make the internal bindings read only
+ /// Initializes a new instance of .
+ /// Discriminator.
+ /// The header template bindings.
+ /// The body template bindings.
+ /// The footer template bindings.
+ /// The button template bindings.
+ internal WhatsAppMessageTemplateBindings(string kind, IList headerInternal, IList bodyInternal, IList footerInternal, IList buttonsInternal) : base(kind)
+ {
+ }
+ }
+}
diff --git a/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppModels.cs b/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppModels.cs
index 4b0fdf75cb38c..77e608591f5ec 100644
--- a/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppModels.cs
+++ b/sdk/communication/Azure.Communication.Messages/src/Models/Channels/WhatsAppModels.cs
@@ -9,9 +9,6 @@ namespace Azure.Communication.Messages.Models.Channels
[CodeGenModel("WhatsAppMessageButtonSubType")]
public partial struct WhatsAppMessageButtonSubType { }
- [CodeGenModel("WhatsAppMessageTemplateBindings")]
- public partial class WhatsAppMessageTemplateBindings { }
-
[CodeGenModel("WhatsAppMessageTemplateBindingsButton")]
public partial class WhatsAppMessageTemplateBindingsButton { }
diff --git a/sdk/communication/Azure.Communication.Messages/tests/NotificationMessagesClient/NotificationMessagesClientLiveTests.cs b/sdk/communication/Azure.Communication.Messages/tests/NotificationMessagesClient/NotificationMessagesClientLiveTests.cs
index 253d5834cbd06..12e6a348b9bea 100644
--- a/sdk/communication/Azure.Communication.Messages/tests/NotificationMessagesClient/NotificationMessagesClientLiveTests.cs
+++ b/sdk/communication/Azure.Communication.Messages/tests/NotificationMessagesClient/NotificationMessagesClientLiveTests.cs
@@ -57,7 +57,7 @@ public async Task SendShippingConfirmationTemplateMessageShouldSucceed()
var ThreeDays = new MessageTemplateText("threeDays", "3");
WhatsAppMessageTemplateBindings bindings = new();
- bindings.Body.Add(new(ThreeDays.Name));
+ bindings.Body.Add(ThreeDays.Name);
MessageTemplate template = new("sample_shipping_confirmation", "en_us")
{
@@ -86,8 +86,8 @@ public async Task SendPurchaseFeedbackTemplateMessageShouldSucceed()
var product = new MessageTemplateText("product", "Microsoft Office");
WhatsAppMessageTemplateBindings bindings = new();
- bindings.Header.Add(new(image.Name));
- bindings.Body.Add(new(product.Name));
+ bindings.Header.Add(image.Name);
+ bindings.Body.Add(product.Name);
MessageTemplate template = new("sample_purchase_feedback", "en_us");
template.Values.Add(image);
@@ -114,10 +114,14 @@ public async Task SendIssueResolutionTemplateMessageShouldSucceed()
var yes = new MessageTemplateQuickAction("yes") { Payload = "Yay!" };
var no = new MessageTemplateQuickAction("no") { Payload = "Nay!" };
- WhatsAppMessageTemplateBindings bindings = new();
- bindings.Body.Add(new(name.Name));
- bindings.Buttons.Add(new(yes.Name) { SubType = WhatsAppMessageButtonSubType.QuickReply.ToString() });
- bindings.Buttons.Add(new(no.Name) { SubType = WhatsAppMessageButtonSubType.QuickReply.ToString() });
+ WhatsAppMessageTemplateBindings bindings = new()
+ {
+ Body = new[] { name.Name },
+ Buttons = new[] {
+ new KeyValuePair(yes.Name, WhatsAppMessageButtonSubType.QuickReply),
+ new KeyValuePair(no.Name, WhatsAppMessageButtonSubType.QuickReply),
+ }
+ };
MessageTemplate template = new("sample_issue_resolution", "en_us")
{
@@ -149,9 +153,9 @@ public async Task SendHappyHourAnnocementTemplateMessageShouldSucceed()
var video = new MessageTemplateVideo("video", new Uri(VideoUrl));
WhatsAppMessageTemplateBindings bindings = new();
- bindings.Header.Add(new(video.Name));
- bindings.Body.Add(new(venue.Name));
- bindings.Body.Add(new(time.Name));
+ bindings.Header.Add(video.Name);
+ bindings.Body.Add(venue.Name);
+ bindings.Body.Add(time.Name);
MessageTemplate template = new("sample_happy_hour_announcement", "en_us");
template.Values.Add(venue);
@@ -182,10 +186,10 @@ public async Task SendFlightConfirmationTemplateMessageShouldSucceed()
var date = new MessageTemplateText("date", "July 1st, 2023");
WhatsAppMessageTemplateBindings bindings = new();
- bindings.Header.Add(new(document.Name));
- bindings.Body.Add(new(firstName.Name));
- bindings.Body.Add(new(lastName.Name));
- bindings.Body.Add(new(date.Name));
+ bindings.Header.Add(document.Name);
+ bindings.Body.Add(firstName.Name);
+ bindings.Body.Add(lastName.Name);
+ bindings.Body.Add(date.Name);
MessageTemplate template = new("sample_flight_confirmation", "en_us");
template.Values.Add(document);
@@ -218,11 +222,11 @@ public async Task SendMovieTicketConfirmationTemplateMessageShouldSucceed()
var seats = new MessageTemplateText("seats", "Seat 1A");
WhatsAppMessageTemplateBindings bindings = new();
- bindings.Header.Add(new(image.Name));
- bindings.Body.Add(new(title.Name));
- bindings.Body.Add(new(time.Name));
- bindings.Body.Add(new(venue.Name));
- bindings.Body.Add(new(seats.Name));
+ bindings.Header.Add(image.Name);
+ bindings.Body.Add(title.Name);
+ bindings.Body.Add(time.Name);
+ bindings.Body.Add(venue.Name);
+ bindings.Body.Add(seats.Name);
MessageTemplate template = new("sample_movie_ticket_confirmation", "en_us");
template.Values.Add(image);