1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://github.com/flipbox/relay-hubspot/blob/master/LICENSE |
6
|
|
|
* @link https://github.com/flipbox/relay-hubspot |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Flipbox\Relay\HubSpot\Builder\Resources\Company; |
10
|
|
|
|
11
|
|
|
use Flipbox\Relay\HubSpot\AuthorizationInterface; |
12
|
|
|
use Flipbox\Relay\HubSpot\Builder\HttpRelayBuilder; |
13
|
|
|
use Flipbox\Relay\HubSpot\Middleware\ResourceV2; |
14
|
|
|
use Psr\Log\LoggerInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Flipbox Factory <[email protected]> |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
*/ |
20
|
|
|
class AddContact extends HttpRelayBuilder |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* The node |
24
|
|
|
*/ |
25
|
|
|
const NODE = 'companies'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The resource |
29
|
|
|
*/ |
30
|
|
|
const RESOURCE = 'companies'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Upsert constructor. |
34
|
|
|
* @param string $companyId |
35
|
|
|
* @param string $contactId |
36
|
|
|
* @param AuthorizationInterface $authorization |
37
|
|
|
* @param LoggerInterface|null $logger |
38
|
|
|
* @param array $config |
39
|
|
|
*/ |
40
|
|
|
public function __construct( |
41
|
|
|
string $companyId, |
42
|
|
|
string $contactId, |
43
|
|
|
AuthorizationInterface $authorization, |
44
|
|
|
LoggerInterface $logger = null, |
45
|
|
|
$config = [] |
46
|
|
|
) { |
47
|
|
|
parent::__construct($authorization, $logger, $config); |
48
|
|
|
|
49
|
|
|
$this->addUri($companyId, $contactId, $logger); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $companyId |
54
|
|
|
* @param string $contactId |
55
|
|
|
* @param LoggerInterface|null $logger |
56
|
|
|
* @return $this |
57
|
|
|
*/ |
58
|
|
|
protected function addUri(string $companyId, string $contactId, LoggerInterface $logger = null) |
59
|
|
|
{ |
60
|
|
|
return $this->addBefore('uri', [ |
61
|
|
|
'class' => ResourceV2::class, |
62
|
|
|
'method' => 'PUT', |
63
|
|
|
'node' => self::NODE, |
64
|
|
|
'resource' => self::RESOURCE . '/' . $companyId . '/contacts/' . $contactId, |
65
|
|
|
'logger' => $logger ?: $this->getLogger() |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |