Completed
Push — master ( bb722b...3bdf28 )
by Nate
02:16
created

ContactListContactsMutatorCriteria::getPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/hubspot/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/hubspot
7
 */
8
9
namespace Flipbox\HubSpot\Criteria;
10
11
use Flipbox\HubSpot\Resources\ContactListContacts;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
class ContactListContactsMutatorCriteria extends AbstractCriteria
19
{
20
    use IdAttributeTrait,
21
        ConnectionTrait,
22
        CacheTrait;
23
24
    /**
25
     * @var array
26
     */
27
    public $vids = [];
28
29
    /**
30
     * @var array
31
     */
32
    public $emails = [];
33
34
    /**
35
     * @return array
36
     */
37
    public function getPayload(): array
38
    {
39
        return array_filter(
40
            [
41
                'vids' => array_filter($this->vids),
42
                'emails' => array_filter($this->emails)
43
            ]
44
        );
45
    }
46
47
    /**
48
     * @param array $criteria
49
     * @param array $config
50
     * @return ResponseInterface
51
     * @throws \Exception
52
     */
53
    public function add(array $criteria = [], array $config = []): ResponseInterface
54
    {
55
        $this->populate($criteria);
56
57
        return ContactListContacts::add(
58
            $this->getId(),
59
            $this->getPayload(),
60
            $this->getConnection(),
61
            $this->getCache(),
62
            $this->getLogger(),
63
            $config
64
        );
65
    }
66
67
    /**
68
     * @param array $criteria
69
     * @param array $config
70
     * @return ResponseInterface
71
     * @throws \Exception
72
     */
73
    public function remove(array $criteria = [], array $config = []): ResponseInterface
74
    {
75
        $this->populate($criteria);
76
77
        return ContactListContacts::remove(
78
            $this->getId(),
79
            $this->getPayload(),
80
            $this->getConnection(),
81
            $this->getCache(),
82
            $this->getLogger(),
83
            $config
84
        );
85
    }
86
}
87