1
0

Updated to reflect the fact that "resource" is now "entity" in responses.

This commit is contained in:
Bharat Mediratta 2010-01-27 21:46:00 -08:00
parent 8bd90d145d
commit eae41b182d
2 changed files with 7 additions and 7 deletions

View File

@ -27,7 +27,7 @@ class Gallery3 {
var $data; var $data;
var $file; var $file;
protected $original_resource; protected $original_entity;
/** /**
* Connect to a remote Gallery3 instance * Connect to a remote Gallery3 instance
@ -77,7 +77,7 @@ class Gallery3 {
* @chainable * @chainable
*/ */
public function set($key, $value) { public function set($key, $value) {
$this->data->resource->$key = $value; $this->data->entity->$key = $value;
return $this; return $this;
} }
@ -100,7 +100,7 @@ class Gallery3 {
*/ */
public function create($url, $token) { public function create($url, $token) {
$response = Gallery3_Helper::request( $response = Gallery3_Helper::request(
"post", $url, $token, $this->data->resource, $this->file); "post", $url, $token, $this->data->entity, $this->file);
$this->url = $response->url; $this->url = $response->url;
$this->token = $token; $this->token = $token;
return $this->load(); return $this->load();
@ -115,7 +115,7 @@ class Gallery3 {
public function save() { public function save() {
$response = Gallery3_Helper::request( $response = Gallery3_Helper::request(
"put", $this->url, $this->token, "put", $this->url, $this->token,
array_diff($this->original_resource, (array)$this->data->resource)); array_diff($this->original_entity, (array)$this->data->entity));
return $this->load(); return $this->load();
} }
@ -140,7 +140,7 @@ class Gallery3 {
public function load() { public function load() {
$response = Gallery3_Helper::request("get", $this->url, $this->token); $response = Gallery3_Helper::request("get", $this->url, $this->token);
$this->data = $response; $this->data = $response;
$this->original_resource = (array)$response->resource; $this->original_entity = (array)$response->entity;
return $this; return $this;
} }
} }

View File

@ -26,14 +26,14 @@ $album = Gallery3::factory()
->set("name", "Sample Album") ->set("name", "Sample Album")
->set("title", "This is my Sample Album") ->set("title", "This is my Sample Album")
->create($root->url, $auth); ->create($root->url, $auth);
alert("Created album: <b>{$album->url} {$album->data->resource->title}</b>"); alert("Created album: <b>{$album->url} {$album->data->entity->title}</b>");
alert("Modify the album"); alert("Modify the album");
$album $album
->set("title", "This is the new title") ->set("title", "This is the new title")
->save(); ->save();
alert("New title: <b>{$album->data->resource->title}</b>"); alert("New title: <b>{$album->data->entity->title}</b>");
$photo = Gallery3::factory() $photo = Gallery3::factory()