Skip to content

Commit

Permalink
Add SMS address point in NotificationOrderRequest for recipients with…
Browse files Browse the repository at this point in the history
… only phone no. (#613)

* Correct comment typo

* In test, add recipient with only mobile phone no. to catch scenario of #608. Includes indentation formatting

* When mapping order requests, also add SMS address points for phone no.
  • Loading branch information
hggutvik authored Sep 23, 2024
1 parent d5a6a5a commit 3de469c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/Altinn.Notifications/Mappers/OrderMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static NotificationOrderRequest MapToOrderRequest(this NotificationOrderR
addresses.Add(new EmailAddressPoint(r.EmailAddress));
}

if (!string.IsNullOrEmpty(r.MobileNumber))
{
addresses.Add(new SmsAddressPoint(r.MobileNumber));
}

return new Recipient(addresses, r.OrganizationNumber, r.NationalIdentityNumber);
})
.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Altinn.Notifications.Models;
/// A class representing a container for an order id.
/// </summary>
/// <remarks>
/// External representaion to be used in the API.
/// External representation to be used in the API.
/// </remarks>
public class NotificationOrderRequestResponseExt
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public void ForEmailMapToOrderRequest_RecipientsProvided_AreEquivalent()
NotificationChannel = NotificationChannel.Email,
Recipients = new List<Recipient>()
{
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } },
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } }
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } },
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } }
}
};

Expand Down Expand Up @@ -222,8 +222,8 @@ public void ForSmsMapToOrderRequest_RecipientsProvided_AreEquivalent()
NotificationChannel = NotificationChannel.Sms,
Recipients = new List<Recipient>()
{
new Recipient() { AddressInfo = new List<IAddressPoint>() { new SmsAddressPoint("+4740000001") } },
new Recipient() { AddressInfo = new List<IAddressPoint>() { new SmsAddressPoint("+4740000002") } }
new Recipient() { AddressInfo = new List<IAddressPoint>() { new SmsAddressPoint("+4740000001") } },
new Recipient() { AddressInfo = new List<IAddressPoint>() { new SmsAddressPoint("+4740000002") } }
}
};

Expand Down Expand Up @@ -289,7 +289,12 @@ public void MapToOrderRequest_AreEquivalent(NotificationChannelExt extChannel, N
{
Body = "sms-body",
},
Recipients = new List<RecipientExt>() { new RecipientExt() { EmailAddress = "[email protected]" }, new RecipientExt() { NationalIdentityNumber = "123456" } },
Recipients = new List<RecipientExt>()
{
new RecipientExt() { EmailAddress = "[email protected]" },
new RecipientExt() { NationalIdentityNumber = "123456" },
new RecipientExt() { MobileNumber = "+4712345678" }
},
SendersReference = "senders-reference",
RequestedSendTime = sendTime,
ConditionEndpoint = new Uri("https://vg.no"),
Expand All @@ -315,8 +320,9 @@ public void MapToOrderRequest_AreEquivalent(NotificationChannelExt extChannel, N
RequestedSendTime = sendTime,
Recipients = new List<Recipient>()
{
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } },
new Recipient() { NationalIdentityNumber = "123456" }
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") } },
new Recipient() { NationalIdentityNumber = "123456" },
new Recipient() { AddressInfo = new List<IAddressPoint>() { new SmsAddressPoint("+4712345678") } }
},
ConditionEndpoint = new Uri("https://vg.no"),
IgnoreReservation = true,
Expand Down

0 comments on commit 3de469c

Please sign in to comment.