Completed
Push — master ( 76552b...80e7ff )
by Nate
01:02
created

ObjectCriteria::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 12
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/salesforce/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/salesforce
7
 */
8
9
namespace Flipbox\Salesforce\Criteria;
10
11
use Flipbox\Salesforce\Resources\SObject;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 3.3.0
17
 */
18
class ObjectCriteria extends AbstractCriteria
19
{
20
    use ConnectionTrait,
21
        CacheTrait,
22
        IdAttributeTrait,
23
        ObjectAttributeTrait,
24
        PayloadAttributeTrait;
25
26
    /**
27
     * @param array $criteria
28
     * @param array $config
29
     * @return ResponseInterface
30
     * @throws \Exception
31
     */
32
    public function basic(array $criteria = [], array $config = []): ResponseInterface
33
    {
34
        $this->populate($criteria);
35
36
        return SObject::basic(
37
            $this->getObject(),
38
            $this->getConnection(),
39
            $this->getCache(),
40
            $this->getLogger(),
41
            $config
42
        );
43
    }
44
45
    /**
46
     * @param array $criteria
47
     * @param array $config
48
     * @return ResponseInterface
49
     * @throws \Exception
50
     */
51
    public function describe(array $criteria = [], array $config = []): ResponseInterface
52
    {
53
        $this->populate($criteria);
54
55
        return SObject::describe(
56
            $this->getObject(),
57
            $this->getConnection(),
58
            $this->getCache(),
59
            $this->getLogger(),
60
            $config
61
        );
62
    }
63
64
    /**
65
     * @param array $criteria
66
     * @param array $config
67
     * @return ResponseInterface
68
     * @throws \Exception
69
     */
70
    public function read(array $criteria = [], array $config = []): ResponseInterface
71
    {
72
        $this->populate($criteria);
73
74
        return SObject::read(
75
            $this->getObject(),
76
            $this->getId(),
77
            $this->getConnection(),
78
            $this->getCache(),
79
            $this->getLogger(),
80
            $config
81
        );
82
    }
83
84
    /**
85
     * @param array $criteria
86
     * @param array $config
87
     * @return ResponseInterface
88
     * @throws \Exception
89
     */
90
    public function create(array $criteria = [], array $config = []): ResponseInterface
91
    {
92
        $this->populate($criteria);
93
94
        return SObject::create(
95
            $this->getObject(),
96
            $this->getPayload(),
97
            $this->getConnection(),
98
            $this->getLogger(),
99
            $config
100
        );
101
    }
102
103
    /**
104
     * @param array $criteria
105
     * @param array $config
106
     * @return ResponseInterface
107
     * @throws \Exception
108
     */
109
    public function update(array $criteria = [], array $config = []): ResponseInterface
110
    {
111
        $this->populate($criteria);
112
113
        return SObject::update(
114
            $this->getObject(),
115
            $this->getPayload(),
116
            $this->getId(),
117
            $this->getConnection(),
118
            $this->getCache(),
119
            $this->getLogger(),
120
            $config
121
        );
122
    }
123
124
    /**
125
     * @param array $criteria
126
     * @param array $config
127
     * @return ResponseInterface
128
     * @throws \Exception
129
     */
130
    public function upsert(array $criteria = [], array $config = []): ResponseInterface
131
    {
132
        $this->populate($criteria);
133
134
        return SObject::upsert(
135
            $this->getObject(),
136
            $this->getPayload(),
137
            $this->getId(),
138
            $this->getConnection(),
139
            $this->getCache(),
140
            $this->getLogger(),
141
            $config
142
        );
143
    }
144
145
    /**
146
     * @param array $criteria
147
     * @param array $config
148
     * @return ResponseInterface
149
     * @throws \Exception
150
     */
151
    public function delete(array $criteria = [], array $config = []): ResponseInterface
152
    {
153
        $this->populate($criteria);
154
155
        return SObject::delete(
156
            $this->getObject(),
157
            $this->getId(),
158
            $this->getConnection(),
159
            $this->getCache(),
160
            $this->getLogger(),
161
            $config
162
        );
163
    }
164
}
165