diff --git a/src/sdk/USStreetApi/Client.cs b/src/sdk/USStreetApi/Client.cs index ae96d7a..fe8e710 100644 --- a/src/sdk/USStreetApi/Client.cs +++ b/src/sdk/USStreetApi/Client.cs @@ -1,4 +1,6 @@ -namespace SmartyStreets.USStreetApi +using SmartyStreets.USReverseGeoApi; + +namespace SmartyStreets.USStreetApi { using System; using System.Collections.Generic; @@ -66,9 +68,12 @@ private static void PopulateQueryString(Lookup address, Request request) request.SetParameter("addressee", address.Addressee); request.SetParameter("urbanization", address.Urbanization); request.SetParameter("match", address.MatchStrategy); - - if (address.MaxCandidates != 1) + + if (address.MaxCandidates != 1) request.SetParameter("candidates", address.MaxCandidates.ToString(CultureInfo.InvariantCulture)); + + if (address.GetFormatString() != "default") + request.SetParameter("format", address.GetFormatString()); } private static void AssignCandidatesToLookups(Batch batch, IEnumerable candidates) diff --git a/src/sdk/USStreetApi/Lookup.cs b/src/sdk/USStreetApi/Lookup.cs index 7bd93e2..a12ddcf 100644 --- a/src/sdk/USStreetApi/Lookup.cs +++ b/src/sdk/USStreetApi/Lookup.cs @@ -1,4 +1,6 @@ -namespace SmartyStreets.USStreetApi +using System.Runtime.CompilerServices; + +namespace SmartyStreets.USStreetApi { using System; using System.Collections.Generic; @@ -13,7 +15,13 @@ public class Lookup : ILookup public const string ENHANCED = "enhanced"; public const string INVALID = "invalid"; public const string RANGE = "range"; // Deprecated - + + public enum Format + { + Default, + ProjectUsa, + } + public List Result { get; private set; } [DataMember(Name = "input_id")] @@ -52,6 +60,9 @@ public class Lookup : ILookup [DataMember(Name = "match")] public string MatchStrategy { get; set; } + [DataMember(Name = "format")] + public Format OutputFormat { get; set; } + public int MaxCandidates { get => this.maxCandidates; @@ -85,5 +96,18 @@ public void AddToResult(Candidate newCandidate) { this.Result.Add(newCandidate); } + + public string GetFormatString() + { + switch (this.OutputFormat) + { + case Format.Default: + return "default"; + case Format.ProjectUsa: + return "project-usa"; + default: + return ""; + } + } } } \ No newline at end of file diff --git a/src/tests/USStreetApi/ClientTests.cs b/src/tests/USStreetApi/ClientTests.cs index 607c034..b041823 100644 --- a/src/tests/USStreetApi/ClientTests.cs +++ b/src/tests/USStreetApi/ClientTests.cs @@ -47,7 +47,35 @@ public void TestSendingSingleFullyPopulatedLookup() Assert.AreEqual("?input_id=1234&street=1&street2=3&secondary=2&city=5&state=6&zipcode=7&" + "lastline=8&addressee=0&urbanization=4&match=enhanced&candidates=5", sender.Request.GetUrl()); } + + [Test] + public void TestSendingSingleFullyPopulatedLookupWithFormatOutput() + { + var sender = new RequestCapturingSender(); + var serializer = new FakeSerializer(null); + var client = new Client(sender, serializer); + var lookup = new Lookup + { + InputId = "1234", + Addressee = "0", + Street = "1", + Secondary = "2", + Street2 = "3", + Urbanization = "4", + City = "5", + State = "6", + ZipCode = "7", + Lastline = "8", + MatchStrategy = "enhanced", + OutputFormat = Lookup.Format.ProjectUsa + }; + + client.Send(lookup); + Assert.AreEqual("?input_id=1234&street=1&street2=3&secondary=2&city=5&state=6&zipcode=7&" + + "lastline=8&addressee=0&urbanization=4&match=enhanced&candidates=5&format=project-usa", sender.Request.GetUrl()); + } + #endregion #region [ Batch Lookup ]