|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace wlbrough\clearbit; |
|
4
|
|
|
|
|
5
|
|
|
use wlbrough\clearbit\Abstracts\Api; |
|
6
|
|
|
|
|
7
|
|
|
class EnrichmentApi extends Api |
|
8
|
|
|
{ |
|
9
|
|
|
private static $apiUrlTemplate = 'https://pk:@%s%s.clearbit.com/v2/%s/find?%s=%s'; |
|
10
|
|
|
|
|
11
|
24 |
|
public function __construct($key, $client = null) |
|
12
|
|
|
{ |
|
13
|
24 |
|
self::$apiUrlTemplate = preg_replace('(pk)', $key, self::$apiUrlTemplate); |
|
14
|
24 |
|
$this->httpClient = $client; |
|
15
|
24 |
|
} |
|
16
|
|
|
|
|
17
|
6 |
|
public function combined($email) |
|
18
|
|
|
{ |
|
19
|
6 |
|
$apiUrl = $this->composeUrl('person', 'combined', 'email', $email); |
|
20
|
6 |
|
return $this->call($apiUrl, $this->httpClient); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
6 |
|
public function person($email, $subscribe = false) |
|
24
|
|
|
{ |
|
25
|
6 |
|
$apiUrl = $this->composeUrl('person', 'people', 'email', $email); |
|
26
|
|
|
|
|
27
|
6 |
|
if ($subscribe) { |
|
28
|
|
|
$apiUrl .= '&subscribe=true'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
6 |
|
return $this->call($apiUrl, $this->httpClient); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function flagPerson($personId, $corrected = null) |
|
35
|
|
|
{ |
|
36
|
|
|
$apiUrl = "https://person.clearbit.com/v1/people/$personId/flag"; |
|
37
|
|
|
return $this->post($apiUrl, $corrected, 200, $this->httpClient); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
6 |
|
public function company($domain) |
|
41
|
|
|
{ |
|
42
|
6 |
|
$apiUrl = $this->composeUrl('company', 'companies', 'domain', $domain); |
|
43
|
6 |
|
return $this->call($apiUrl, $this->httpClient); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function flagCompany($domain, $corrected = null) |
|
47
|
|
|
{ |
|
48
|
|
|
$apiUrl = "https://company.clearbit.com/v2/companies/flag?domain=$domain"; |
|
49
|
|
|
return $this->post($apiUrl, $corrected, 200, $this->httpClient); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
18 |
|
private function composeUrl($subdomain, $path, $query, $parameter) |
|
53
|
|
|
{ |
|
54
|
18 |
|
$streaming = $this->useStreaming ? '' : '-streaming'; |
|
55
|
18 |
|
return sprintf(self::$apiUrlTemplate, $subdomain, $streaming, $path, $query, $parameter); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|