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
|
|
|
private function getOperations() |
71
|
|
|
{ |
72
|
|
|
return [ |
73
|
|
|
self::ADD, |
74
|
|
|
self::REMOVE, |
75
|
|
|
self::REPLACE, |
76
|
|
|
]; |
77
|
|
|
} |
78
|
|
|
private function assureValidOperation($op) |
79
|
|
|
{ |
80
|
|
|
foreach ($this->getOperations() as $allowedOp) { |
81
|
|
|
if ($op === $allowedOp) { |
82
|
|
|
return $op; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
throw new InvalidOperation( |
87
|
|
|
sprintf('"%s" is not a valid operation for %s', $op, TailoredAudience::class) |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|