public function testUpdateWithoutCustomer() { self::authorizeFromEnv(); $receiver = $this->createTestBitcoinReceiver("*****@*****.**"); $receiver->description = "a new description"; $receiver->save(); $this->assertEquals(BitcoinReceiver::classUrl() . "/" . $receiver['id'], $receiver->instanceUrl()); $updatedReceiver = BitcoinReceiver::retrieve($receiver->id); $this->assertEquals($receiver["description"], $updatedReceiver["description"]); }
/** * @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() { $result = parent::instanceUrl(); if ($result) { return $result; } else { $id = $this['id']; $id = Util\Util::utf8($id); $extn = urlencode($id); $base = BitcoinReceiver::classUrl(); return "{$base}/{$extn}"; } }
/** * @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); } $id = ApiRequestor::utf8($id); $extn = urlencode($id); if (!$this['customer']) { $base = BitcoinReceiver::classUrl(); return "{$base}/{$extn}"; } else { $base = Customer::classUrl(); $parent = ApiRequestor::utf8($this['customer']); $parentExtn = urlencode($parent); return "{$base}/{$parentExtn}/sources/{$extn}"; } }