Skip to content

Commit 9d49f80

Browse files
author
Adam Valverde
committed
adding in email api
1 parent 6a7f951 commit 9d49f80

8 files changed

+101
-22
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace FullContactDotNet.Entities
8+
{
9+
public class DisposableEmailResponse : FullContactResponse
10+
{
11+
/// <summary>
12+
/// Gets or sets the username sub addressing.
13+
/// </summary>
14+
/// <value>
15+
/// The username sub addressing.
16+
/// </value>
17+
public string UsernameSubAddressing { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets a value indicating whether [disposable email domain].
21+
/// </summary>
22+
/// <value>
23+
/// <c>true</c> if [disposable email domain]; otherwise, <c>false</c>.
24+
/// </value>
25+
public bool DisposableEmailDomain { get; set; }
26+
}
27+
}

FullContactDotNet/Entities/FullContactResponse.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ public class FullContactResponse
1212
/// </value>
1313
public HttpStatusCode Status { get; set; }
1414

15-
/// <summary>
16-
/// Gets or sets the request identifier.
17-
/// </summary>
18-
/// <value>
19-
/// The request identifier.
20-
/// </value>
21-
public string RequestId { get; set; }
22-
2315
/// <summary>
2416
/// Gets or sets the message.
2517
/// </summary>

FullContactDotNet/Entities/Person.cs renamed to FullContactDotNet/Entities/PersonResponse.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
namespace FullContactDotNet.Entities
44
{
5-
public class Person : FullContactResponse
5+
public class PersonResponse : FullContactResponse
66
{
7+
/// <summary>
8+
/// Gets or sets the request identifier.
9+
/// </summary>
10+
/// <value>
11+
/// The request identifier.
12+
/// </value>
13+
public string RequestId { get; set; }
14+
715
/// <summary>
816
/// Gets or sets the likelihood that the person provided matches the person requested.
917
/// </summary>

FullContactDotNet/FullContactDotNet.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<Compile Include="Entities\County.cs" />
5555
<Compile Include="Entities\Demographics.cs" />
5656
<Compile Include="Entities\DigitalFootprint.cs" />
57+
<Compile Include="Entities\DisposableEmailResponse.cs" />
5758
<Compile Include="Entities\FullContactResponse.cs" />
5859
<Compile Include="Entities\LocationDeduced.cs" />
5960
<Compile Include="Entities\Organization.cs" />
@@ -64,11 +65,13 @@
6465
<Compile Include="Entities\Topic.cs" />
6566
<Compile Include="Entities\Website.cs" />
6667
<Compile Include="FullContactApi.cs" />
68+
<Compile Include="FullContactEmailApi.cs" />
6769
<Compile Include="FullContactPersonApi.cs" />
6870
<Compile Include="FullContactApiException.cs" />
6971
<Compile Include="FullContactConfiguration.cs" />
72+
<Compile Include="IFullContactEmailApi.cs" />
7073
<Compile Include="IFullContactPersonApi.cs" />
71-
<Compile Include="Entities\Person.cs" />
74+
<Compile Include="Entities\PersonResponse.cs" />
7275
<Compile Include="Properties\AssemblyInfo.cs" />
7376
</ItemGroup>
7477
<ItemGroup>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FullContactDotNet.Entities;
2+
using RestSharp;
3+
using System;
4+
5+
namespace FullContactDotNet
6+
{
7+
public class FullContactEmailApi : FullContactApi, IFullContactEmailApi
8+
{
9+
/// <summary>
10+
/// Initializes a new instance of the <see cref="FullContactEmailApi"/> class.
11+
/// </summary>
12+
public FullContactEmailApi() : base(FullContactConfiguration.ApiKey) { }
13+
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="FullContactEmailApi"/> class.
16+
/// </summary>
17+
/// <param name="apiKey">The API key.</param>
18+
public FullContactEmailApi(string apiKey) : base(apiKey) { }
19+
20+
/// <summary>
21+
/// Detects the disposable email.
22+
/// </summary>
23+
/// <param name="emailAddress">The email address.</param>
24+
/// <returns></returns>
25+
/// <exception cref="System.ArgumentNullException">A email address is required to lookup a person by email.</exception>
26+
public DisposableEmailResponse DetectDisposableEmail(string emailAddress)
27+
{
28+
if (string.IsNullOrEmpty(emailAddress)) throw new ArgumentNullException("A email address is required to lookup a person by email.");
29+
30+
var request = new RestRequest("/email.json", Method.GET);
31+
request.AddParameter("email", emailAddress);
32+
return Execute<DisposableEmailResponse>(request);
33+
}
34+
}
35+
}

FullContactDotNet/FullContactPersonApi.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public FullContactPersonApi(string apiKey) : base(apiKey) { }
2525
/// <param name="webhookUrl">The webhook url.</param>
2626
/// <returns></returns>
2727
/// <exception cref="System.ArgumentNullException">A email address is required to lookup a person by email.</exception>
28-
public Person LookupPersonByEmail(string emailAddress, int? queue = null, string webhookUrl = null)
28+
public PersonResponse LookupPersonByEmail(string emailAddress, int? queue = null, string webhookUrl = null)
2929
{
3030
if (string.IsNullOrEmpty(emailAddress)) throw new ArgumentNullException("A email address is required to lookup a person by email.");
3131

3232
var request = GetPersonRequest(queue, webhookUrl);
3333
request.AddParameter("email", emailAddress);
34-
return Execute<Person>(request);
34+
return Execute<PersonResponse>(request);
3535
}
3636

3737
/// <summary>
@@ -43,7 +43,7 @@ public Person LookupPersonByEmail(string emailAddress, int? queue = null, string
4343
/// <param name="webhookUrl">The webhook url.</param>
4444
/// <returns></returns>
4545
/// <exception cref="System.ArgumentNullException">A phone number is required to lookup a person by twitter.</exception>
46-
public Person LookupPersonByPhone(string phoneNumber, string countryCode = null, int? queue = null, string webhookUrl = null)
46+
public PersonResponse LookupPersonByPhone(string phoneNumber, string countryCode = null, int? queue = null, string webhookUrl = null)
4747
{
4848
if (string.IsNullOrEmpty(phoneNumber)) throw new ArgumentNullException("A phone number is required to lookup a person by twitter.");
4949

@@ -57,7 +57,7 @@ public Person LookupPersonByPhone(string phoneNumber, string countryCode = null,
5757
request.AddParameter("countryCode", countryCode);
5858
}
5959

60-
return Execute<Person>(request);
60+
return Execute<PersonResponse>(request);
6161
}
6262

6363
/// <summary>
@@ -68,13 +68,13 @@ public Person LookupPersonByPhone(string phoneNumber, string countryCode = null,
6868
/// <param name="webhookUrl">The webhook url.</param>
6969
/// <returns></returns>
7070
/// <exception cref="System.ArgumentNullException">A twitter username is required to lookup a person by twitter.</exception>
71-
public Person LookupPersonByTwitter(string twitterUsername, int? queue = null, string webhookUrl = null)
71+
public PersonResponse LookupPersonByTwitter(string twitterUsername, int? queue = null, string webhookUrl = null)
7272
{
7373
if (string.IsNullOrEmpty(twitterUsername)) throw new ArgumentNullException("A twitter username is required to lookup a person by twitter.");
7474

7575
var request = GetPersonRequest(queue, webhookUrl);
7676
request.AddParameter("twitter", twitterUsername);
77-
return Execute<Person>(request);
77+
return Execute<PersonResponse>(request);
7878
}
7979

8080
/// <summary>
@@ -85,13 +85,13 @@ public Person LookupPersonByTwitter(string twitterUsername, int? queue = null, s
8585
/// <param name="webhookUrl">The webhook url.</param>
8686
/// <returns></returns>
8787
/// <exception cref="System.ArgumentNullException">A facebook username is required to lookup a person by facebook.</exception>
88-
public Person LookupPersonByFacebook(string facebookUsername, int? queue = null, string webhookUrl = null)
88+
public PersonResponse LookupPersonByFacebook(string facebookUsername, int? queue = null, string webhookUrl = null)
8989
{
9090
if (string.IsNullOrEmpty(facebookUsername)) throw new ArgumentNullException("A facebook username is required to lookup a person by facebook.");
9191

9292
var request = GetPersonRequest(queue, webhookUrl);
9393
request.AddParameter("facebookUsername", facebookUsername);
94-
return Execute<Person>(request);
94+
return Execute<PersonResponse>(request);
9595
}
9696

9797
/// <summary>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using FullContactDotNet.Entities;
2+
3+
namespace FullContactDotNet
4+
{
5+
public interface IFullContactEmailApi
6+
{
7+
/// <summary>
8+
/// Detects the disposable email.
9+
/// </summary>
10+
/// <param name="emailAddress">The email address.</param>
11+
/// <returns></returns>
12+
DisposableEmailResponse DetectDisposableEmail(string emailAddress);
13+
}
14+
}

FullContactDotNet/IFullContactPersonApi.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface IFullContactPersonApi
1111
/// <param name="queue">The queue.</param>
1212
/// <param name="webhookUrl">The webhook url.</param>
1313
/// <returns></returns>
14-
Person LookupPersonByEmail(string emailAddress, int? queue = null, string webhookUrl = null);
14+
PersonResponse LookupPersonByEmail(string emailAddress, int? queue = null, string webhookUrl = null);
1515

1616
/// <summary>
1717
/// Lookup Person by phone number.
@@ -21,7 +21,7 @@ public interface IFullContactPersonApi
2121
/// <param name="queue">The queue.</param>
2222
/// <param name="webhookUrl">The webhook url.</param>
2323
/// <returns></returns>
24-
Person LookupPersonByPhone(string phoneNumber, string countryCode = null, int? queue = null, string webhookUrl = null);
24+
PersonResponse LookupPersonByPhone(string phoneNumber, string countryCode = null, int? queue = null, string webhookUrl = null);
2525

2626
/// <summary>
2727
/// Lookup Person by twitter username.
@@ -30,7 +30,7 @@ public interface IFullContactPersonApi
3030
/// <param name="queue">The queue.</param>
3131
/// <param name="webhookUrl">The webhook url.</param>
3232
/// <returns></returns>
33-
Person LookupPersonByTwitter(string twitterUsername, int? queue = null, string webhookUrl = null);
33+
PersonResponse LookupPersonByTwitter(string twitterUsername, int? queue = null, string webhookUrl = null);
3434

3535
/// <summary>
3636
/// Lookup Person by facebook username.
@@ -39,6 +39,6 @@ public interface IFullContactPersonApi
3939
/// <param name="queue">The queue.</param>
4040
/// <param name="webhookUrl">The webhook url.</param>
4141
/// <returns></returns>
42-
Person LookupPersonByFacebook(string facebookUsername, int? queue = null, string webhookUrl = null);
42+
PersonResponse LookupPersonByFacebook(string facebookUsername, int? queue = null, string webhookUrl = null);
4343
}
4444
}

0 commit comments

Comments
 (0)