1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Integrations\Connectors\ExactSales; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
6
|
|
|
use Log; |
7
|
|
|
use App\Models\User; |
8
|
|
|
use Integrations\Connectors\Connector; |
9
|
|
|
|
10
|
|
|
class ExactSales extends Connector |
11
|
|
|
{ |
12
|
|
|
public static $ID = 33; |
13
|
|
|
protected function getConnection($token = false) |
14
|
|
|
{ |
15
|
|
|
$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; |
16
|
|
|
return new Pipedrive($token); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
// private $config; |
20
|
|
|
// private $curl; |
21
|
|
|
// private $token; |
22
|
|
|
// private $apiUrl = "api.spotter.exactsales.com.br/api/v2"; |
23
|
|
|
// private $apiProcotol = "https://"; |
24
|
|
|
|
25
|
|
|
// public function __construct($token) |
26
|
|
|
// { |
27
|
|
|
// $this->curl = new Curl(); |
28
|
|
|
// $this->token = $token; |
29
|
|
|
// } |
30
|
|
|
|
31
|
|
|
// public function inserirLead($parameters, $validar_duplicidade = 1, $addcampospersonalizados = 0) |
32
|
|
|
// { |
33
|
|
|
// $this->curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE); |
34
|
|
|
// $this->curl->setOpt(CURLOPT_HEADER, FALSE); |
35
|
|
|
// $this->curl->setOpt(CURLOPT_HTTPHEADER, array( |
36
|
|
|
// "Content-Type: application/json", |
37
|
|
|
// "token_exact: ".$this->token |
38
|
|
|
// ) |
39
|
|
|
// ); |
40
|
|
|
// $url = $this->apiProcotol.$this->apiUrl."/leads?validar_duplicidade=".$validar_duplicidade."&addcampospersonalizados=".$addcampospersonalizados; |
41
|
|
|
// $this->curl->post($url, json_encode($parameters)); |
42
|
|
|
// if ($this->curl->error) |
43
|
|
|
// return $this->treatError(); |
44
|
|
|
// else |
45
|
|
|
// return $this->treatSuccess($this->curl->response); |
46
|
|
|
|
47
|
|
|
// } |
48
|
|
|
|
49
|
|
|
// private function treatSuccess($response) |
50
|
|
|
// { |
51
|
|
|
// $response = json_decode($response, true); |
52
|
|
|
// return $response; |
53
|
|
|
// } |
54
|
|
|
|
55
|
|
|
// private function treatError() |
56
|
|
|
// { |
57
|
|
|
// $message = array(); |
58
|
|
|
// $message['error'] = true; |
59
|
|
|
// $message['error_code'] = $this->curl->error_code; |
60
|
|
|
// $message['error_message'] = $this->curl->error_message; |
61
|
|
|
// return json_encode($message); |
62
|
|
|
// } |
63
|
|
|
} |
64
|
|
|
|