protected static function _scopedCreate($class, $params = null, $apiKey = null)
 {
     self::_validateCall('create', $params, $apiKey);
     $requestor = new SweetTooth_ApiRequestor($apiKey);
     $url = self::_scopedLsb($class, 'classUrl', $class);
     list($response, $apiKey) = $requestor->request('post', $url, $params);
     return SweetTooth_Util::convertToSweetToothObject($response, $apiKey);
 }
 public function retrieve($id, $params = null)
 {
     $requestor = new SweetTooth_ApiRequestor($this->_apiKey);
     $base = $this['url'];
     $id = SweetTooth_ApiRequestor::utf8($id);
     $extn = urlencode($id);
     list($response, $apiKey) = $requestor->request('get', "{$base}/{$extn}", $params);
     return SweetTooth_Util::convertToSweetToothObject($response, $apiKey);
 }
Exemple #3
0
 public function refreshFrom($values, $apiKey, $partial = false)
 {
     $this->_apiKey = $apiKey;
     // 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 SweetTooth_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)) {
             continue;
         }
         if (self::$_nestedUpdatableAttributes->includes($k) && is_array($v)) {
             $this->_values[$k] = SweetTooth_Object::scopedConstructFrom('SweetTooth_AttachedObject', $v, $apiKey);
         } else {
             $this->_values[$k] = SweetTooth_Util::convertToSweetToothObject($v, $apiKey);
         }
         $this->_transientValues->discard($k);
         $this->_unsavedValues->discard($k);
     }
 }