From 423e842f8e303b86be280b6d75c25fd48e147628 Mon Sep 17 00:00:00 2001 From: Andrew Johnson <141680314+andrewjohnsonsmarty@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:49:57 -0600 Subject: [PATCH] Removed the use of enums for format field using string instead (#40) --- src/sdk/USStreetApi/Client.cs | 3 +-- src/sdk/USStreetApi/Lookup.cs | 24 ++++-------------------- src/tests/USStreetApi/ClientTests.cs | 2 +- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/sdk/USStreetApi/Client.cs b/src/sdk/USStreetApi/Client.cs index fe8e710..09248a6 100644 --- a/src/sdk/USStreetApi/Client.cs +++ b/src/sdk/USStreetApi/Client.cs @@ -72,8 +72,7 @@ private static void PopulateQueryString(Lookup address, Request request) if (address.MaxCandidates != 1) request.SetParameter("candidates", address.MaxCandidates.ToString(CultureInfo.InvariantCulture)); - if (address.GetFormatString() != "default") - request.SetParameter("format", address.GetFormatString()); + request.SetParameter("format", address.OutputFormat); } private static void AssignCandidatesToLookups(Batch batch, IEnumerable candidates) diff --git a/src/sdk/USStreetApi/Lookup.cs b/src/sdk/USStreetApi/Lookup.cs index a12ddcf..95a6ad3 100644 --- a/src/sdk/USStreetApi/Lookup.cs +++ b/src/sdk/USStreetApi/Lookup.cs @@ -15,12 +15,9 @@ 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 const string DEFAULT_FORMAT = "default"; + public const string PROJECT_USA_FORMAT = "project-usa"; public List Result { get; private set; } @@ -61,7 +58,7 @@ public enum Format public string MatchStrategy { get; set; } [DataMember(Name = "format")] - public Format OutputFormat { get; set; } + public string OutputFormat { get; set; } public int MaxCandidates { @@ -96,18 +93,5 @@ 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 b041823..1a69d73 100644 --- a/src/tests/USStreetApi/ClientTests.cs +++ b/src/tests/USStreetApi/ClientTests.cs @@ -67,7 +67,7 @@ public void TestSendingSingleFullyPopulatedLookupWithFormatOutput() ZipCode = "7", Lastline = "8", MatchStrategy = "enhanced", - OutputFormat = Lookup.Format.ProjectUsa + OutputFormat = Lookup.PROJECT_USA_FORMAT }; client.Send(lookup);