convertToStripeObject() public static method

Converts a response from the Stripe API to the corresponding PHP object.
public static convertToStripeObject ( array $resp, array $opts ) : Stripe\StripeObject | array
$resp array The response from the Stripe API.
$opts array
return Stripe\StripeObject | array
Example #1
0
 /**
  * Refreshes this object using the provided values.
  *
  * @param array $values
  * @param array $opts
  * @param boolean $partial Defaults to false.
  */
 public function refreshFrom($values, $opts, $partial = false)
 {
     $this->_opts = $opts;
     // 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 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] = AttachedObject::constructFrom($v, $opts);
         } else {
             $this->_values[$k] = Util\Util::convertToStripeObject($v, $opts);
         }
         $this->_transientValues->discard($k);
         $this->_unsavedValues->discard($k);
     }
 }