Completed
Push — master ( 7209c8...b579d6 )
by Hector
04:15
created

LineItem::setEntityStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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