1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Audiens\AdForm\Entity; |
4
|
|
|
|
5
|
|
|
use Audiens\AdForm\Enum\SegmentStatus; |
6
|
|
|
use DateTime; |
7
|
|
|
use JsonSerializable; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Segment |
11
|
|
|
*/ |
12
|
|
|
class Segment implements JsonSerializable |
13
|
|
|
{ |
14
|
|
|
/** @var int|null */ |
15
|
|
|
protected $id; |
16
|
|
|
|
17
|
|
|
/** @var int|null */ |
18
|
|
|
protected $dataProviderId; |
19
|
|
|
|
20
|
|
|
/** @var SegmentStatus|null */ |
21
|
|
|
protected $status; |
22
|
|
|
|
23
|
|
|
/** @var int|null */ |
24
|
|
|
protected $categoryId; |
25
|
|
|
|
26
|
|
|
/** @var string|null */ |
27
|
|
|
protected $refId; |
28
|
|
|
|
29
|
|
|
/** @var float|null */ |
30
|
|
|
protected $fee; |
31
|
|
|
|
32
|
|
|
/** @var int|null */ |
33
|
|
|
protected $ttl; |
34
|
|
|
|
35
|
|
|
/** @var string|null */ |
36
|
|
|
protected $name; |
37
|
|
|
|
38
|
|
|
/** @var string|null */ |
39
|
|
|
protected $formula; |
40
|
|
|
|
41
|
|
|
/** @var string|null */ |
42
|
|
|
protected $extractionRule; |
43
|
|
|
|
44
|
|
|
/** @var bool|null */ |
45
|
|
|
protected $audience; |
46
|
|
|
|
47
|
|
|
/** @var array|null */ |
48
|
|
|
protected $audienceBySources; |
49
|
|
|
|
50
|
|
|
/** @var array|null */ |
51
|
|
|
protected $audienceByUserIdentityType; |
52
|
|
|
|
53
|
|
|
/** @var bool|null */ |
54
|
|
|
protected $isExtended; |
55
|
|
|
|
56
|
|
|
/** @var int|null */ |
57
|
|
|
protected $extensionThreshold; |
58
|
|
|
|
59
|
|
|
/** @var int|null */ |
60
|
|
|
protected $frequency; |
61
|
|
|
|
62
|
|
|
/** @var bool|null */ |
63
|
|
|
protected $isCrossDevice; |
64
|
|
|
|
65
|
|
|
/** @var bool|null */ |
66
|
|
|
protected $hasDataUsagePermissions; |
67
|
|
|
|
68
|
|
|
/** @var DateTime|null */ |
69
|
|
|
protected $updatedAt; |
70
|
|
|
|
71
|
|
|
/** @var DateTime|null */ |
72
|
|
|
protected $createdAt; |
73
|
|
|
|
74
|
|
|
/** @var int[] */ |
75
|
|
|
protected $unifiedTaxonomyLabelIds; |
76
|
|
|
|
77
|
|
|
public function __construct() |
78
|
|
|
{ |
79
|
|
|
$this->unifiedTaxonomyLabelIds = []; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getUpdatedAt(): ?DateTime |
83
|
|
|
{ |
84
|
|
|
return $this->updatedAt; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getCreatedAt(): ?DateTime |
88
|
|
|
{ |
89
|
|
|
return $this->createdAt; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getId(): ?int |
93
|
|
|
{ |
94
|
|
|
return $this->id; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function setId(int $id): self |
98
|
|
|
{ |
99
|
|
|
$this->id = $id; |
100
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getDataProviderId(): ?int |
105
|
|
|
{ |
106
|
|
|
return $this->dataProviderId; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function setDataProviderId(int $dataProviderId): self |
110
|
|
|
{ |
111
|
|
|
$this->dataProviderId = $dataProviderId; |
112
|
|
|
|
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
public function getStatus(): ?SegmentStatus |
117
|
|
|
{ |
118
|
|
|
return $this->status; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function setStatus(SegmentStatus $status): self |
122
|
|
|
{ |
123
|
|
|
$this->status = $status; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function getCategoryId(): ?int |
129
|
|
|
{ |
130
|
|
|
return $this->categoryId; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function setCategoryId(int $categoryId): self |
134
|
|
|
{ |
135
|
|
|
$this->categoryId = $categoryId; |
136
|
|
|
|
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getRefId(): ?string |
141
|
|
|
{ |
142
|
|
|
return $this->refId; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function setRefId(string $refId): self |
146
|
|
|
{ |
147
|
|
|
$this->refId = $refId; |
148
|
|
|
|
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function getFee(): ?float |
153
|
|
|
{ |
154
|
|
|
return $this->fee; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function setFee(float $fee): self |
158
|
|
|
{ |
159
|
|
|
$this->fee = $fee; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function getTtl(): ?int |
165
|
|
|
{ |
166
|
|
|
return $this->ttl; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function setTtl(int $ttl): self |
170
|
|
|
{ |
171
|
|
|
$this->ttl = $ttl; |
172
|
|
|
|
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function getName(): ?string |
177
|
|
|
{ |
178
|
|
|
return $this->name; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function setName(string $name): self |
182
|
|
|
{ |
183
|
|
|
$this->name = $name; |
184
|
|
|
|
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function getFormula(): ?string |
189
|
|
|
{ |
190
|
|
|
return $this->formula; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function setFormula(string $formula): self |
194
|
|
|
{ |
195
|
|
|
$this->formula = $formula; |
196
|
|
|
|
197
|
|
|
return $this; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function getExtractionRule(): ?string |
201
|
|
|
{ |
202
|
|
|
return $this->extractionRule; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
public function setExtractionRule(string $extractionRule): self |
206
|
|
|
{ |
207
|
|
|
$this->extractionRule = $extractionRule; |
208
|
|
|
|
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function getAudience(): ?bool |
213
|
|
|
{ |
214
|
|
|
return $this->audience; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function setAudience(bool $audience): self |
218
|
|
|
{ |
219
|
|
|
$this->audience = $audience; |
220
|
|
|
|
221
|
|
|
return $this; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function getAudienceBySources(): ?array |
225
|
|
|
{ |
226
|
|
|
return $this->audienceBySources; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
public function setAudienceBySources(array $audienceBySources): self |
230
|
|
|
{ |
231
|
|
|
$this->audienceBySources = $audienceBySources; |
232
|
|
|
|
233
|
|
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
public function getAudienceByUserIdentityType(): ?array |
237
|
|
|
{ |
238
|
|
|
return $this->audienceByUserIdentityType; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function setAudienceByUserIdentityType(array $audienceByUserIdentityType): self |
242
|
|
|
{ |
243
|
|
|
$this->audienceByUserIdentityType = $audienceByUserIdentityType; |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
public function getIsExtended(): ?bool |
249
|
|
|
{ |
250
|
|
|
return $this->isExtended; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function setIsExtended(bool $isExtended): self |
254
|
|
|
{ |
255
|
|
|
$this->isExtended = $isExtended; |
256
|
|
|
|
257
|
|
|
return $this; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
public function getExtensionThreshold(): ?int |
261
|
|
|
{ |
262
|
|
|
return $this->extensionThreshold; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
public function setExtensionThreshold(int $extensionThreshold): self |
266
|
|
|
{ |
267
|
|
|
$this->extensionThreshold = $extensionThreshold; |
268
|
|
|
|
269
|
|
|
return $this; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public function getFrequency(): ?int |
273
|
|
|
{ |
274
|
|
|
return $this->frequency; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function setFrequency(int $frequency): self |
278
|
|
|
{ |
279
|
|
|
$this->frequency = $frequency; |
280
|
|
|
|
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public function getIsCrossDevice(): ?bool |
285
|
|
|
{ |
286
|
|
|
return $this->isCrossDevice; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function setIsCrossDevice(bool $isCrossDevice): self |
290
|
|
|
{ |
291
|
|
|
$this->isCrossDevice = $isCrossDevice; |
292
|
|
|
|
293
|
|
|
return $this; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function getHasDataUsagePermissions(): ?bool |
297
|
|
|
{ |
298
|
|
|
return $this->hasDataUsagePermissions; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
public function setHasDataUsagePermissions(bool $hasDataUsagePermissions): self |
302
|
|
|
{ |
303
|
|
|
$this->hasDataUsagePermissions = $hasDataUsagePermissions; |
304
|
|
|
|
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* @return int[] |
310
|
|
|
*/ |
311
|
|
|
public function getUnifiedTaxonomyLabelIds(): array |
312
|
|
|
{ |
313
|
|
|
return $this->unifiedTaxonomyLabelIds; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @param int[] $unifiedTaxonomyLabelIds |
318
|
|
|
* |
319
|
|
|
* @return Segment |
320
|
|
|
*/ |
321
|
|
|
public function setUnifiedTaxonomyLabelIds(array $unifiedTaxonomyLabelIds): self |
322
|
|
|
{ |
323
|
|
|
$this->unifiedTaxonomyLabelIds = $unifiedTaxonomyLabelIds; |
324
|
|
|
|
325
|
|
|
return $this; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
public function addUnifiedTaxonomyLabelId(int $unifiedTaxonomyLabelId): self |
329
|
|
|
{ |
330
|
|
|
if (!\in_array($unifiedTaxonomyLabelId, $this->unifiedTaxonomyLabelIds, true)) { |
331
|
|
|
$this->unifiedTaxonomyLabelIds[] = $unifiedTaxonomyLabelId; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
return $this; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
public function jsonSerialize() |
338
|
|
|
{ |
339
|
|
|
$json = new \stdClass(); |
340
|
|
|
|
341
|
|
|
// might not be set for a new segment |
342
|
|
|
if ($this->id !== null) { |
343
|
|
|
$json->id = $this->id; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
$json->dataProviderId = (int)$this->dataProviderId; |
347
|
|
|
|
348
|
|
|
if ($this->status !== null) { |
349
|
|
|
$json->status = $this->status->getValue(); |
350
|
|
|
} else { |
351
|
|
|
$json->status = null; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
$json->categoryId = (int)$this->categoryId; |
355
|
|
|
$json->refId = $this->refId; |
356
|
|
|
$json->fee = (float)$this->fee; |
357
|
|
|
$json->ttl = (int)$this->ttl; |
358
|
|
|
$json->name = $this->name; |
359
|
|
|
|
360
|
|
|
// might not be set in JSON |
361
|
|
|
if ($this->formula !== null) { |
362
|
|
|
$json->formula = $this->formula; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
// might not be set in JSON |
366
|
|
|
if ($this->extractionRule !== null) { |
367
|
|
|
$json->extractionRule = $this->extractionRule; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
$json->audience = (bool) $this->audience; |
371
|
|
|
$json->audienceBySources = $this->audienceBySources; |
372
|
|
|
$json->audienceByUserIdentityType = $this->audienceByUserIdentityType; |
373
|
|
|
$json->isExtended = (bool) $this->isExtended; |
374
|
|
|
|
375
|
|
|
// might not be set in JSON |
376
|
|
|
if ($this->extensionThreshold !== null) { |
377
|
|
|
$json->extensionThreshold = (bool)$this->extensionThreshold; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
$json->frequency = (int) $this->frequency; |
381
|
|
|
$json->isCrossDevice = (bool) $this->isCrossDevice; |
382
|
|
|
$json->hasDataUsagePermissions = (bool) $this->hasDataUsagePermissions; |
383
|
|
|
|
384
|
|
|
// might not be set for a new segment |
385
|
|
|
if ($this->createdAt !== null) { |
386
|
|
|
$json->createdAt = $this->createdAt->format('c'); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
// might not be set for a new segment |
390
|
|
|
if ($this->updatedAt !== null) { |
391
|
|
|
$json->updatedAt = $this->updatedAt->format('c'); |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
if (!empty($this->unifiedTaxonomyLabelIds)) { |
395
|
|
|
$json->unifiedTaxonomyLabelsIds = $this->unifiedTaxonomyLabelIds; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
return $json; |
399
|
|
|
} |
400
|
|
|
} |
401
|
|
|
|