#
A C# wrapper for the Full Contact API
Install FullContact.Api.Csharp nuget. Run the following command in the Package Manager Console.
Solution (.sln) is based in The Onion Architecture
var container = new Container();
#region Dependency Injection (DI) using Simple Injector
container.RegisterSingleton<IServiceProvider>(container);
container.Register<IFullContactAppServiceFactory, FullContactAppServiceFactory>();
container.Register<IHttpClientFactory, HttpClientFactory>();
#endregion
///Get container full contact app service factory
var fullContactAppServiceFactory = container.GetInstance<IFullContactAppServiceFactory>();
///Create full contact app service
var fullContactAppService = fullContactAppServiceFactory.Create<Person>("https://api.fullcontact.com/v2",
"xxxx", Serializer.Json);
/// Call full contact api by http get method
var person = await fullContactAppService.GetAsync(Lookup.Email, "bart@fullcontact.com");
///Person contains all properties. Sample:
var fullName = person.ContactInfo.FullName;
Using lookup enum to get other's query to call the Person API
public enum Lookup
{
Phone = 0,
Email = 1,
Twitter = 2,
Domain = 3
}
This release only implements the person api. For other, simply create the DataTranferObject and change GetApi method in FullContactAppService.
private Api GetApi(Type type)
{
switch (type.Name)
{
case "Person":
return Api.Person;
/// Insert new cases
default:
throw new NotImplementedException($"Api type {type.Name} not implemented.");
}
}
This software is open source, licensed under the MIT License (MIT). See LICENSE.me for details.