Skip to content

Commit a83d8c6

Browse files
committed
Merge branch 'riccagroup-master'
2 parents 07f2ce7 + 881774b commit a83d8c6

File tree

4 files changed

+103
-20
lines changed

4 files changed

+103
-20
lines changed

composer.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
22
"name": "kickbox/kickbox",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "Official kickbox API library client for PHP",
55
"homepage": "http://kickbox.io",
6-
"authors": [
7-
{
8-
"name": "Chaitanya Surapaneni",
9-
"email": "chaitanya.surapaneni@kickbox.io",
10-
"homepage": "https://github.com/kickboxio"
11-
}
12-
],
6+
"authors": [{
7+
"name": "Chaitanya Surapaneni",
8+
"email": "chaitanya.surapaneni@kickbox.io",
9+
"homepage": "https://github.com/kickboxio"
10+
}],
1311
"keywords": [
1412
"free",
1513
"email",
@@ -38,13 +36,13 @@
3836
"friendsofphp/php-cs-fixer": "^2.3"
3937
},
4038
"support": {
41-
"email": "help@kickbox.io",
39+
"email": "help@kickbox.io",
4240
"docs": "https://docs.kickbox.io",
4341
"issues": "https://github.com/kickboxio/kickbox-php/issues"
4442
},
45-
"scripts":{
43+
"scripts": {
4644
"test": "./vendor/bin/phpunit",
4745
"fix-style": "./vendor/bin/php-cs-fixer fix ."
4846
},
4947
"license": "MIT"
50-
}
48+
}

lib/Kickbox/Api/Kickbox.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,56 @@ public function verify($email, array $options = [])
3131

3232
return $this->client->get('/v2/verify', $body, $options);
3333
}
34+
35+
/**
36+
* Start a verify batch process
37+
* @param array $emails List of Email addresses
38+
* @param array $options Options for PUT request
39+
* @return \Kickbox\HttpClient\Response
40+
*/
41+
public function verifyBatch($emails, array $options = [])
42+
{
43+
if(empty($options['headers'])) {
44+
$options['headers'] = [];
45+
}
46+
$options['headers'] = array_merge([
47+
'Content-Type' => 'text/csv',
48+
'X-Kickbox-Filename' => 'Batch API Process - '.date('m-d-Y-H-i-s')
49+
], $options['headers']);
50+
$emails = join("\n", $emails);
51+
return $this->client->put('/v2/verify-batch', $emails, $options);
52+
}
53+
54+
/**
55+
* Get a batch result
56+
* @param integer $id Batch ID to check
57+
* @param array $options Options for GET request
58+
* @return \Kickbox\HttpClient\Response
59+
*/
60+
public function getBatchResults($id, array $options = []) {
61+
return $this->client->get('/v2/verify-batch/'.$id, [], $options);
62+
}
63+
64+
/**
65+
* Check if an email is isDisposable
66+
* @param string $email Email address to check
67+
* @param array $options Options for GET request
68+
* @return \Kickbox\HttpClient\Response
69+
*/
70+
public function isDisposable($email, array $options = []) {
71+
$options = array_merge([
72+
'base_uri' => 'https://open.kickbox.io',
73+
'api_version' => 'v1',
74+
], $options);
75+
return $this->client->get('/v1/disposable/'.$email, [], $options);
76+
}
77+
78+
/**
79+
* Check the credit balance
80+
* @param array $options Options for GET request
81+
* @return \Kickbox\HttpClient\Response
82+
*/
83+
public function getCreditBalance(array $options = []) {
84+
return $this->client->get('/v2/balance', [], $options);
85+
}
3486
}

lib/Kickbox/Api/KickboxInterface.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,37 @@ interface KickboxInterface
1313
* @throws \ErrorException|\RuntimeException
1414
*/
1515
public function verify($email, array $options = []);
16+
17+
/**
18+
* @method verifyBatch
19+
* @param array $emails
20+
* @param array $options
21+
* @return Response
22+
* @throws \ErrorException|\RuntimeException
23+
*/
24+
public function verifyBatch($emails, array $options = []);
25+
26+
/**
27+
* @param integer $id
28+
* @param array $options
29+
* @return Response
30+
* @throws \ErrorException|\RuntimeException
31+
*/
32+
public function getBatchResults($id, array $options = []);
33+
34+
35+
/**
36+
* @param string $email
37+
* @param array $options
38+
* @return Response
39+
* @throws \ErrorException|\RuntimeException
40+
*/
41+
public function isDisposable($email, array $options = []);
42+
43+
/**
44+
* @param array $options
45+
* @return Response
46+
* @throws \ErrorException|\RuntimeException
47+
*/
48+
public function getCreditBalance(array $options = []);
1649
}

lib/Kickbox/HttpClient/HttpClient.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class HttpClient implements HttpClientInterface
2323
'base_uri' => 'https://api.kickbox.io',
2424
'api_version' => 'v2',
2525
'headers' => [
26-
'user-agent' => 'kickbox-php/2.2.2 (https://github.com/kickboxio/kickbox-php)'
26+
'user-agent' => 'kickbox-php/2.2.3 (https://github.com/kickboxio/kickbox-php)'
2727
]
2828
];
2929

@@ -81,27 +81,27 @@ public function put($path, $body, array $options = [])
8181

8282
/**
8383
* @param $path
84-
* @param array $body
84+
* @param $body
8585
* @param string $httpMethod
8686
* @param array $options
8787
* @return Response
8888
* @throws \ErrorException|\RuntimeException
8989
*/
90-
private function request($path, array $body = [], $httpMethod = 'GET', array $options = [])
90+
private function request($path, $body, $httpMethod = 'GET', array $options = [])
9191
{
92-
if (isset($options['body'])) {
93-
$body = array_merge($options['body'], $body);
94-
}
95-
9692
$headers = [];
9793
if (isset($options['headers'])) {
9894
$headers = $options['headers'];
9995
unset($options['headers']);
10096
}
10197

102-
$options['body'] = json_encode($body);
98+
unset($options['body']);
99+
100+
if(!empty($body))
101+
$options['body'] = $body;
102+
103103
$options['headers'] = array_merge($headers, self::$options['headers']);
104-
$options = array_merge($options, self::$options);
104+
$options = array_merge(self::$options, $options);
105105

106106
try {
107107
$response = $this->client->request($httpMethod, $path, $options);

0 commit comments

Comments
 (0)