1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: hborras |
5
|
|
|
* Date: 3/04/16 |
6
|
|
|
* Time: 11:59. |
7
|
|
|
*/ |
8
|
|
|
namespace Hborras\TwitterAdsSDK\TwitterAds\Campaign; |
9
|
|
|
|
10
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Analytics; |
11
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Creative\PromotedTweet; |
12
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Cursor; |
13
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Fields\LineItemFields; |
14
|
|
|
use Hborras\TwitterAdsSDK\TwitterAdsException; |
15
|
|
|
|
16
|
|
|
class LineItem extends Analytics |
17
|
|
|
{ |
18
|
|
|
const RESOURCE_COLLECTION = 'accounts/{account_id}/line_items'; |
19
|
|
|
const RESOURCE = 'accounts/{account_id}/line_items/{id}'; |
20
|
|
|
|
21
|
|
|
const ENTITY = "LINE_ITEM"; |
22
|
|
|
|
23
|
|
|
/** Read Only */ |
24
|
|
|
protected $id; |
25
|
|
|
protected $created_at; |
26
|
|
|
protected $updated_at; |
27
|
|
|
protected $deleted; |
28
|
|
|
|
29
|
|
|
protected $properties = [ |
30
|
|
|
LineItemFields::CAMPAIGN_ID, |
31
|
|
|
LineItemFields::BID_AMOUNT_LOCAL_MICRO, |
32
|
|
|
LineItemFields::NAME, |
33
|
|
|
LineItemFields::BID_TYPE, |
34
|
|
|
LineItemFields::AUTOMATICALLY_SELECT_BID, |
35
|
|
|
LineItemFields::PRODUCT_TYPE, |
36
|
|
|
LineItemFields::PLACEMENTS, |
37
|
|
|
LineItemFields::OBJECTIVE, |
38
|
|
|
LineItemFields::PAUSED, |
39
|
|
|
LineItemFields::INCLUDE_SENTIMENT, |
40
|
|
|
LineItemFields::TOTAL_BUDGET_AMOUNT_LOCAL_MICRO, |
41
|
|
|
LineItemFields::START_TIME, |
42
|
|
|
LineItemFields::END_TIME, |
43
|
|
|
LineItemFields::PRIMARY_WEB_EVENT_TAG, |
44
|
|
|
LineItemFields::OPTIMIZATION, |
45
|
|
|
LineItemFields::BID_UNIT, |
46
|
|
|
LineItemFields::CHARGE_BY, |
47
|
|
|
LineItemFields::ADVERTISER_DOMAIN, |
48
|
|
|
LineItemFields::ADVERTISER_USER_ID |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
/** Writable */ |
52
|
|
|
protected $campaign_id; |
53
|
|
|
protected $bid_amount_local_micro; |
54
|
|
|
protected $name; |
55
|
|
|
protected $bid_type; |
56
|
|
|
protected $automatically_select_bid; |
57
|
|
|
protected $product_type; |
58
|
|
|
protected $placements; |
59
|
|
|
protected $objective; |
60
|
|
|
protected $paused; |
61
|
|
|
protected $include_sentiment; |
62
|
|
|
protected $total_budget_amount_local_micro; |
63
|
|
|
protected $start_time; |
64
|
|
|
protected $end_time; |
65
|
|
|
protected $primary_web_event_tag; |
66
|
|
|
protected $optimization; |
67
|
|
|
protected $bid_unit; |
68
|
|
|
protected $charge_by; |
69
|
|
|
protected $advertiser_domain; |
70
|
|
|
protected $tracking_tags; |
71
|
|
|
protected $advertiser_user_id; |
72
|
|
|
|
73
|
|
|
public function getPromotedTweets($params = []) |
74
|
|
|
{ |
75
|
|
|
$params[LineItemFields::LINE_ITEM_IDS] = $this->getId(); |
76
|
|
|
$promotedTweetClass = new PromotedTweet(); |
77
|
|
|
return $promotedTweetClass->loadResource('', $params); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Returns a collection of targeting criteria available to the |
82
|
|
|
* current line item. |
83
|
|
|
* |
84
|
|
|
* @param string $id |
85
|
|
|
* @param array $params |
86
|
|
|
* |
87
|
|
|
* @return Cursor | Resource |
88
|
|
|
* |
89
|
|
|
* @throws TwitterAdsException |
90
|
|
|
*/ |
91
|
|
|
public function getTargetingCriteria($id = '', $params = []) |
92
|
|
|
{ |
93
|
|
|
$targetingCriteria = new TargetingCriteria(); |
94
|
|
|
|
95
|
|
|
$this->validateLoaded(); |
96
|
|
|
if ($id == '') { |
97
|
|
|
$cursor = $targetingCriteria->line_item_all($this->getId(), $params); |
98
|
|
|
} else { |
99
|
|
|
$cursor = $targetingCriteria->load($id, $params); |
|
|
|
|
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return $cursor; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return mixed |
107
|
|
|
*/ |
108
|
|
|
public function getId() |
109
|
|
|
{ |
110
|
|
|
return $this->id; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return mixed |
115
|
|
|
*/ |
116
|
|
|
public function getCreatedAt() |
117
|
|
|
{ |
118
|
|
|
return $this->created_at; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return mixed |
123
|
|
|
*/ |
124
|
|
|
public function getUpdatedAt() |
125
|
|
|
{ |
126
|
|
|
return $this->updated_at; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return mixed |
131
|
|
|
*/ |
132
|
|
|
public function getDeleted() |
133
|
|
|
{ |
134
|
|
|
return $this->deleted; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return array |
139
|
|
|
*/ |
140
|
|
|
public function getProperties() |
141
|
|
|
{ |
142
|
|
|
return $this->properties; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param array $properties |
147
|
|
|
*/ |
148
|
|
|
public function setProperties($properties) |
149
|
|
|
{ |
150
|
|
|
$this->properties = $properties; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return mixed |
155
|
|
|
*/ |
156
|
|
|
public function getCampaignId() |
157
|
|
|
{ |
158
|
|
|
return $this->campaign_id; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param mixed $campaign_id |
163
|
|
|
*/ |
164
|
|
|
public function setCampaignId($campaign_id) |
165
|
|
|
{ |
166
|
|
|
$this->campaign_id = $campaign_id; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return mixed |
171
|
|
|
*/ |
172
|
|
|
public function getBidAmountLocalMicro() |
173
|
|
|
{ |
174
|
|
|
return $this->bid_amount_local_micro; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param mixed $bid_amount_local_micro |
179
|
|
|
*/ |
180
|
|
|
public function setBidAmountLocalMicro($bid_amount_local_micro) |
181
|
|
|
{ |
182
|
|
|
$this->bid_amount_local_micro = $bid_amount_local_micro; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return mixed |
187
|
|
|
*/ |
188
|
|
|
public function getName() |
189
|
|
|
{ |
190
|
|
|
return $this->name; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param mixed $name |
195
|
|
|
*/ |
196
|
|
|
public function setName($name) |
197
|
|
|
{ |
198
|
|
|
$this->name = $name; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return mixed |
203
|
|
|
*/ |
204
|
|
|
public function getBidType() |
205
|
|
|
{ |
206
|
|
|
return $this->bid_type; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param mixed $bid_type |
211
|
|
|
*/ |
212
|
|
|
public function setBidType($bid_type) |
213
|
|
|
{ |
214
|
|
|
$this->bid_type = $bid_type; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return mixed |
219
|
|
|
*/ |
220
|
|
|
public function getAutomaticallySelectdBid() |
221
|
|
|
{ |
222
|
|
|
return $this->automatically_select_bid; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @param mixed $automatically_select_bid |
227
|
|
|
*/ |
228
|
|
|
public function setAutomaticallySelectBid($automatically_select_bid) |
229
|
|
|
{ |
230
|
|
|
$this->automatically_select_bid = $automatically_select_bid; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return mixed |
235
|
|
|
*/ |
236
|
|
|
public function getProductType() |
237
|
|
|
{ |
238
|
|
|
return $this->product_type; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @param mixed $product_type |
243
|
|
|
*/ |
244
|
|
|
public function setProductType($product_type) |
245
|
|
|
{ |
246
|
|
|
$this->product_type = $product_type; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return mixed |
251
|
|
|
*/ |
252
|
|
|
public function getPlacements() |
253
|
|
|
{ |
254
|
|
|
return $this->placements; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @param mixed $placements |
259
|
|
|
*/ |
260
|
|
|
public function setPlacements($placements) |
261
|
|
|
{ |
262
|
|
|
$this->placements = $placements; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @return mixed |
267
|
|
|
*/ |
268
|
|
|
public function getObjective() |
269
|
|
|
{ |
270
|
|
|
return $this->objective; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @param mixed $objective |
275
|
|
|
*/ |
276
|
|
|
public function setObjective($objective) |
277
|
|
|
{ |
278
|
|
|
$this->objective = $objective; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* @return mixed |
283
|
|
|
*/ |
284
|
|
|
public function getPaused() |
285
|
|
|
{ |
286
|
|
|
return $this->paused; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @param mixed $paused |
291
|
|
|
*/ |
292
|
|
|
public function setPaused($paused) |
293
|
|
|
{ |
294
|
|
|
$this->paused = $paused; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @return mixed |
299
|
|
|
*/ |
300
|
|
|
public function getIncludeSentiment() |
301
|
|
|
{ |
302
|
|
|
return $this->include_sentiment; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* @param mixed $include_sentiment |
307
|
|
|
*/ |
308
|
|
|
public function setIncludeSentiment($include_sentiment) |
309
|
|
|
{ |
310
|
|
|
$this->include_sentiment = $include_sentiment; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* @return mixed |
315
|
|
|
*/ |
316
|
|
|
public function getTotalBudgetAmountLocalMicro() |
317
|
|
|
{ |
318
|
|
|
return $this->total_budget_amount_local_micro; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* @param mixed $total_budget_amount_local_micro |
323
|
|
|
*/ |
324
|
|
|
public function setTotalBudgetAmountLocalMicro($total_budget_amount_local_micro) |
325
|
|
|
{ |
326
|
|
|
$this->total_budget_amount_local_micro = $total_budget_amount_local_micro; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* @return mixed |
331
|
|
|
*/ |
332
|
|
|
public function getStartTime() |
333
|
|
|
{ |
334
|
|
|
return $this->start_time; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* @param mixed $start_time |
339
|
|
|
*/ |
340
|
|
|
public function setStartTime($start_time) |
341
|
|
|
{ |
342
|
|
|
$this->start_time = $start_time; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* @return mixed |
347
|
|
|
*/ |
348
|
|
|
public function getEndTime() |
349
|
|
|
{ |
350
|
|
|
return $this->end_time; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* @param mixed $end_time |
355
|
|
|
*/ |
356
|
|
|
public function setEndTime($end_time) |
357
|
|
|
{ |
358
|
|
|
$this->end_time = $end_time; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @return mixed |
363
|
|
|
*/ |
364
|
|
|
public function getPrimaryWebEventTag() |
365
|
|
|
{ |
366
|
|
|
return $this->primary_web_event_tag; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* @param mixed $primary_web_event_tag |
371
|
|
|
*/ |
372
|
|
|
public function setPrimaryWebEventTag($primary_web_event_tag) |
373
|
|
|
{ |
374
|
|
|
$this->primary_web_event_tag = $primary_web_event_tag; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* @return mixed |
379
|
|
|
*/ |
380
|
|
|
public function getOptimization() |
381
|
|
|
{ |
382
|
|
|
return $this->optimization; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* @param mixed $optimization |
387
|
|
|
*/ |
388
|
|
|
public function setOptimization($optimization) |
389
|
|
|
{ |
390
|
|
|
$this->optimization = $optimization; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* @return mixed |
395
|
|
|
*/ |
396
|
|
|
public function getBidUnit() |
397
|
|
|
{ |
398
|
|
|
return $this->bid_unit; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* @param mixed $bid_unit |
403
|
|
|
*/ |
404
|
|
|
public function setBidUnit($bid_unit) |
405
|
|
|
{ |
406
|
|
|
$this->bid_unit = $bid_unit; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* @return mixed |
411
|
|
|
*/ |
412
|
|
|
public function getChargeBy() |
413
|
|
|
{ |
414
|
|
|
return $this->charge_by; |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* @param mixed $charge_by |
419
|
|
|
*/ |
420
|
|
|
public function setChargeBy($charge_by) |
421
|
|
|
{ |
422
|
|
|
$this->charge_by = $charge_by; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* @return mixed |
427
|
|
|
*/ |
428
|
|
|
public function getAdvertiserDomain() |
429
|
|
|
{ |
430
|
|
|
return $this->advertiser_domain; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* @param mixed $advertiser_domain |
435
|
|
|
*/ |
436
|
|
|
public function setAdvertiserDomain($advertiser_domain) |
437
|
|
|
{ |
438
|
|
|
$this->advertiser_domain = $advertiser_domain; |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* @return mixed |
443
|
|
|
*/ |
444
|
|
|
public function getTrackingTags() |
445
|
|
|
{ |
446
|
|
|
return $this->tracking_tags; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* @param mixed $tracking_tags |
451
|
|
|
*/ |
452
|
|
|
public function setTrackingTags($tracking_tags) |
453
|
|
|
{ |
454
|
|
|
$this->tracking_tags = $tracking_tags; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* @return mixed |
459
|
|
|
*/ |
460
|
|
|
public function getAdvertiserUserId() |
461
|
|
|
{ |
462
|
|
|
return $this->advertiser_user_id; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* @param mixed $advertiser_user_id |
467
|
|
|
*/ |
468
|
|
|
public function setAdvertiserUserId($advertiser_user_id) |
469
|
|
|
{ |
470
|
|
|
$this->advertiser_user_id = $advertiser_user_id; |
471
|
|
|
} |
472
|
|
|
} |
473
|
|
|
|