/** * Refreshes this object using the provided values. * * @param array $values * @param string $preset * @param boolean $partial Defaults to false. */ public function refreshFrom($values, $preset = null, $partial = false) { $this->_preset = $preset; // Wipe old state before setting new. This is useful for e.g. updating a // customer, where there is no persistent card parameter. Mark those values // which don't persist as transient if ($partial) { $removed = new Maestrano_Util_Set(); } else { $removed = array_diff(array_keys($this->_values), array_keys($values)); } foreach ($removed as $k) { if (self::$permanentAttributes->includes($k)) { continue; } unset($this->{$k}); } foreach ($values as $k => $v) { if (self::$permanentAttributes->includes($k) && isset($this[$k])) { continue; } if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) { $this->_values[$k] = Maestrano_Api_Object::scopedConstructFrom('Maestrano_AttachedObject', $v, $preset); } else { $this->_values[$k] = Maestrano_Api_Util::convertToMaestranoObject($v, $preset); } $this->_transientValues->discard($k); $this->_unsavedValues->discard($k); } }
protected static function _scopedCreate($class, $params = null, $apiToken = null) { self::_validateCall('create', $params, $apiToken); $requestor = new Maestrano_Api_Requestor($apiToken); $url = self::_scopedLsb($class, 'classUrl', $class); $realParams = Maestrano_Api_Util::convertMaestranoObjectToArray($params); list($response, $apiToken) = $requestor->request('post', $url, $realParams); return Maestrano_Api_Util::convertToMaestranoObject($response, $apiToken); }