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\Resources; |
10
|
|
|
|
11
|
|
|
use Flipbox\HubSpot\Connections\ConnectionInterface; |
12
|
|
|
use Flipbox\HubSpot\HubSpot; |
13
|
|
|
use Flipbox\Relay\Builder\RelayBuilderInterface; |
14
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\ContactList\Contacts\Add; |
15
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\ContactList\Contacts\All; |
16
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\ContactList\Contacts\Remove; |
17
|
|
|
use Psr\Http\Message\ResponseInterface; |
18
|
|
|
use Psr\Log\LoggerInterface; |
19
|
|
|
use Psr\SimpleCache\CacheInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Flipbox Factory <[email protected]> |
23
|
|
|
* @since 2.0.0 |
24
|
|
|
*/ |
25
|
|
|
class ContactListContacts |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
/******************************************* |
29
|
|
|
* READ |
30
|
|
|
*******************************************/ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $identifier |
34
|
|
|
* @param ConnectionInterface|null $connection |
35
|
|
|
* @param CacheInterface|null $cache |
36
|
|
|
* @param LoggerInterface|null $logger |
37
|
|
|
* @param array $config |
38
|
|
|
* @return ResponseInterface |
39
|
|
|
*/ |
40
|
|
|
public static function all( |
41
|
|
|
string $identifier, |
42
|
|
|
ConnectionInterface $connection = null, |
43
|
|
|
CacheInterface $cache = null, |
44
|
|
|
LoggerInterface $logger = null, |
45
|
|
|
array $config = [] |
46
|
|
|
): ResponseInterface { |
47
|
|
|
return static::allRelay( |
48
|
|
|
$identifier, |
49
|
|
|
$connection, |
50
|
|
|
$cache, |
51
|
|
|
$logger, |
52
|
|
|
$config |
53
|
|
|
)(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $identifier |
58
|
|
|
* @param ConnectionInterface|null $connection |
59
|
|
|
* @param CacheInterface|null $cache |
60
|
|
|
* @param LoggerInterface|null $logger |
61
|
|
|
* @param array $config |
62
|
|
|
* @return callable |
63
|
|
|
*/ |
64
|
|
|
public static function allRelay( |
65
|
|
|
string $identifier, |
66
|
|
|
ConnectionInterface $connection = null, |
67
|
|
|
CacheInterface $cache = null, |
68
|
|
|
LoggerInterface $logger = null, |
69
|
|
|
array $config = [] |
70
|
|
|
): callable { |
71
|
|
|
$builder = new All( |
72
|
|
|
$identifier, |
73
|
|
|
$connection ?: HubSpot::getConnection(), |
74
|
|
|
$cache ?: HubSpot::getCache(), |
75
|
|
|
$logger ?: HubSpot::getLogger(), |
76
|
|
|
$config |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
return $builder->build(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/******************************************* |
84
|
|
|
* ADD |
85
|
|
|
*******************************************/ |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string $identifier |
89
|
|
|
* @param array $payload |
90
|
|
|
* @param ConnectionInterface|null $connection |
91
|
|
|
* @param CacheInterface|null $cache |
92
|
|
|
* @param LoggerInterface|null $logger |
93
|
|
|
* @param array $config |
94
|
|
|
* @return ResponseInterface |
95
|
|
|
*/ |
96
|
|
|
public static function add( |
97
|
|
|
string $identifier, |
98
|
|
|
array $payload, |
99
|
|
|
ConnectionInterface $connection = null, |
100
|
|
|
CacheInterface $cache = null, |
101
|
|
|
LoggerInterface $logger = null, |
102
|
|
|
array $config = [] |
103
|
|
|
): ResponseInterface { |
104
|
|
|
return static::addRelay( |
105
|
|
|
$identifier, |
106
|
|
|
$payload, |
107
|
|
|
$connection, |
108
|
|
|
$cache, |
109
|
|
|
$logger, |
110
|
|
|
$config |
111
|
|
|
)(); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string $identifier |
116
|
|
|
* @param array $payload |
117
|
|
|
* @param ConnectionInterface|null $connection |
118
|
|
|
* @param CacheInterface|null $cache |
119
|
|
|
* @param LoggerInterface|null $logger |
120
|
|
|
* @param array $config |
121
|
|
|
* @return callable |
122
|
|
|
*/ |
123
|
|
|
public static function addRelay( |
124
|
|
|
string $identifier, |
125
|
|
|
array $payload, |
126
|
|
|
ConnectionInterface $connection = null, |
127
|
|
|
CacheInterface $cache = null, |
128
|
|
|
LoggerInterface $logger = null, |
129
|
|
|
array $config = [] |
130
|
|
|
): callable { |
131
|
|
|
/** @var RelayBuilderInterface $builder */ |
132
|
|
|
$builder = new Add( |
133
|
|
|
$identifier, |
134
|
|
|
$payload, |
135
|
|
|
$connection ?: HubSpot::getConnection(), |
136
|
|
|
$cache ?: HubSpot::getCache(), |
137
|
|
|
$logger ?: HubSpot::getLogger(), |
138
|
|
|
$config |
139
|
|
|
); |
140
|
|
|
|
141
|
|
|
return $builder->build(); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/******************************************* |
146
|
|
|
* REMOVE |
147
|
|
|
*******************************************/ |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string $identifier |
151
|
|
|
* @param array $payload |
152
|
|
|
* @param ConnectionInterface|null $connection |
153
|
|
|
* @param CacheInterface|null $cache |
154
|
|
|
* @param LoggerInterface|null $logger |
155
|
|
|
* @param array $config |
156
|
|
|
* @return ResponseInterface |
157
|
|
|
*/ |
158
|
|
|
public static function remove( |
159
|
|
|
string $identifier, |
160
|
|
|
array $payload, |
161
|
|
|
ConnectionInterface $connection = null, |
162
|
|
|
CacheInterface $cache = null, |
163
|
|
|
LoggerInterface $logger = null, |
164
|
|
|
array $config = [] |
165
|
|
|
): ResponseInterface { |
166
|
|
|
return static::removeRelay( |
167
|
|
|
$identifier, |
168
|
|
|
$payload, |
169
|
|
|
$connection, |
170
|
|
|
$cache, |
171
|
|
|
$logger, |
172
|
|
|
$config |
173
|
|
|
)(); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param string $identifier |
178
|
|
|
* @param array $payload |
179
|
|
|
* @param ConnectionInterface|null $connection |
180
|
|
|
* @param CacheInterface|null $cache |
181
|
|
|
* @param LoggerInterface|null $logger |
182
|
|
|
* @param array $config |
183
|
|
|
* @return callable |
184
|
|
|
*/ |
185
|
|
|
public static function removeRelay( |
186
|
|
|
string $identifier, |
187
|
|
|
array $payload, |
188
|
|
|
ConnectionInterface $connection = null, |
189
|
|
|
CacheInterface $cache = null, |
190
|
|
|
LoggerInterface $logger = null, |
191
|
|
|
array $config = [] |
192
|
|
|
): callable { |
193
|
|
|
/** @var RelayBuilderInterface $builder */ |
194
|
|
|
$builder = new Remove( |
195
|
|
|
$identifier, |
196
|
|
|
$payload, |
197
|
|
|
$connection ?: HubSpot::getConnection(), |
198
|
|
|
$cache ?: HubSpot::getCache(), |
199
|
|
|
$logger ?: HubSpot::getLogger(), |
200
|
|
|
$config |
201
|
|
|
); |
202
|
|
|
|
203
|
|
|
return $builder->build(); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|