-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKickBox.ps1
More file actions
51 lines (37 loc) · 1.56 KB
/
KickBox.ps1
File metadata and controls
51 lines (37 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class KickBox
{
[string] $apiKey;
KickBox([string] $ApiKey)
{
$this.apiKey = $ApiKey;
}
[object] verifySingleEmail([string] $emailAddress)
{
$inputData = @{"email" = $emailAddress};
return $this.callApi('verify', 'GET', $inputData) | ConvertFrom-Json;
}
[object] verifyBulkEmail([string[]] $emailAddresses) {
return this.callApi('verify-batch', 'PUT') | ConvertFrom-Json;
}
[object] checkVerificationStatus([string] $jobId) {
return this.callApi("verify-batch/$jobId", 'GET') | ConvertFrom-Json;
}
# Private Helpers
hidden [object] callApi([string]$apiMethod, [string] $httpMethod, $inputData) {
$contentType = 'application/octet-stream';
$queryString = '';
if($httpMethod -eq 'PUT'){
$contentType = 'text/csv';
}
$headers = @{ 'Content-Type' = $contentType }
foreach($key in $inputData.Keys) {
$queryString = $queryString + "&" + $key + "=" + $inputData[$key]
}
$queryString = $queryString + "&apikey=" + $this.apiKey;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
return Invoke-WebRequest -Uri "https://api.kickbox.com/v2/$apiMethod\?$queryString" -Method $httpMethod -Headers $headers; # -Body $this.inputData;
}
}
$kickboxObject = New-Object KickBox('live_740aa12661f1a3edb6a27e0ce6fc053d5ba218e92ce7bb21c389f8e848c2c5fa');
$singleVerificationResponse = $kickboxObject.verifySingleEmail('brandon.osborne@coderpro.net');
Write-Output('test')