Skip to content

Commit

Permalink
make WhatsAppMessageTemplateBindings internal
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialimicrosoft committed Jan 11, 2024
1 parent 7f1ec14 commit 2706f9d
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 62 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System.Collections.Generic;
using Azure.Communication.Messages;
using Azure.Core;

namespace Azure.Communication.Messages.Models.Channels
{

/// <summary> The template bindings for WhatsApp. </summary>
[CodeGenModel("WhatsAppMessageTemplateBindings")]
public partial class WhatsAppMessageTemplateBindings
{

/// <summary> The header template bindings. </summary>
[CodeGenMember("Header")]
internal IList<WhatsAppMessageTemplateBindingsComponent> HeaderInternal {
get
{
var header = new ChangeTrackingList<WhatsAppMessageTemplateBindingsComponent>();
foreach (string item in Header)
{
header.Add(new WhatsAppMessageTemplateBindingsComponent(item));
}

return header;
}
}

/// <summary> The body template bindings. </summary>
[CodeGenMember("Body")]
internal IList<WhatsAppMessageTemplateBindingsComponent> BodyInternal
{
get
{
var body = new ChangeTrackingList<WhatsAppMessageTemplateBindingsComponent>();
foreach (string item in Body)
{
body.Add(new WhatsAppMessageTemplateBindingsComponent(item));
}

return body;
}
}

/// <summary> The footer template bindings. </summary>
[CodeGenMember("Footer")]
internal IList<WhatsAppMessageTemplateBindingsComponent> FooterInternal
{
get
{
var footer = new ChangeTrackingList<WhatsAppMessageTemplateBindingsComponent>();
foreach (string item in Footer)
{
footer.Add(new WhatsAppMessageTemplateBindingsComponent(item));
}

return footer;
}
}
/// <summary> The button template bindings. </summary>
[CodeGenMember("Buttons")]
internal IList<WhatsAppMessageTemplateBindingsButton> ButtonsInternal
{
get
{
var buttons = new ChangeTrackingList<WhatsAppMessageTemplateBindingsButton>();
foreach (var item in Buttons)
{
buttons.Add(new WhatsAppMessageTemplateBindingsButton(item.Key) { SubType = item.Value.ToString() });
}

return buttons;
}
}

/// <summary> The header template bindings. </summary>
public IList<string> Header { get; set; } = new List<string>();

/// <summary> The body template bindings. </summary>
public IList<string> Body { get; set; } = new List<string>();

/// <summary> The footer template bindings. </summary>
public IList<string> Footer { get; set; } = new List<string>();

/// <summary> The button template bindings. </summary>
public IList<KeyValuePair<string, WhatsAppMessageButtonSubType>> Buttons { get; set; } = new List<KeyValuePair<string, WhatsAppMessageButtonSubType>> ();

/// <summary> Initializes a new instance of <see cref="WhatsAppMessageTemplateBindings"/>. </summary>
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
/// <summary> Initializes a new instance of <see cref="WhatsAppMessageTemplateBindings"/>. </summary>
/// <param name="kind"> Discriminator. </param>
/// <param name="headerInternal"> The header template bindings. </param>
/// <param name="bodyInternal"> The body template bindings. </param>
/// <param name="footerInternal"> The footer template bindings. </param>
/// <param name="buttonsInternal"> The button template bindings. </param>
internal WhatsAppMessageTemplateBindings(string kind, IList<WhatsAppMessageTemplateBindingsComponent> headerInternal, IList<WhatsAppMessageTemplateBindingsComponent> bodyInternal, IList<WhatsAppMessageTemplateBindingsComponent> footerInternal, IList<WhatsAppMessageTemplateBindingsButton> buttonsInternal) : base(kind)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down Expand Up @@ -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);
Expand All @@ -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<string, WhatsAppMessageButtonSubType>(yes.Name, WhatsAppMessageButtonSubType.QuickReply),
new KeyValuePair<string, WhatsAppMessageButtonSubType>(no.Name, WhatsAppMessageButtonSubType.QuickReply),
}
};

MessageTemplate template = new("sample_issue_resolution", "en_us")
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2706f9d

Please sign in to comment.