Skip to content

Commit

Permalink
Merge pull request #77 from Bandwidth/SWI-3335
Browse files Browse the repository at this point in the history
SWI-3335 Make DateTime fields nullable in Tn model
  • Loading branch information
ajrice6713 authored Aug 25, 2023
2 parents 64314c0 + 31bb96a commit 34d71a7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ Thumbs.db
.vscode

.vs
.idea
24 changes: 22 additions & 2 deletions Bandwidth.Iris.Tests/Models/TnTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ public void GetTest()
}
}

public void GetTestWithNullDateTime()
{
using (var server = new HttpServer(new RequestHandler
{
EstimatedMethod = "GET",
EstimatedPathAndQuery = string.Format("/v1.0/tns/1234", Helper.AccountId),
ContentToSend = new StringContent(TestXmlStrings.TnResponseWithNullDates, Encoding.UTF8, "application/xml")
}))
{
var client = Helper.CreateClient();
var result = Tn.Get(client, "1234").Result;
if (server.Error != null) throw server.Error;
Assert.Equal("1234", result.TelephoneNumber);
Assert.Equal("Inservice", result.Status);
Assert.Equal("5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04be", result.OrderId);
Assert.Equal("NEW_NUMBER_ORDER", result.OrderType);
Assert.Null(result.LastModifiedDate);
}
}

[Fact]
public void ListTest()
{
Expand All @@ -48,7 +68,7 @@ public void ListTest()
}))
{
var client = Helper.CreateClient();
var result = Tn.List(client, new Dictionary<string, object>{{"npa", "818"}}).Result;
var result = Tn.List(client, new Dictionary<string, object> { { "npa", "818" } }).Result;
if (server.Error != null) throw server.Error;
Assert.Equal(5, result.TelephoneNumberCount);

Expand Down Expand Up @@ -107,7 +127,7 @@ public void GetSitesTest()
}))
{
var client = Helper.CreateClient();
var tn = new Tn {TelephoneNumber = "1234", Client = client};
var tn = new Tn { TelephoneNumber = "1234", Client = client };
var result = tn.GetSites().Result;
if (server.Error != null) throw server.Error;
Assert.Equal("1435", result.Id);
Expand Down
1 change: 1 addition & 0 deletions Bandwidth.Iris.Tests/TestXmlStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ public static class TestXmlStrings
public static string CoveredRateCentersResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CoveredRateCenters><CoveredRateCenter><Abbreviation>ACME</Abbreviation><Name>ACME</Name></CoveredRateCenter></CoveredRateCenters>";
public static string CitiesResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CityResponse><ResultCount>2</ResultCount><Cities><City><RcAbbreviation>SOUTHEPINS</RcAbbreviation><Name>ABERDEEN</Name></City><City><RcAbbreviation>JULIAN</RcAbbreviation><Name>ADVANCE</Name></City></Cities></CityResponse>";
public static string TnResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumber>1234</TelephoneNumber><Status>Inservice</Status><LastModifiedDate>2014-05-09T21:12:03.000Z</LastModifiedDate><OrderCreateDate>2014-05-09T21:12:03.835Z</OrderCreateDate><OrderId>5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04be</OrderId><OrderType>NEW_NUMBER_ORDER</OrderType><SiteId>1091</SiteId><AccountId>9500149</AccountId></TelephoneNumberResponse>";
public static string TnResponseWithNullDates = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumber>1234</TelephoneNumber><Status>Inservice</Status><LastModifiedDate/><OrderCreateDate>2014-05-09T21:12:03.835Z</OrderCreateDate><OrderId>5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04be</OrderId><OrderType>NEW_NUMBER_ORDER</OrderType><SiteId>1091</SiteId><AccountId>9500149</AccountId></TelephoneNumberResponse>";
public static string TnsListResponse = "<?xml version=\"1.0\"?><TelephoneNumbersResponse><TelephoneNumberCount>5</TelephoneNumberCount><Links><first></first><next></next></Links><TelephoneNumbers><TelephoneNumber><City>CARY</City><Lata>426</Lata><State>NC</State><FullNumber>9192381138</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900008</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber><TelephoneNumber><City>CARY</City><Lata>426</Lata><FullNumber>9192381139</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900000</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber></TelephoneNumbers></TelephoneNumbersResponse>";
public static string TnSitesResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Site><Id>1435</Id><Name>Sales Training</Name></Site>";
public static string TnSipPeersResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeer><Id>4064</Id><Name>Sales</Name></SipPeer>";
Expand Down
16 changes: 8 additions & 8 deletions Bandwidth.Iris/Model/Tn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static async Task<TelephoneNumbersResponse> List(Client client, IDictiona
{
return await client.MakeGetRequest<TelephoneNumbersResponse>(TnsPath, query);
}

#if !PCL
public static Task<Tn> Get(string number)
{
Expand Down Expand Up @@ -72,7 +72,7 @@ public async Task<TelephoneNumberRateCenter> GetRateCenter()
}
}


public async Task<TelephoneNumberDetails> GetDetails()
{
return
Expand All @@ -89,17 +89,17 @@ public async Task<string> GetLata()
return xml.Descendants("Lata").First().Value;
}
}

public string TelephoneNumber { get; set; }
public string Status { get; set; }
public DateTime LastModifiedDate { get; set; }
public DateTime OrderCreateDate { get; set; }
public DateTime? LastModifiedDate { get; set; }
public DateTime? OrderCreateDate { get; set; }
public string OrderId { get; set; }
public string OrderType { get; set; }
public string SiteId { get; set; }
public string AccountId { get; set; }


}

[XmlType("SipPeer")]
Expand All @@ -124,7 +124,7 @@ public class TelephoneNumberRateCenter

public class TelephoneNumberResponse
{
public TelephoneNumberDetails TelephoneNumberDetails { get; set; }
public TelephoneNumberDetails TelephoneNumberDetails { get; set; }
}

public class TelephoneNumberDetails
Expand All @@ -138,7 +138,7 @@ public class TelephoneNumberDetails
public string Tier { get; set; }
public string VendorId { get; set; }
public string VendorName { get; set; }
public DateTime LastModified { get; set; }
public DateTime? LastModified { get; set; }
public string State { get; set; }
public Features Features { get; set; }
}
Expand Down

0 comments on commit 34d71a7

Please sign in to comment.