-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing: Getting an error when listing experiments - unknown (new) att…
…ributes such as 'selector' causing exceptions to be thrown #1
- Loading branch information
1 parent
fe2892d
commit 6427ed5
Showing
24 changed files
with
2,126 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
202 changes: 202 additions & 0 deletions
202
lib/WebMarketingROI/OptimizelyPHP/Resource/v2/Attribute.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
<?php | ||
/** | ||
* @author Oleg Krivtsov <oleg@webmarketingroi.com.au> | ||
* @date 05 May 2017 | ||
* @copyright (c) 2017, Web Marketing ROI | ||
*/ | ||
namespace WebMarketingROI\OptimizelyPHP\Resource\v2; | ||
|
||
use WebMarketingROI\OptimizelyPHP\Exception; | ||
|
||
/** | ||
* Optimizely attribute. | ||
*/ | ||
class Attribute | ||
{ | ||
/** | ||
* Unique string identifier for this Attribute within the project | ||
* @var string | ||
*/ | ||
private $key; | ||
|
||
/** | ||
* The ID of the project the Attribute belongs to | ||
* @var integer | ||
*/ | ||
private $projectId; | ||
|
||
/** | ||
* Whether or not the Attribute has been archived | ||
* @var boolean | ||
*/ | ||
private $archived; | ||
|
||
/** | ||
* A short description of the Attribute | ||
* @var string | ||
*/ | ||
private $description; | ||
|
||
/** | ||
* The name of the Attribute | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* Whether this Attribute is a custom dimension or custom attribute. If this | ||
* is a custom dimension, it belongs to an Optimizely Classic experiment and | ||
* is read-only. | ||
* Can be custom_attribute or custom_dimension | ||
*/ | ||
private $conditionType; | ||
|
||
/** | ||
* The unique identifier for the Attribute | ||
* @var integer | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* The last time the Attribute was modified | ||
* @var string | ||
*/ | ||
private $lastModified; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct($options = array()) | ||
{ | ||
foreach ($options as $name=>$value) { | ||
switch ($name) { | ||
case 'key': $this->setKey($value); break; | ||
case 'project_id': $this->setProjectId($value); break; | ||
case 'archived': $this->setArchived($value); break; | ||
case 'description': $this->setDescription($value); break; | ||
case 'name': $this->setName($value); break; | ||
case 'condition_type': $this->setConditionType($value); break; | ||
case 'id': $this->setId($value); break; | ||
case 'last_modified': $this->setLastModified($value); break; | ||
default: | ||
throw new Exception('Unknown option found in the Attribute entity: ' . $name); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns this object as array. | ||
*/ | ||
public function toArray() | ||
{ | ||
$options = array( | ||
'key' => $this->getKey(), | ||
'project_id' => $this->getProjectId(), | ||
'archived' => $this->getArchived(), | ||
'description' => $this->getDescription(), | ||
'name' => $this->getName(), | ||
'condition_type' => $this->getConditionType(), | ||
'id' => $this->getId(), | ||
'last_modified' => $this->getLastModified(), | ||
); | ||
|
||
// Remove options with empty values | ||
$cleanedOptions = array(); | ||
foreach ($options as $name=>$value) { | ||
if ($value!==null) | ||
$cleanedOptions[$name] = $value; | ||
} | ||
|
||
return $cleanedOptions; | ||
} | ||
|
||
public function getKey() | ||
{ | ||
return $this->key; | ||
} | ||
|
||
public function setKey($key) | ||
{ | ||
$this->key = $key; | ||
} | ||
|
||
public function getProjectId() | ||
{ | ||
return $this->projectId; | ||
} | ||
|
||
public function setProjectId($projectId) | ||
{ | ||
$this->projectId = $projectId; | ||
} | ||
|
||
public function getArchived() | ||
{ | ||
return $this->archived; | ||
} | ||
|
||
public function setArchived($archived) | ||
{ | ||
$this->archived = $archived; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function setDescription($description) | ||
{ | ||
$this->description = $description; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getConditionType() | ||
{ | ||
return $this->conditionType; | ||
} | ||
|
||
public function setConditionType($conditionType) | ||
{ | ||
$this->conditionType = $conditionType; | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId($id) | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function getLastModified() | ||
{ | ||
return $this->lastModified; | ||
} | ||
|
||
public function setLastModified($lastModified) | ||
{ | ||
$this->lastModified = $lastModified; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.