Example #1
0
 /**
  * @return null|string The instance URL for this resource. It needs to be special
  *                     cased because it doesn't fit into the standard resource pattern.
  *
  * @throws Error\InvalidRequest
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Error\InvalidRequest($msg, null);
     }
     if ($this['customer']) {
         $parent = $this['customer'];
         $base = Customer::classUrl();
         $path = 'sources';
     } elseif ($this['account']) {
         $parent = $this['account'];
         $base = Account::classUrl();
         $path = 'external_accounts';
     } elseif ($this['recipient']) {
         $parent = $this['recipient'];
         $base = Recipient::classUrl();
         $path = 'cards';
     } else {
         return;
     }
     $parent = Util\Util::utf8($parent);
     $id = Util\Util::utf8($id);
     $parentExtn = urlencode($parent);
     $extn = urlencode($id);
     return "{$base}/{$parentExtn}/{$path}/{$extn}";
 }
Example #2
0
 /**
  * @return string The instance URL for this resource. It needs to be special
  *    cased because it doesn't fit into the standard resource pattern.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Error\InvalidRequest($msg, null);
     }
     if (isset($this['customer'])) {
         $parent = $this['customer'];
         $base = Customer::classUrl();
     } elseif (isset($this['recipient'])) {
         $parent = $this['recipient'];
         $base = Recipient::classUrl();
     } else {
         return null;
     }
     $parent = ApiRequestor::utf8($parent);
     $id = ApiRequestor::utf8($id);
     $parentExtn = urlencode($parent);
     $extn = urlencode($id);
     return "{$base}/{$parentExtn}/cards/{$extn}";
 }