-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Valverde
committed
Aug 25, 2015
1 parent
0d69fbe
commit b39dd61
Showing
15 changed files
with
320 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using FullContactDotNet.Location; | ||
using RestSharp; | ||
using System; | ||
|
||
namespace FullContactDotNet | ||
{ | ||
public class FullContactLocationApi : FullContactApi, IFullContactLocationApi | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FullContactLocationApi"/> class. | ||
/// </summary> | ||
public FullContactLocationApi() : base(FullContactConfiguration.ApiKey) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FullContactLocationApi"/> class. | ||
/// </summary> | ||
/// <param name="apiKey">The API key.</param> | ||
public FullContactLocationApi(string apiKey) : base(apiKey) { } | ||
|
||
/// <summary> | ||
/// Gets the normalized location. | ||
/// </summary> | ||
/// <param name="place">The place.</param> | ||
/// <param name="includeZeroPopulation">The include zero population.</param> | ||
/// <param name="casing">The casing.</param> | ||
/// <returns></returns> | ||
/// <exception cref="System.ArgumentNullException">An email address is required to lookup a person by email.</exception> | ||
public NormalizedLocationResponse GetNormalizedLocation(string place, bool? includeZeroPopulation = null, Casing? casing = null) | ||
{ | ||
if (string.IsNullOrWhiteSpace(place)) throw new ArgumentNullException("A place is required to get a normalized location."); | ||
|
||
var request = GetLocationRequest("locationNormalizer", includeZeroPopulation, casing); | ||
request.AddParameter("place", place); | ||
return Execute<NormalizedLocationResponse>(request); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the enriched location. | ||
/// </summary> | ||
/// <param name="place">The place.</param> | ||
/// <param name="includeZeroPopulation">The include zero population.</param> | ||
/// <param name="casing">The casing.</param> | ||
/// <returns></returns> | ||
/// <exception cref="System.ArgumentNullException">A place is required to get a normalized location.</exception> | ||
public EnrichedLocationResponse GetEnrichedLocation(string place, bool? includeZeroPopulation = null, Casing? casing = null) | ||
{ | ||
if (string.IsNullOrWhiteSpace(place)) throw new ArgumentNullException("A place is required to get a enriched location."); | ||
|
||
var request = GetLocationRequest("locationEnrichment", includeZeroPopulation, casing); | ||
request.AddParameter("place", place); | ||
return Execute<EnrichedLocationResponse>(request); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the location request. | ||
/// </summary> | ||
/// <param name="resource">The resource.</param> | ||
/// <param name="includeZeroPopulation">The include zero population.</param> | ||
/// <param name="casing">The casing.</param> | ||
/// <returns></returns> | ||
private RestRequest GetLocationRequest(string resource, bool? includeZeroPopulation = null, Casing? casing = null) | ||
{ | ||
var request = new RestRequest(string.Format("/address/{0}.json", resource), Method.GET); | ||
|
||
if (includeZeroPopulation.HasValue) | ||
{ | ||
request.AddParameter("includeZeroPopulation", includeZeroPopulation.Value); | ||
} | ||
|
||
if (casing.HasValue) | ||
{ | ||
request.AddParameter("casing", casing.Value); | ||
} | ||
|
||
return request; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using FullContactDotNet.Location; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FullContactDotNet | ||
{ | ||
public interface IFullContactLocationApi | ||
{ | ||
/// <summary> | ||
/// Gets the normalized location. | ||
/// </summary> | ||
/// <param name="place">The place.</param> | ||
/// <param name="includeZeroPopulation">The include zero population.</param> | ||
/// <param name="casing">The casing.</param> | ||
/// <returns></returns> | ||
NormalizedLocationResponse GetNormalizedLocation(string place, bool? includeZeroPopulation = null, Casing? casing = null); | ||
|
||
/// <summary> | ||
/// Gets the enriched location. | ||
/// </summary> | ||
/// <param name="place">The place.</param> | ||
/// <param name="includeZeroPopulation">The include zero population.</param> | ||
/// <param name="casing">The casing.</param> | ||
/// <returns></returns> | ||
EnrichedLocationResponse GetEnrichedLocation(string place, bool? includeZeroPopulation = null, Casing? casing = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace FullContactDotNet.Location | ||
{ | ||
public class EnrichedLocationResponse : FullContactResponse | ||
{ | ||
/// <summary> | ||
/// Gets or sets the locations. | ||
/// </summary> | ||
/// <value> | ||
/// The locations. | ||
/// </value> | ||
public List<Location> Locations { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using FullContactDotNet.Shared; | ||
|
||
namespace FullContactDotNet.Location | ||
{ | ||
public class Location | ||
{ | ||
/// <summary> | ||
/// Gets or sets the city. | ||
/// </summary> | ||
/// <value> | ||
/// The city. | ||
/// </value> | ||
public string City { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the county. | ||
/// </summary> | ||
/// <value> | ||
/// The county. | ||
/// </value> | ||
public string County { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the state. | ||
/// </summary> | ||
/// <value> | ||
/// The state. | ||
/// </value> | ||
public NameAndCode State { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the country. | ||
/// </summary> | ||
/// <value> | ||
/// The country. | ||
/// </value> | ||
public NameAndCode Country { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the continent. | ||
/// </summary> | ||
/// <value> | ||
/// The continent. | ||
/// </value> | ||
public string Continent { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the population. | ||
/// </summary> | ||
/// <value> | ||
/// The population. | ||
/// </value> | ||
public string Population { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the normalized location. | ||
/// </summary> | ||
/// <value> | ||
/// The normalized location. | ||
/// </value> | ||
public string NormalizedLocation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using FullContactDotNet.Shared; | ||
|
||
namespace FullContactDotNet.Location | ||
{ | ||
public class NormalizedLocationResponse : FullContactResponse | ||
{ | ||
/// <summary> | ||
/// Gets or sets the city. | ||
/// </summary> | ||
/// <value> | ||
/// The city. | ||
/// </value> | ||
public string City { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the state. | ||
/// </summary> | ||
/// <value> | ||
/// The state. | ||
/// </value> | ||
public NameAndCode State { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the county. | ||
/// </summary> | ||
/// <value> | ||
/// The county. | ||
/// </value> | ||
public string County { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the country. | ||
/// </summary> | ||
/// <value> | ||
/// The country. | ||
/// </value> | ||
public NameAndCode Country { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the continent. | ||
/// </summary> | ||
/// <value> | ||
/// The continent. | ||
/// </value> | ||
public string Continent { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the likelihood. | ||
/// </summary> | ||
/// <value> | ||
/// The likelihood. | ||
/// </value> | ||
public string Likelihood { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the normalized location. | ||
/// </summary> | ||
/// <value> | ||
/// The normalized location. | ||
/// </value> | ||
public string NormalizedLocation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
FullContactDotNet/Company/Asset.cs → FullContactDotNet/Shared/Asset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace FullContactDotNet.Company | ||
namespace FullContactDotNet.Shared | ||
{ | ||
public class Asset | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
FullContactDotNet/Person/DeducedName.cs → FullContactDotNet/Shared/DeducedName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace FullContactDotNet.Person | ||
namespace FullContactDotNet.Shared | ||
{ | ||
public class DeducedName | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
...ontactDotNet/Person/DeducedNameAndCode.cs → ...ontactDotNet/Shared/DeducedNameAndCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
FullContactDotNet/Company/NameAndCode.cs → FullContactDotNet/Shared/NameAndCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace FullContactDotNet.Company | ||
namespace FullContactDotNet.Shared | ||
{ | ||
public class NameAndCode | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using FullContactDotNet; | ||
|
||
namespace UnitTests | ||
{ | ||
[TestClass] | ||
public class FullContactLocationApiUnitTests | ||
{ | ||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException), | ||
"FullContactApi was allowed to query location normalization with a null place.")] | ||
public void FullContactLocationApiGetNormalizedLocationNullPlace() | ||
{ | ||
var fullContactLocationApi = new FullContactLocationApi(); | ||
var actual = fullContactLocationApi.GetNormalizedLocation(null); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException), | ||
"FullContactApi was allowed to query location normalization with a blank place.")] | ||
public void FullContactLocationApiGetNormalizedLocationEmptyPlace() | ||
{ | ||
var fullContactLocationApi = new FullContactLocationApi(); | ||
var actual = fullContactLocationApi.GetNormalizedLocation(" "); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException), | ||
"FullContactApi was allowed to query location enrichment with a null place.")] | ||
public void FullContactLocationApiGetEnrichedLocationNullPlace() | ||
{ | ||
var fullContactLocationApi = new FullContactLocationApi(); | ||
var actual = fullContactLocationApi.GetEnrichedLocation(null); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException), | ||
"FullContactApi was allowed to query location enrichment with a blank place.")] | ||
public void FullContactLocationApiGetEnrichedLocationEmptyPlace() | ||
{ | ||
var fullContactLocationApi = new FullContactLocationApi(); | ||
var actual = fullContactLocationApi.GetEnrichedLocation(" "); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters