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\Analytics; |
9
|
|
|
|
10
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Analytics; |
11
|
|
|
use Hborras\TwitterAdsSDK\TwitterAds\Fields\JobFields; |
12
|
|
|
|
13
|
|
|
class Job extends Analytics |
14
|
|
|
{ |
15
|
|
|
const RESOURCE_COLLECTION = 'stats/jobs/accounts/{account_id}'; |
16
|
|
|
const RESOURCE = 'stats/jobs/accounts/{account_id}'; |
17
|
|
|
const ENTITY = 'JOBS'; |
18
|
|
|
|
19
|
|
|
/** Read Only */ |
20
|
|
|
protected $id; |
21
|
|
|
protected $start_time; |
22
|
|
|
protected $segmentation_type; |
23
|
|
|
protected $url; |
24
|
|
|
protected $id_str; |
25
|
|
|
protected $entity_ids; |
26
|
|
|
protected $end_time; |
27
|
|
|
protected $placement; |
28
|
|
|
protected $expires_at; |
29
|
|
|
protected $account_id; |
30
|
|
|
protected $status; |
31
|
|
|
protected $granularity; |
32
|
|
|
protected $entity; |
33
|
|
|
protected $created_at; |
34
|
|
|
protected $updated_at; |
35
|
|
|
protected $metric_groups; |
36
|
|
|
|
37
|
|
|
protected $properties = []; |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
public function read($params = []) |
41
|
|
|
{ |
42
|
|
|
$resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE); |
43
|
|
|
$params[JobFields::JOB_IDS] = $this->id; |
44
|
|
|
$response = $this->getTwitterAds()->get($resource, $params); |
45
|
|
|
if(isset($response->getBody()->data[0])){ |
46
|
|
|
return $this->fromResponse($response->getBody()->data[0]); |
47
|
|
|
} else { |
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return mixed |
54
|
|
|
*/ |
55
|
|
|
public function getId() |
56
|
|
|
{ |
57
|
|
|
return $this->id; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return mixed |
62
|
|
|
*/ |
63
|
|
|
public function getStartTime() |
64
|
|
|
{ |
65
|
|
|
return $this->start_time; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function getSegmentationType() |
72
|
|
|
{ |
73
|
|
|
return $this->segmentation_type; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
public function getUrl() |
80
|
|
|
{ |
81
|
|
|
return $this->url; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function getIdStr() |
88
|
|
|
{ |
89
|
|
|
return $this->id_str; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
|
|
public function getEntityIds() |
96
|
|
|
{ |
97
|
|
|
return $this->entity_ids; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function getEndTime() |
104
|
|
|
{ |
105
|
|
|
return $this->end_time; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return mixed |
110
|
|
|
*/ |
111
|
|
|
public function getPlacement() |
112
|
|
|
{ |
113
|
|
|
return $this->placement; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
|
|
public function getExpiresAt() |
120
|
|
|
{ |
121
|
|
|
return $this->expires_at; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return mixed |
126
|
|
|
*/ |
127
|
|
|
public function getAccountId() |
128
|
|
|
{ |
129
|
|
|
return $this->account_id; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return mixed |
134
|
|
|
*/ |
135
|
|
|
public function getStatus() |
136
|
|
|
{ |
137
|
|
|
return $this->status; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return mixed |
142
|
|
|
*/ |
143
|
|
|
public function getGranularity() |
144
|
|
|
{ |
145
|
|
|
return $this->granularity; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return mixed |
150
|
|
|
*/ |
151
|
|
|
public function getEntity() |
152
|
|
|
{ |
153
|
|
|
return $this->entity; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return mixed |
158
|
|
|
*/ |
159
|
|
|
public function getCreatedAt() |
160
|
|
|
{ |
161
|
|
|
return $this->created_at; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return mixed |
166
|
|
|
*/ |
167
|
|
|
public function getUpdatedAt() |
168
|
|
|
{ |
169
|
|
|
return $this->updated_at; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return mixed |
174
|
|
|
*/ |
175
|
|
|
public function getMetricGroups() |
176
|
|
|
{ |
177
|
|
|
return $this->metric_groups; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return array |
182
|
|
|
*/ |
183
|
|
|
public function getProperties() |
184
|
|
|
{ |
185
|
|
|
return $this->properties; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
|
189
|
|
|
} |
190
|
|
|
|