1 | <?php |
||
16 | final class TailoredAudience extends Resource |
||
17 | { |
||
18 | const RESOURCE_COLLECTION = 'accounts/{account_id}/tailored_audiences'; |
||
19 | const RESOURCE = 'accounts/{account_id}/tailored_audiences/{id}'; |
||
20 | |||
21 | const LIST_TYPE_EMAIL = 'EMAIL'; |
||
22 | const LIST_TYPE_DEVICE_ID = 'DEVICE_ID'; |
||
23 | const LIST_TYPE_TWITTER_ID = 'TWITTER_ID'; |
||
24 | const LIST_TYPE_HANDLE = 'HANDLE'; |
||
25 | const LIST_TYPE_PHONE_NUMBER = 'PHONE_NUMBER'; |
||
26 | |||
27 | /** Writable */ |
||
28 | protected $list_type; |
||
29 | protected $name; |
||
30 | |||
31 | protected $properties = [ |
||
32 | 'name', |
||
33 | 'list_type', |
||
34 | ]; |
||
35 | |||
36 | /** Read Only */ |
||
37 | protected $deleted; |
||
38 | protected $targetable; |
||
39 | protected $audience_size; |
||
40 | protected $id; |
||
41 | protected $updated_at; |
||
42 | protected $created_at; |
||
43 | protected $audience_type; |
||
44 | protected $reasons_not_targetable; |
||
45 | protected $targetable_types; |
||
46 | protected $partner_source; |
||
47 | protected $metadata; |
||
48 | |||
49 | /** |
||
50 | * Uploads and creates a new tailored audience |
||
51 | * |
||
52 | * @param $filePath |
||
53 | * @param $name |
||
54 | * @param $listType |
||
55 | * @return Resource |
||
56 | * @throws TwitterAds\Errors\BadRequest |
||
57 | * @throws TwitterAds\Errors\Forbidden |
||
58 | * @throws TwitterAds\Errors\NotAuthorized |
||
59 | * @throws TwitterAds\Errors\NotFound |
||
60 | * @throws TwitterAds\Errors\RateLimit |
||
61 | * @throws TwitterAds\Errors\ServerError |
||
62 | * @throws TwitterAds\Errors\ServiceUnavailable |
||
63 | * @throws TwitterAdsException |
||
64 | */ |
||
65 | public function create($filePath, $name, $listType) |
||
76 | |||
77 | /** |
||
78 | * Create a simple tailored audience object |
||
79 | * |
||
80 | * @param $name |
||
81 | * @param $listType |
||
82 | * @return $this |
||
83 | * @throws TwitterAds\Errors\BadRequest |
||
84 | * @throws TwitterAds\Errors\Forbidden |
||
85 | * @throws TwitterAds\Errors\NotAuthorized |
||
86 | * @throws TwitterAds\Errors\NotFound |
||
87 | * @throws TwitterAds\Errors\RateLimit |
||
88 | * @throws TwitterAds\Errors\ServerError |
||
89 | * @throws TwitterAds\Errors\ServiceUnavailable |
||
90 | * @throws TwitterAdsException |
||
91 | */ |
||
92 | public function createAudience($name, $listType) |
||
100 | |||
101 | /** |
||
102 | * Returns the TailoredAudienceChange with the status |
||
103 | * @return null |
||
104 | */ |
||
105 | public function status() |
||
110 | |||
111 | /** |
||
112 | * @return boolean |
||
113 | */ |
||
114 | public function isDeleted() |
||
118 | |||
119 | /** |
||
120 | * @return boolean |
||
121 | */ |
||
122 | public function isTargetable() |
||
126 | |||
127 | /** |
||
128 | * @return integer |
||
129 | */ |
||
130 | public function getAudienceSize() |
||
134 | |||
135 | /** |
||
136 | * @return mixed |
||
137 | */ |
||
138 | public function getId() |
||
142 | |||
143 | /** |
||
144 | * @return DateTimeImmutable |
||
145 | */ |
||
146 | public function getCreatedAt() |
||
150 | |||
151 | /** |
||
152 | * @return DateTimeImmutable |
||
153 | */ |
||
154 | public function getUpdatedAt() |
||
158 | |||
159 | /** |
||
160 | * @return mixed |
||
161 | */ |
||
162 | public function getListType() |
||
166 | |||
167 | /** |
||
168 | * @param string $type |
||
169 | */ |
||
170 | public function setListType($type) |
||
174 | |||
175 | /** |
||
176 | * @return string |
||
177 | */ |
||
178 | public function getAudienceType() |
||
182 | |||
183 | /** |
||
184 | * @return array |
||
185 | */ |
||
186 | public function getReasonsNotTargetable() |
||
190 | |||
191 | /** |
||
192 | * @return array |
||
193 | */ |
||
194 | public function getTargetableTypes() |
||
198 | |||
199 | /** |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getName() |
||
206 | |||
207 | /** |
||
208 | * @param string $name |
||
209 | */ |
||
210 | public function setName($name) |
||
214 | |||
215 | /** |
||
216 | * @return string |
||
217 | */ |
||
218 | public function getPartnerSource() |
||
222 | |||
223 | /** |
||
224 | * @return array |
||
225 | */ |
||
226 | public static function getTypes() |
||
236 | |||
237 | /** |
||
238 | * Asserts that the given type is valid |
||
239 | * |
||
240 | * @param string $type |
||
241 | * @throws InvalidType - if type is invalid or null |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | private function assureValidType($type) |
||
257 | |||
258 | /** |
||
259 | * @return mixed |
||
260 | */ |
||
261 | public function getMetadata() |
||
265 | } |
||
266 |