Completed
Push — develop ( 1df43e...024668 )
by Nate
01:43
created

RemoveContact::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 2
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 RemoveContact 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' => 'DELETE',
63
            'node' => self::NODE,
64
            'resource' => self::RESOURCE . '/' . $companyId . '/contacts/' . $contactId,
65
            'logger' => $logger ?: $this->getLogger()
66
        ]);
67
    }
68
69
}