|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Oleg Krivtsov <[email protected]> |
|
4
|
|
|
* @date 07 October 2016 |
|
5
|
|
|
* @copyright (c) 2016, Web Marketing ROI |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace WebMarketingROI\OptimizelyPHP\Resource\v2; |
|
8
|
|
|
|
|
9
|
|
|
use WebMarketingROI\OptimizelyPHP\Exception; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* An Optimizely project page. |
|
13
|
|
|
*/ |
|
14
|
|
|
class Page |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* URL of the Page |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $editUrl; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Name of the Page |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $name; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* ID of the Page's project |
|
30
|
|
|
* @var integer |
|
31
|
|
|
*/ |
|
32
|
|
|
private $projectId; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Code to determine Experiment start |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
private $activationCode; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Page activation type. Can be immediate, manual, polling or callback |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $activationType; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
private $apiName; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Whether the Page has been archived |
|
54
|
|
|
* @var boolean |
|
55
|
|
|
*/ |
|
56
|
|
|
private $archived; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* The category this Page is grouped under. Can be article, cart, category, |
|
60
|
|
|
* checkout, home, landing_page, pricing, product_detail, search_results or other |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
private $category; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Conditions that activate the Page |
|
67
|
|
|
* @var string |
|
68
|
|
|
*/ |
|
69
|
|
|
private $conditions; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Unique string identifier for this page within the project. |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
private $key; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Type of Page. Can be single_url, url_set or global |
|
79
|
|
|
* @var string |
|
80
|
|
|
*/ |
|
81
|
|
|
private $pageType; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Date created |
|
85
|
|
|
* @var string |
|
86
|
|
|
*/ |
|
87
|
|
|
private $created; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* The unique identifier of the Page |
|
91
|
|
|
* @var integer |
|
92
|
|
|
*/ |
|
93
|
|
|
private $id; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Date last modified |
|
97
|
|
|
* @var string |
|
98
|
|
|
*/ |
|
99
|
|
|
private $lastModified; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Constructor. |
|
103
|
|
|
*/ |
|
104
|
7 |
|
public function __construct($options = array()) |
|
105
|
|
|
{ |
|
106
|
7 |
|
foreach ($options as $name=>$value) { |
|
107
|
|
|
switch ($name) { |
|
108
|
6 |
|
case 'edit_url': $this->setEditUrl($value); break; |
|
109
|
6 |
|
case 'name': $this->setName($value); break; |
|
110
|
6 |
|
case 'project_id': $this->setProjectId($value); break; |
|
111
|
6 |
|
case 'activation_code': $this->setActivationCode($value); break; |
|
112
|
6 |
|
case 'activation_type': $this->setActivationType($value); break; |
|
113
|
6 |
|
case 'api_name': $this->setApiName($value); break; |
|
114
|
6 |
|
case 'archived': $this->setArchived($value); break; |
|
115
|
6 |
|
case 'category': $this->setCategory($value); break; |
|
116
|
6 |
|
case 'conditions': $this->setConditions($value); break; |
|
117
|
6 |
|
case 'key': $this->setKey($value); break; |
|
118
|
6 |
|
case 'page_type': $this->setPageType($value); break; |
|
119
|
6 |
|
case 'created': $this->setCreated($value); break; |
|
120
|
6 |
|
case 'id': $this->setId($value); break; |
|
121
|
6 |
|
case 'last_modified': $this->setLastModified($value); break; |
|
122
|
|
|
default: |
|
123
|
6 |
|
throw new Exception('Unknown option found in the Page entity: ' . $name); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
7 |
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Returns this object as array. |
|
130
|
|
|
*/ |
|
131
|
3 |
|
public function toArray() |
|
132
|
|
|
{ |
|
133
|
|
|
$options = array( |
|
134
|
3 |
|
'edit_url' => $this->getEditUrl(), |
|
135
|
3 |
|
'name' => $this->getName(), |
|
136
|
3 |
|
'project_id' => $this->getProjectId(), |
|
137
|
3 |
|
'activation_code' => $this->getActivationCode(), |
|
138
|
3 |
|
'activation_type' => $this->getActivationType(), |
|
139
|
3 |
|
'api_name' => $this->getApiName(), |
|
140
|
3 |
|
'archived' => $this->getArchived(), |
|
141
|
3 |
|
'category' => $this->getCategory(), |
|
142
|
3 |
|
'conditions' => $this->getConditions(), |
|
143
|
3 |
|
'key' => $this->getKey(), |
|
144
|
3 |
|
'page_type' => $this->getPageType(), |
|
145
|
3 |
|
'created' => $this->getCreated(), |
|
146
|
3 |
|
'id' => $this->getId(), |
|
147
|
3 |
|
'last_modified' => $this->getLastModified() |
|
148
|
|
|
); |
|
149
|
|
|
|
|
150
|
|
|
// Remove options with empty values |
|
151
|
3 |
|
$cleanedOptions = array(); |
|
152
|
3 |
|
foreach ($options as $name=>$value) { |
|
153
|
3 |
|
if ($value!==null) |
|
154
|
3 |
|
$cleanedOptions[$name] = $value; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
3 |
|
return $cleanedOptions; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
5 |
|
public function getEditUrl() |
|
161
|
|
|
{ |
|
162
|
5 |
|
return $this->editUrl; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
7 |
|
public function setEditUrl($editUrl) |
|
166
|
|
|
{ |
|
167
|
7 |
|
$this->editUrl = $editUrl; |
|
168
|
7 |
|
} |
|
169
|
|
|
|
|
170
|
7 |
|
public function getName() |
|
171
|
|
|
{ |
|
172
|
7 |
|
return $this->name; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
7 |
|
public function setName($name) |
|
176
|
|
|
{ |
|
177
|
7 |
|
$this->name = $name; |
|
178
|
7 |
|
} |
|
179
|
|
|
|
|
180
|
5 |
|
public function getProjectId() |
|
181
|
|
|
{ |
|
182
|
5 |
|
return $this->projectId; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
7 |
|
public function setProjectId($projectId) |
|
186
|
|
|
{ |
|
187
|
7 |
|
$this->projectId = $projectId; |
|
188
|
7 |
|
} |
|
189
|
|
|
|
|
190
|
5 |
|
public function getActivationCode() |
|
191
|
|
|
{ |
|
192
|
5 |
|
return $this->activationCode; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
4 |
|
public function setActivationCode($activationCode) |
|
196
|
|
|
{ |
|
197
|
4 |
|
$this->activationCode = $activationCode; |
|
198
|
4 |
|
} |
|
199
|
|
|
|
|
200
|
5 |
|
public function getActivationType() |
|
201
|
|
|
{ |
|
202
|
5 |
|
return $this->activationType; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
7 |
|
public function setActivationType($activationType) |
|
206
|
|
|
{ |
|
207
|
7 |
|
$this->activationType = $activationType; |
|
208
|
7 |
|
} |
|
209
|
|
|
|
|
210
|
3 |
|
public function getApiName() |
|
211
|
|
|
{ |
|
212
|
3 |
|
return $this->apiName; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
public function setApiName($apiName) |
|
216
|
|
|
{ |
|
217
|
|
|
$this->apiName = $apiName; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
5 |
|
public function getArchived() |
|
221
|
|
|
{ |
|
222
|
5 |
|
return $this->archived; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
7 |
|
public function setArchived($archived) |
|
226
|
|
|
{ |
|
227
|
7 |
|
$this->archived = $archived; |
|
228
|
7 |
|
} |
|
229
|
|
|
|
|
230
|
3 |
|
public function getCategory() |
|
231
|
|
|
{ |
|
232
|
3 |
|
return $this->category; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
7 |
|
public function setCategory($category) |
|
236
|
|
|
{ |
|
237
|
7 |
|
$this->category = $category; |
|
238
|
7 |
|
} |
|
239
|
|
|
|
|
240
|
3 |
|
public function getConditions() |
|
241
|
|
|
{ |
|
242
|
3 |
|
return $this->conditions; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
7 |
|
public function setConditions($conditions) |
|
246
|
|
|
{ |
|
247
|
7 |
|
$this->conditions = $conditions; |
|
248
|
7 |
|
} |
|
249
|
|
|
|
|
250
|
3 |
|
public function getKey() |
|
251
|
|
|
{ |
|
252
|
3 |
|
return $this->key; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
7 |
|
public function setKey($key) |
|
256
|
|
|
{ |
|
257
|
7 |
|
$this->key = $key; |
|
258
|
7 |
|
} |
|
259
|
|
|
|
|
260
|
3 |
|
public function getPageType() |
|
261
|
|
|
{ |
|
262
|
3 |
|
return $this->pageType; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
7 |
|
public function setPageType($pageType) |
|
266
|
|
|
{ |
|
267
|
7 |
|
$this->pageType = $pageType; |
|
268
|
7 |
|
} |
|
269
|
|
|
|
|
270
|
3 |
|
public function getCreated() |
|
271
|
|
|
{ |
|
272
|
3 |
|
return $this->created; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
7 |
|
public function setCreated($created) |
|
276
|
|
|
{ |
|
277
|
7 |
|
$this->created = $created; |
|
278
|
7 |
|
} |
|
279
|
|
|
|
|
280
|
3 |
|
public function getId() |
|
281
|
|
|
{ |
|
282
|
3 |
|
return $this->id; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
7 |
|
public function setId($id) |
|
286
|
|
|
{ |
|
287
|
7 |
|
$this->id = $id; |
|
288
|
7 |
|
} |
|
289
|
|
|
|
|
290
|
3 |
|
public function getLastModified() |
|
291
|
|
|
{ |
|
292
|
3 |
|
return $this->lastModified; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
7 |
|
public function setLastModified($lastModified) |
|
296
|
|
|
{ |
|
297
|
7 |
|
$this->lastModified = $lastModified; |
|
298
|
7 |
|
} |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
|
|
302
|
|
|
|
|
303
|
|
|
|
|
304
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
|
|
307
|
|
|
|
|
308
|
|
|
|