Skip to content

Commit a82d636

Browse files
authored
Merge pull request #48 from smartystreets/eric/add-custom-parameter
Eric/add custom parameter
2 parents 157d785 + 5df0877 commit a82d636

31 files changed

+153
-4
lines changed

src/examples/InternationalAutocompleteExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public static void Run()
3636
Locality = "Paris",
3737
};
3838

39+
//uncomment the line below to add a custom parameter
40+
//lookup.AddCustomParameter("max_results", "3");
41+
3942
try
4043
{
4144
client.Send(lookup);

src/examples/InternationalStreetExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public static void Run()
4141
Country = "Brazil",
4242
PostalCode = "02516-050"
4343
};
44+
45+
//uncomment the line below to add a custom parameter
46+
//lookup.AddCustomParameter("input_id", "ID-8675309");
4447

4548
try
4649
{

src/examples/USAutocompleteProExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public static void Run()
7878
lookup.PreferRatio = 4;
7979
lookup.Source = "all";
8080

81+
//uncomment the below line to add a custom parameter
82+
//lookup.AddCustomParameter("source", "all");
83+
8184
try
8285
{
8386
client.Send(lookup);

src/examples/USEnrichmentGeoReferenceExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public static void Run()
3939
componentsLookup.SetState("NJ");
4040
componentsLookup.SetZipcode("08876");
4141

42+
//uncomment the below line to add a custom parameter
43+
//componentsLookup.AddCustomParameter("zipcode", "08876");
44+
4245
// Create a lookup with a single line address using the line below
4346
var freeformLookup = new SmartyStreets.USEnrichmentApi.GeoReference.Lookup();
4447
freeformLookup.SetFreeform("56 Union Ave Somerville NJ 08876");

src/examples/USEnrichmentPropertyExample.cs

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public static void Run()
3939
componentsLookup.SetState("NJ");
4040
componentsLookup.SetZipcode("08876");
4141

42+
//uncomment the below line to add a custom parameter
43+
//componentsLookup.AddCustomParameter("zipcode", "08876");
44+
4245
// Create a lookup with a single line address using the line below
4346
var freeformLookup = new SmartyStreets.USEnrichmentApi.Property.Principal.Lookup();
4447
freeformLookup.SetFreeform("56 Union Ave Somerville NJ 08876");
@@ -83,6 +86,9 @@ public static void Run()
8386
financialComponentsLookup.SetState("NJ");
8487
financialComponentsLookup.SetZipcode("08876");
8588

89+
//uncomment the below line to add a custom parameter
90+
//financialComponentsLookup.AddCustomParameter("zipcode", "08876");
91+
8692
// Create a lookup with a single line address using the line below
8793
var financialFreeformLookup = new SmartyStreets.USEnrichmentApi.Property.Financial.Lookup();
8894
financialFreeformLookup.SetFreeform("56 Union Ave Somerville NJ 08876");

src/examples/USEnrichmentSecondaryExample.cs

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static void Run()
4040
componentsLookup.SetState("NJ");
4141
componentsLookup.SetZipcode("08876");
4242

43+
//uncomment the below line to add a custom parameter
44+
//componentsLookup.AddCustomParameter("zipcode", "08876");
45+
4346
// Create a lookup with a single line address using the line below
4447
var freeformLookup = new SmartyStreets.USEnrichmentApi.Secondary.Lookup();
4548
freeformLookup.SetFreeform("56 Union Ave Somerville NJ 08876");
@@ -95,6 +98,9 @@ public static void Run()
9598
countComponentsLookup.SetState("NJ");
9699
countComponentsLookup.SetZipcode("08876");
97100

101+
//uncomment the below line to add a custom parameter
102+
//countComponentsLookup.AddCustomParameter("zipcode", "08876");
103+
98104
// Create a lookup with a single line address using the line below
99105
var countFreeformLookup = new SmartyStreets.USEnrichmentApi.Secondary.Count.Lookup();
100106
countFreeformLookup.SetFreeform("56 Union Ave Somerville NJ 08876");

src/examples/USEnrichmentUniversalExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public static void Run()
4242
componentsLookup.SetState("NJ");
4343
componentsLookup.SetZipcode("08876");
4444

45+
//uncomment the line below to add a custom parameter
46+
//componentsLookup.AddCustomParameter("zipcode", "08876");
47+
4548
// Create a lookup with a single line address using the lines below
4649
var freeformLookup = new SmartyStreets.USEnrichmentApi.Universal.Lookup();
4750
freeformLookup.SetDatasetName("property");

src/examples/USExtractExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public static void Run()
3232
AddressesHaveLineBreaks = false,
3333
AddressesPerLine = 1
3434
};
35+
36+
//uncomment the line below to add a custom parameter
37+
//lookup.AddCustomParameter("addr_line_breaks", "false");
3538

3639
try
3740
{

src/examples/USReverseGeoExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public static void Run()
3535

3636
var lookup = new Lookup(40.111111, -111.111111);
3737

38+
//uncomment the line below to add a custom parameter
39+
//lookup.AddCustomParameter("source", "all");
40+
3841
try
3942
{
4043
client.Send(lookup);

src/examples/USStreetLookupsWithMatchStrategyExamples.cs

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public static void Run()
3737
MatchStrategy = Lookup.STRICT
3838
};
3939

40+
//uncomment the line below to add a custom parameter
41+
//addressWithStrictStrategy.AddCustomParameter("city", "provo");
42+
4043
var addressWithEnhancedStrategy = new Lookup
4144
{
4245
Street = "693 W 1150 S",

src/examples/USStreetMultipleAddressesExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static void Run()
4646
// Refer to the documentation for additional MatchStrategy options.
4747
};
4848

49+
//uncomment the line below to add a custom parameter
50+
//address1.AddCustomParameter("InputId", "24601");
51+
4952
var address2 = new Lookup("1 Rosedale, Baltimore, Maryland")
5053
{
5154
Street = "1 Rosedale",

src/examples/USStreetSingleAddressEndpointExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public static void Run()
5151
// Refer to the documentation for additional MatchStrategy options.
5252
};
5353

54+
//uncomment the line below to add a custom parameter
55+
//lookup.AddCustomParameter("InputId", "24601");
56+
5457
try
5558
{
5659
client.Send(lookup);

src/examples/USStreetSingleAddressExample.cs

+4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ public static void Run()
4444
City = "Mountain View",
4545
State = "CA",
4646
ZipCode = "21229",
47+
CountySource = Lookup.GEOGRAPHIC,
4748
MaxCandidates = 3,
4849
MatchStrategy = Lookup.ENHANCED // "invalid" is the most permissive match,
4950
// this will always return at least one result even if the address is invalid.
5051
// Refer to the documentation for additional MatchStrategy options.
5152
};
5253

54+
//uncomment the line below to add a custom parameter
55+
//lookup.AddCustomParameter("county_source", "geographic");
56+
5357
try
5458
{
5559
client.Send(lookup);

src/examples/USZipCodeMultipleLookupsExample.cs

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static void Run()
2626
ZipCode = "12345"
2727
};
2828

29+
//uncomment the lines below to add custom parameters
30+
// lookup1.AddCustomParameter("city", "Schenectady");
31+
// lookup1.AddCustomParameter("state", "NY");
32+
2933
var lookup2 = new Lookup
3034
{
3135
City = "Phoenix",

src/examples/USZipCodeSingleLookupExample.cs

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public static void Run()
3131
ZipCode = "94039"
3232
};
3333

34+
//uncomment the line below to add a custom parameter
35+
//lookup.AddCustomParameter("zipcode", "94039");
36+
3437
try
3538
{
3639
client.Send(lookup);

src/sdk/InternationalAutcompleteApi/Client.cs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections;
55
using System.IO;
6+
using System.Collections.Generic;
67

78
/// <summary>
89
/// This client sends lookups to the SmartyStreets US Autocomplete API,
@@ -58,6 +59,10 @@ private static Request BuildRequest(Lookup lookup)
5859
request.SetParameter("max_results", lookup.MaxSuggestionsString);
5960
request.SetParameter("include_only_locality", lookup.Locality);
6061
request.SetParameter("include_only_postal_code", lookup.PostalCode);
62+
63+
foreach (KeyValuePair<string, string> line in lookup.CustomParamDict) {
64+
request.SetParameter(line.Key, line.Value);
65+
}
6166

6267
return request;
6368
}

src/sdk/InternationalAutcompleteApi/Lookup.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace SmartyStreets.InternationalAutocompleteApi
22
{
33
using System.Collections;
4+
using System.Collections.Generic;
45

56
/// <summary>
67
/// In addition to holding all of the input data for this lookup, this class also
@@ -22,6 +23,7 @@ public class Lookup
2223
public int MaxResults { get; set; }
2324
public string Locality { get; set; }
2425
public string PostalCode { get; set; }
26+
public Dictionary<string, string> CustomParamDict = new Dictionary<string, string>{};
2527

2628
#endregion
2729

@@ -46,5 +48,8 @@ public Lookup(string search) : this()
4648

4749
internal string MaxSuggestionsString => this.MaxResults.ToString();
4850

51+
public void AddCustomParameter(string parameter, string value) {
52+
CustomParamDict.Add(parameter, value);
53+
}
4954
}
5055
}

src/sdk/InternationalStreetApi/Client.cs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ private static Request BuildRequest(Lookup lookup)
5757
request.SetParameter("administrative_area", lookup.AdministrativeArea);
5858
request.SetParameter("postal_code", lookup.PostalCode);
5959

60+
foreach (KeyValuePair<string, string> line in lookup.CustomParamDict) {
61+
request.SetParameter(line.Key, line.Value);
62+
}
63+
6064
return request;
6165
}
6266

src/sdk/InternationalStreetApi/Lookup.cs

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class Lookup : ILookup
4242
public string Locality { get; set; }
4343
public string AdministrativeArea { get; set; }
4444
public string PostalCode { get; set; }
45+
public Dictionary<string, string> CustomParamDict = new Dictionary<string, string>{};
4546

4647
#endregion
4748

@@ -118,5 +119,9 @@ public void AddToResult(Candidate newCandidate)
118119
{
119120
this.Result.Add(newCandidate);
120121
}
122+
123+
public void AddCustomParameter(string parameter, string value) {
124+
CustomParamDict.Add(parameter, value);
125+
}
121126
}
122127
}

src/sdk/USAutocompleteProApi/Client.cs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections;
55
using System.IO;
6+
using System.Collections.Generic;
67

78
/// <summary>
89
/// This client sends lookups to the SmartyStreets US Autocomplete API,
@@ -57,6 +58,10 @@ private static Request BuildRequest(Lookup lookup)
5758
request.SetParameter("selected", lookup.Selected);
5859
request.SetParameter("source", lookup.Source);
5960

61+
foreach (KeyValuePair<string, string> line in lookup.CustomParamDict) {
62+
request.SetParameter(line.Key, line.Value);
63+
}
64+
6065
return request;
6166
}
6267

src/sdk/USAutocompleteProApi/Lookup.cs

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SmartyStreets.USAutocompleteProApi
44
{
55
using System.Collections;
6+
using System.Collections.Generic;
67

78
/// <summary>
89
/// In addition to holding all of the input data for this lookup, this class also
@@ -31,6 +32,7 @@ public class Lookup
3132
public string PreferGeolocation { get; set; }
3233
public string Selected { get; set; }
3334
public string Source { get; set; }
35+
public Dictionary<string, string> CustomParamDict = new Dictionary<string, string>{};
3436

3537
#endregion
3638

@@ -112,5 +114,9 @@ public void AddPreferZIP(string zipcode)
112114
this.PreferGeolocation = GeolocateType.NONE;
113115
this.PreferZIPCodes.Add(zipcode);
114116
}
117+
118+
public void AddCustomParameter(string parameter, string value) {
119+
CustomParamDict.Add(parameter, value);
120+
}
115121
}
116122
}

src/sdk/USEnrichmentApi/Client.cs

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace SmartyStreets.USEnrichmentApi
22
{
33
using System;
44
using System.IO;
5+
using System.Collections.Generic;
56

67
public class Client //: IUSEnrichmentClient
78
{
@@ -150,6 +151,10 @@ private SmartyStreets.Request BuildRequest(Lookup lookup)
150151
request.SetHeader("Etag", lookup.GetEtag());
151152
}
152153

154+
foreach (KeyValuePair<string, string> line in lookup.CustomParamDict) {
155+
request.SetParameter(line.Key, line.Value);
156+
}
157+
153158
return request;
154159
}
155160
}

src/sdk/USEnrichmentApi/Lookup.cs

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Collections.Generic;
2+
13
namespace SmartyStreets.USEnrichmentApi
24
{
35
using System;
@@ -15,6 +17,7 @@ public abstract class Lookup
1517
private string zipcode;
1618
private string includeFields;
1719
private string excludeFields;
20+
public Dictionary<string, string> CustomParamDict = new Dictionary<string, string>{};
1821
private string eTag;
1922

2023
public Lookup(string smartyKey = null, string datasetName = null, string dataSubsetName = null, string freeform = null, string street = null,
@@ -141,6 +144,10 @@ public void SetZipcode(string zipcode)
141144
}
142145

143146
public abstract void DeserializeAndSetResults(SmartyStreets.ISerializer serializer, Stream payload);
147+
148+
public void AddCustomParameter(string parameter, string value) {
149+
CustomParamDict.Add(parameter, value);
150+
}
144151
}
145152

146153
}

src/sdk/USExtractApi/Client.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace SmartyStreets.USExtractApi
1+
using System.Collections.Generic;
2+
3+
namespace SmartyStreets.USExtractApi
24
{
35
using System;
46
using System.IO;
@@ -52,6 +54,10 @@ private static Request BuildRequest(Lookup lookup)
5254
if ((lookup.MatchStrategy != "") && (lookup.MatchStrategy != Lookup.STRICT))
5355
request.SetParameter("match", lookup.MatchStrategy);
5456

57+
foreach (KeyValuePair<string, string> line in lookup.CustomParamDict) {
58+
request.SetParameter(line.Key, line.Value);
59+
}
60+
5561
return request;
5662
}
5763
}

src/sdk/USExtractApi/Lookup.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace SmartyStreets.USExtractApi
1+
using System.Collections.Generic;
2+
3+
namespace SmartyStreets.USExtractApi
4+
25
{
36
/// <summary>
47
/// In addition to holding all of the input data for this lookup, this class also
@@ -20,6 +23,7 @@ public class Lookup
2023
public int AddressesPerLine { get; set; }
2124
public string MatchStrategy { get; set; }
2225
public string Text { get; set; }
26+
public Dictionary<string, string> CustomParamDict = new Dictionary<string, string>{};
2327

2428
#endregion
2529

@@ -51,5 +55,9 @@ public void SpecifyHtmlInput(bool html)
5155
{
5256
this.html = html.ToString().ToLower();
5357
}
58+
59+
public void AddCustomParameter(string parameter, string value) {
60+
CustomParamDict.Add(parameter, value);
61+
}
5462
}
5563
}

0 commit comments

Comments
 (0)