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\Fields\AnalyticsFields; |
12
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Fields\CampaignFields; |
13
|
|
|
|
14
|
|
|
class Campaign extends Analytics |
15
|
|
|
{ |
16
|
|
|
const RESOURCE_COLLECTION = 'accounts/{account_id}/campaigns'; |
17
|
|
|
const RESOURCE = 'accounts/{account_id}/campaigns/{id}'; |
18
|
|
|
const ENTITY = 'CAMPAIGN'; |
19
|
|
|
|
20
|
|
|
/** Read Only */ |
21
|
|
|
protected $id; |
22
|
|
|
protected $reasons_not_servable; |
23
|
|
|
protected $servable; |
24
|
|
|
protected $created_at; |
25
|
|
|
protected $updated_at; |
26
|
|
|
protected $deleted; |
27
|
|
|
protected $currency; |
28
|
|
|
|
29
|
|
|
protected $properties = [ |
30
|
|
|
CampaignFields::NAME, |
31
|
|
|
CampaignFields::FUNDING_INSTRUMENT_ID, |
32
|
|
|
CampaignFields::START_TIME, |
33
|
|
|
CampaignFields::END_TIME, |
34
|
|
|
CampaignFields::ENTITY_STATUS, |
35
|
|
|
CampaignFields::STANDARD_DELIVERY, |
36
|
|
|
CampaignFields::DAILY_BUDGET_AMOUNT_LOCAL_MICRO, |
37
|
|
|
CampaignFields::TOTAL_BUDGET_AMOUNT_LOCAL_MICRO, |
38
|
|
|
CampaignFields::DURATION_IN_DAYS, |
39
|
|
|
CampaignFields::FREQUENCY_CAP, |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** Writable */ |
43
|
|
|
protected $name; |
44
|
|
|
protected $funding_instrument_id; |
45
|
|
|
protected $start_time; |
46
|
|
|
protected $end_time; |
47
|
|
|
protected $entity_status; |
48
|
|
|
protected $standard_delivery; |
49
|
|
|
protected $daily_budget_amount_local_micro; |
50
|
|
|
protected $total_budget_amount_local_micro; |
51
|
|
|
protected $duration_in_days; |
52
|
|
|
protected $frequency_cap; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param array $params |
56
|
|
|
* @return \Hborras\TwitterAdsSDK\TwitterAds\Cursor|Resource |
57
|
|
|
*/ |
58
|
|
|
public function getLineItems($params = []) |
59
|
|
|
{ |
60
|
|
|
$params[CampaignFields::CAMPAIGN_IDS] = $this->getId(); |
61
|
|
|
$lineItemClass = new LineItem(); |
62
|
|
|
return $lineItemClass->loadResource('', $params); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $metricGroups |
67
|
|
|
* @param array $params |
68
|
|
|
* @param bool $async |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function stats($metricGroups, $params = [], $async = false) |
72
|
|
|
{ |
73
|
|
|
$params[AnalyticsFields::ENTITY] = AnalyticsFields::CAMPAIGN; |
74
|
|
|
return parent::stats($metricGroups, $params, $async); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return mixed |
79
|
|
|
*/ |
80
|
|
|
public function getId() |
81
|
|
|
{ |
82
|
|
|
return $this->id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return mixed |
87
|
|
|
*/ |
88
|
|
|
public function getReasonsNotServable() |
89
|
|
|
{ |
90
|
|
|
return $this->reasons_not_servable; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return mixed |
95
|
|
|
*/ |
96
|
|
|
public function getServable() |
97
|
|
|
{ |
98
|
|
|
return $this->servable; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return \DateTime |
103
|
|
|
*/ |
104
|
|
|
public function getCreatedAt() |
105
|
|
|
{ |
106
|
|
|
return $this->created_at; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return mixed |
111
|
|
|
*/ |
112
|
|
|
public function getUpdatedAt() |
113
|
|
|
{ |
114
|
|
|
return $this->updated_at; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return mixed |
119
|
|
|
*/ |
120
|
|
|
public function getDeleted() |
121
|
|
|
{ |
122
|
|
|
return $this->deleted; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return mixed |
127
|
|
|
*/ |
128
|
|
|
public function getName() |
129
|
|
|
{ |
130
|
|
|
return $this->name; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param mixed $name |
135
|
|
|
*/ |
136
|
|
|
public function setName($name) |
137
|
|
|
{ |
138
|
|
|
$this->name = $name; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return mixed |
143
|
|
|
*/ |
144
|
|
|
public function getFundingInstrumentId() |
145
|
|
|
{ |
146
|
|
|
return $this->funding_instrument_id; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param mixed $funding_instrument_id |
151
|
|
|
*/ |
152
|
|
|
public function setFundingInstrumentId($funding_instrument_id) |
153
|
|
|
{ |
154
|
|
|
$this->funding_instrument_id = $funding_instrument_id; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return mixed |
159
|
|
|
*/ |
160
|
|
|
public function getStartTime() |
161
|
|
|
{ |
162
|
|
|
return $this->start_time; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param mixed $start_time |
167
|
|
|
*/ |
168
|
|
|
public function setStartTime($start_time) |
169
|
|
|
{ |
170
|
|
|
$this->start_time = $start_time; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return mixed |
175
|
|
|
*/ |
176
|
|
|
public function getEndTime() |
177
|
|
|
{ |
178
|
|
|
return $this->end_time; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param mixed $end_time |
183
|
|
|
*/ |
184
|
|
|
public function setEndTime($end_time) |
185
|
|
|
{ |
186
|
|
|
$this->end_time = $end_time; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return mixed |
191
|
|
|
*/ |
192
|
|
|
public function getEntityStatus() |
193
|
|
|
{ |
194
|
|
|
return $this->entity_status; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @param mixed $entityStatus |
199
|
|
|
*/ |
200
|
|
|
public function setEntityStatus($entityStatus) |
201
|
|
|
{ |
202
|
|
|
$this->entity_status = $entityStatus; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @return mixed |
207
|
|
|
*/ |
208
|
|
|
public function getCurrency() |
209
|
|
|
{ |
210
|
|
|
return $this->currency; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @param mixed $currency |
215
|
|
|
*/ |
216
|
|
|
public function setCurrency($currency) |
217
|
|
|
{ |
218
|
|
|
$this->currency = $currency; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @return mixed |
223
|
|
|
*/ |
224
|
|
|
public function getStandardDelivery() |
225
|
|
|
{ |
226
|
|
|
return $this->standard_delivery; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @param mixed $standard_delivery |
231
|
|
|
*/ |
232
|
|
|
public function setStandardDelivery($standard_delivery) |
233
|
|
|
{ |
234
|
|
|
$this->standard_delivery = $standard_delivery; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @return mixed |
239
|
|
|
*/ |
240
|
|
|
public function getDailyBudgetAmountLocalMicro() |
241
|
|
|
{ |
242
|
|
|
return $this->daily_budget_amount_local_micro; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @param mixed $daily_budget_amount_local_micro |
247
|
|
|
*/ |
248
|
|
|
public function setDailyBudgetAmountLocalMicro($daily_budget_amount_local_micro) |
249
|
|
|
{ |
250
|
|
|
$this->daily_budget_amount_local_micro = $daily_budget_amount_local_micro; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @return mixed |
255
|
|
|
*/ |
256
|
|
|
public function getTotalBudgetAmountLocalMicro() |
257
|
|
|
{ |
258
|
|
|
return $this->total_budget_amount_local_micro; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @param mixed $total_budget_amount_local_micro |
263
|
|
|
*/ |
264
|
|
|
public function setTotalBudgetAmountLocalMicro($total_budget_amount_local_micro) |
265
|
|
|
{ |
266
|
|
|
$this->total_budget_amount_local_micro = $total_budget_amount_local_micro; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @return array |
271
|
|
|
*/ |
272
|
|
|
public function getProperties() |
273
|
|
|
{ |
274
|
|
|
return $this->properties; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @param array $properties |
279
|
|
|
*/ |
280
|
|
|
public function setProperties($properties) |
281
|
|
|
{ |
282
|
|
|
$this->properties = $properties; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @return mixed |
287
|
|
|
*/ |
288
|
|
|
public function getDurationInDays() |
289
|
|
|
{ |
290
|
|
|
return $this->duration_in_days; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* @param mixed $duration_in_days |
295
|
|
|
*/ |
296
|
|
|
public function setDurationInDays($duration_in_days) |
297
|
|
|
{ |
298
|
|
|
$this->duration_in_days = $duration_in_days; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* @return mixed |
303
|
|
|
*/ |
304
|
|
|
public function getFrequencyCap() |
305
|
|
|
{ |
306
|
|
|
return $this->frequency_cap; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @param mixed $frequency_cap |
311
|
|
|
*/ |
312
|
|
|
public function setFrequencyCap($frequency_cap) |
313
|
|
|
{ |
314
|
|
|
$this->frequency_cap = $frequency_cap; |
315
|
|
|
} |
316
|
|
|
} |
317
|
|
|
|