|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience; |
|
4
|
|
|
|
|
5
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds; |
|
6
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Resource; |
|
7
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience\Exception\InvalidOperation; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Represents a Tailored Audience Change object |
|
11
|
|
|
* Supports: GET, POST |
|
12
|
|
|
* |
|
13
|
|
|
* @since 2016-06-27 |
|
14
|
|
|
*/ |
|
15
|
|
|
final class TailoredAudienceChanges extends Resource |
|
16
|
|
|
{ |
|
17
|
|
|
const RESOURCE_COLLECTION = 'accounts/{account_id}/tailored_audiences_changes'; |
|
18
|
|
|
const RESOURCE = 'accounts/{account_id}/tailored_audiences_changes/{id}'; |
|
19
|
|
|
|
|
20
|
|
|
const ADD = 'ADD'; |
|
21
|
|
|
const REMOVE = 'REMOVE'; |
|
22
|
|
|
const REPLACE = 'REPLACE'; |
|
23
|
|
|
|
|
24
|
|
|
protected $input_file_path; |
|
25
|
|
|
protected $tailored_audience_id; |
|
26
|
|
|
protected $id; |
|
27
|
|
|
protected $operation; |
|
28
|
|
|
|
|
29
|
|
|
protected $properties = [ |
|
30
|
|
|
'tailored_audience_id', |
|
31
|
|
|
'input_file_path', |
|
32
|
|
|
'operation', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
public function getId() |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->id; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getInputFilePath() |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->input_file_path; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function setInputFilePath($path) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->input_file_path = $path; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getTailoredAudienceId() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->tailored_audience_id; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function setTailoredAudienceId($id) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->tailored_audience_id = $id; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getOperation() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->assureValidOperation($this->operation); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function setOperation($op) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->operation = $this->assureValidOperation($op); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return array |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getProperties() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->properties; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
private function getOperations() |
|
79
|
|
|
{ |
|
80
|
|
|
return [ |
|
81
|
|
|
self::ADD, |
|
82
|
|
|
self::REMOVE, |
|
83
|
|
|
self::REPLACE, |
|
84
|
|
|
]; |
|
85
|
|
|
} |
|
86
|
|
|
private function assureValidOperation($op) |
|
87
|
|
|
{ |
|
88
|
|
|
foreach ($this->getOperations() as $allowedOp) { |
|
89
|
|
|
if ($op === $allowedOp) { |
|
90
|
|
|
return $op; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
throw new InvalidOperation( |
|
95
|
|
|
sprintf('"%s" is not a valid operation for %s', $op, TailoredAudience::class) |
|
96
|
|
|
); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|