Completed
Push — master ( 6e9196...c55090 )
by Nate
02:30
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 ConnectionTrait,
21
        CacheTrait;
22
23
    /**
24
     * @var string
25
     */
26
    public $id;
27
28
    /**
29
     * @var array
30
     */
31
    public $vids = [];
32
33
    /**
34
     * @var array
35
     */
36
    public $emails = [];
37
38
    /**
39
     * @return string
40
     */
41
    public function getId(): string
42
    {
43
        return (string)$this->id;
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getPayload(): array
50
    {
51
        return array_filter(
52
            [
53
                'vids' => array_filter($this->vids),
54
                'emails' => array_filter($this->emails)
55
            ]
56
        );
57
    }
58
59
    /**
60
     * @param array $criteria
61
     * @param array $config
62
     * @return ResponseInterface
63
     */
64
    public function add(array $criteria = [], array $config = []): ResponseInterface
65
    {
66
        $this->populate($criteria);
67
68
        return ContactListContacts::add(
69
            $this->getId(),
70
            $this->getPayload(),
71
            $this->getConnection(),
72
            $this->getCache(),
73
            $this->getLogger(),
74
            $config
75
        );
76
    }
77
78
    /**
79
     * @param array $criteria
80
     * @param array $config
81
     * @return ResponseInterface
82
     */
83
    public function remove(array $criteria = [], array $config = []): ResponseInterface
84
    {
85
        $this->populate($criteria);
86
87
        return ContactListContacts::remove(
88
            $this->getId(),
89
            $this->getPayload(),
90
            $this->getConnection(),
91
            $this->getCache(),
92
            $this->getLogger(),
93
            $config
94
        );
95
    }
96
}
97