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