Skip to content

Commit

Permalink
Removed the use of enums for format field using string instead (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjohnsonsmarty authored Nov 3, 2023
1 parent da543fe commit 423e842
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/sdk/USStreetApi/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Candidate> candidates)
Expand Down
24 changes: 4 additions & 20 deletions src/sdk/USStreetApi/Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Candidate> Result { get; private set; }

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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 "";
}
}
}
}
2 changes: 1 addition & 1 deletion src/tests/USStreetApi/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 423e842

Please sign in to comment.