From 79f4bd67ffaa8aef8519945750bfb6bca018cd4c Mon Sep 17 00:00:00 2001 From: AJ Rice <53190766+ajrice6713@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:11:33 -0400 Subject: [PATCH 1/3] SWI-5092 Add an `ImportTnOrderSubscriber` model This is a breaking change --- Bandwidth.Iris/Model/ImportTnOrder.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Bandwidth.Iris/Model/ImportTnOrder.cs b/Bandwidth.Iris/Model/ImportTnOrder.cs index d5496a3..7752a7e 100644 --- a/Bandwidth.Iris/Model/ImportTnOrder.cs +++ b/Bandwidth.Iris/Model/ImportTnOrder.cs @@ -17,7 +17,7 @@ public class ImportTnOrder public string LastModifiedDate { get; set; } public int SiteId { get; set; } public int SipPeerId { get; set; } - public Subscriber Subscriber { get; set; } + public ImportTnOrderSubscriber Subscriber { get; set; } public TelephoneNumber[] TelephoneNumbers { get; set; } public string LoaAuthorizingPerson { get; set; } public string ProcessingStatus { get; set; } @@ -155,6 +155,12 @@ public static Task DeleteLoasFileMetadata(string orderId, string fileId) } + public class ImportTnOrderSubscriber + { + public string Name { get; set; } + public Address ServiceAddress { get; set; } + } + public class fileUploadResponse { [XmlElement("filename")] @@ -194,5 +200,3 @@ public class ImportTnOrderSummary } - - From bc2181e65f0442e8f29cf1c4b921d4f1c719058d Mon Sep 17 00:00:00 2001 From: AJ Rice <53190766+ajrice6713@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:23:28 -0400 Subject: [PATCH 2/3] Add a test --- .../Models/ImportTnOrderTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs b/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs index 1d77b7b..9fd0506 100644 --- a/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs +++ b/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs @@ -421,5 +421,27 @@ public void TestImportTnOrderDeleteLoasFileMetadata() } } + + [Fact] + public void TestImportTnOrderWithSubscriber() + { + var address = new Address + { + HouseNumber = "123" + }; + + var subscriber = new ImportTnOrderSubscriber + { + Name = "test", + ServiceAddress = address + }; + + var order = new ImportTnOrder + { + Subscriber = subscriber + }; + + Assert.Equal("test", order.Subscriber.Name); + } } } From 45f3d5b29294d7ee086b7818a52b5fdcfbaa476f Mon Sep 17 00:00:00 2001 From: AJ Rice <53190766+ajrice6713@users.noreply.github.com> Date: Thu, 25 Apr 2024 09:00:03 -0400 Subject: [PATCH 3/3] Verify the XML is correct --- Bandwidth.Iris.Tests/Helper.cs | 10 +++++----- Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Bandwidth.Iris.Tests/Helper.cs b/Bandwidth.Iris.Tests/Helper.cs index c443ea5..728300f 100644 --- a/Bandwidth.Iris.Tests/Helper.cs +++ b/Bandwidth.Iris.Tests/Helper.cs @@ -36,8 +36,8 @@ public async static Task ParseXmlContent(HttpContent content) { using (var stream = await content.ReadAsStreamAsync()) { - var serializer = new XmlSerializer(typeof (T)); - return (T) serializer.Deserialize(stream); + var serializer = new XmlSerializer(typeof(T)); + return (T)serializer.Deserialize(stream); } } @@ -54,11 +54,11 @@ public static T ParseXml(string xml) public static void AssertObjects(object estimated, object value) { var type = estimated.GetType(); - foreach(var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)) + foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { var est = property.GetValue(estimated); var val = property.GetValue(value); - if(est == null && val == null) continue; + if (est == null && val == null) continue; var t = (val ?? est).GetType(); if (t.IsPrimitive || val is IComparable) { @@ -108,7 +108,7 @@ public static string ToXmlStringMinified(object data) using (var writer = new Utf8StringWriter()) - using (var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = false, OmitXmlDeclaration = true})) + using (var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = false, OmitXmlDeclaration = true })) { serializer.Serialize(xmlWriter, data); return writer.ToString(); diff --git a/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs b/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs index 9fd0506..7f77dda 100644 --- a/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs +++ b/Bandwidth.Iris.Tests/Models/ImportTnOrderTests.cs @@ -442,6 +442,17 @@ public void TestImportTnOrderWithSubscriber() }; Assert.Equal("test", order.Subscriber.Name); + + using (var server = new HttpServer(new RequestHandler + { + EstimatedMethod = "POST", + EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/importTnOrders", + })) + { + var client = Helper.CreateClient(); + ImportTnOrder.Create(client, order).Wait(); + if (server.Error != null) throw server.Error; + } } } }