Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ UpgradeLog*.XML

MSTest.*

*.nupkg
*.nupkg
/packages/*
4 changes: 2 additions & 2 deletions PiplApisProd.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piplapis", "Piplapis\Piplapis.csproj", "{E9921187-C395-422D-844A-6136C55CD6BC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Piplapis", "Piplapis\Piplapis.csproj", "{E9921187-C395-422D-844A-6136C55CD6BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{D7E2E676-B827-47EE-B82A-89686DB6D00F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{D7E2E676-B827-47EE-B82A-89686DB6D00F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
8 changes: 6 additions & 2 deletions Piplapis/Data/Fields/Phone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ public override bool IsSearchable
{
get
{
return (!string.IsNullOrEmpty(Raw)) ||
(Number != null && (CountryCode == null || CountryCode >= 0 && CountryCode < 999));

if (!string.IsNullOrEmpty(Raw)) return true;
if (CountryCode == null && Number >= 99999999) return true;
if (CountryCode != null && CountryCode>0 && CountryCode <=999 && Number >= 999999) return true;
return false;

}
}

Expand Down
2 changes: 1 addition & 1 deletion Piplapis/Piplapis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
196 changes: 185 additions & 11 deletions UnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,67 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;

using Pipl.APIs;
using Pipl.APIs.Search;
using Pipl.APIs.Data;
using Pipl.APIs.Data.Fields;
using Pipl.APIs.Data.Containers;
using Pipl.APIs.Data.Enums;
using Pipl.APIs.Utils;

namespace UnitTests

namespace UnitTestProjectAPIc
{

[TestClass]
public class UnitTest1
{
public static string API_KEY = "YOUR API KEY HERE";


public UnitTest1()
{
//Init();
}
private SearchConfiguration setDefaultSearchConfiguration()
{
//edit your API key in appsettings app.config file such as: <appSettings > < add key = "PIPL_APIKey" value = "YOURKEY" /></ appSettings >
//this is not working perhaps bec of project differences or because of test project; see irregularTTextParser project
//string api_key = ConfigurationManager.AppSettings.Get("Pipl_APIKey"); //?? throw new ArgumentNullException("No PIPL API key set in App.config");
string api_key = "BUSINESS-PREMIUM-YOURKEY";

return new SearchConfiguration()
{
ApiKey = api_key,
ShowSources = ShowSources.Matching,
//For improved latency, rate and consistent results
LiveFeeds = false,

//Work only with single matching profiles (Person responses), and must have social_profiles including LinkedIn sources
// see https://pipl.com/api/reference/#match-criteria and https://pipl.com/api/reference/#source
MinimumMatch = 1,
MatchRequirements = "social_profiles",
SourceCategoryRequirements = "professional_and_business",
UseHttps = true

};

}

[TestMethod]
public void TestTopMatch()
{
SearchConfiguration config = new SearchConfiguration(topMatch: true, apiKey: API_KEY);
SearchAPIRequest s = new SearchAPIRequest(firstName: "Moshe", lastName: "Elkayam", requestConfiguration: config);

SearchConfiguration sConfig = setDefaultSearchConfiguration();
sConfig.TopMatch = true;
SearchAPIRequest s = new SearchAPIRequest(firstName: "Moshe", lastName: "Elkayam", requestConfiguration: sConfig);
SearchAPIResponse res = s.Send();

Assert.IsTrue(res.TopMatch);
Expand All @@ -25,12 +70,141 @@ public void TestTopMatch()
[TestMethod]
public void TestNotTopMatch()
{
SearchConfiguration config = new SearchConfiguration(apiKey: API_KEY);
SearchAPIRequest s = new SearchAPIRequest(firstName: "Moshe", lastName: "Elkayam", requestConfiguration: config);

SearchConfiguration sConfig = setDefaultSearchConfiguration();
SearchAPIRequest s = new SearchAPIRequest(firstName: "Moshe", lastName: "Elkayam", requestConfiguration: sConfig);
SearchAPIResponse res = s.Send();

Assert.IsFalse(res.TopMatch);
}

[TestMethod]
public void aaa_testControlCheck()
{

Debug.WriteLine("hi. Control check. ");
Assert.IsTrue(true);
}
[TestMethod]
public void TestPersonPhoneQParam()
{
SearchConfiguration sConfig = setDefaultSearchConfiguration();
List<Field> fields = new List<Field>();
var person = new Person(fields);

SearchAPIRequest request = new SearchAPIRequest(phone: "+14152549431", requestConfiguration: sConfig);
SearchAPIResponse response = request.Send();
Assert.IsTrue(response.Person != null);

request = new SearchAPIRequest(phone: "14152549431", requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.Person != null);

request = new SearchAPIRequest(phone: "+14152549431", requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.Person != null);

request = new SearchAPIRequest(phone: "+972508915495", requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.PersonsCount == 0);

request = new SearchAPIRequest(phone: "4152549431", requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.Person != null);

//fields.Add(new Phone(raw: "4152549431")); //Clark Kent #
//SearchAPIRequest request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
//fields.Add(new Phone(countryCode: System.Convert.ToInt32(recIn.CountryCode), number: System.Convert.ToInt64(recIn.PhoneNum)));

}


[TestMethod]
public void TestPersonPhonePersonSearch()
{
SearchConfiguration sConfig = setDefaultSearchConfiguration();
List<Field> fields = new List<Field>();

fields.Add(new Phone(countryCode: 1, number: 4152549431));
var person = new Person(fields);
SearchAPIRequest request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
SearchAPIResponse response = request.Send();
Assert.IsTrue(response.Person != null);

fields = new List<Field>();
fields.Add(new Phone(number: 4152549431));
person = new Person(fields);
request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.Person != null);

fields = new List<Field>();
fields.Add(new Phone(countryCode: 34, number: 636117049));
person = new Person(fields);
request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
response = request.Send();
Assert.IsTrue(response.PersonsCount >= 0);
}
[TestMethod]
public void TestPersonPhonePersonSearchNull()
{
SearchConfiguration sConfig = setDefaultSearchConfiguration();
List<Field> fields = new List<Field>();

fields = new List<Field>();
fields.Add(new Phone(countryCode: null, number: 636117049));
var person = new Person(fields);
SearchAPIRequest request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
request = new SearchAPIRequest(person: person, requestConfiguration: sConfig);
SearchAPIResponse response;

try
{
response = request.Send();
Assert.IsTrue(false); //if it gets this far, it's false;
}
catch (SearchAPIError apiError)
{
Assert.IsTrue(apiError.Error == "The query does not contain any valid name/username/user_id/phone/email/address to search by");
}
catch (System.Net.WebException e)
{ }
catch (Exception e)
{ }

}



[TestMethod]
public void TestIsPhoneSearchable()
{
SearchConfiguration sConfig = setDefaultSearchConfiguration();
List<Field> fields = new List<Field>();

fields.Add(new Phone(countryCode: 1, number: 4152549431));
Assert.IsTrue(fields[0].IsSearchable);
fields.Add(new Phone(countryCode: 9, number: 4152549431));
Assert.IsTrue(fields[1].IsSearchable);
fields.Add(new Phone(countryCode: 999, number: 4152549431));
Assert.IsTrue(fields[2].IsSearchable);
fields.Add(new Phone(countryCode: +1, number: +4152549431));
Assert.IsTrue(fields[3].IsSearchable);
fields.Add(new Phone(countryCode: 34, number: 636117049));
Assert.IsTrue(fields[4].IsSearchable);
fields.Add(new Phone(countryCode: +34, number: +636117049));
Assert.IsTrue(fields[5].IsSearchable);
fields.Add(new Phone(countryCode: -1, number: -4152549431));
Assert.IsFalse(fields[6].IsSearchable);
fields.Add(new Phone(countryCode: 9999, number: 636117049));
Assert.IsFalse(fields[7].IsSearchable);
fields.Add(new Phone(countryCode: 1, number: 99999));
Assert.IsFalse(fields[8].IsSearchable);
fields.Add(new Phone(countryCode: null, number: +4152549431));
Assert.IsTrue(fields[9].IsSearchable);
fields.Add(new Phone(countryCode: null, number: +4152549431));
Assert.IsTrue(fields[10].IsSearchable);

}

}
}
4 changes: 2 additions & 2 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Piplapis\Piplapis.csproj" />
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
<ProjectReference Include="..\Piplapis\Piplapis.csproj" />
</ItemGroup>

</Project>