diff --git a/README.md b/README.md index d4614bd..47a3eed 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ $project = $client->projects->createProjectForWorkspace($workspaceGid, array('na echo "Created project with gid: " . $project->gid; ``` -Methods that return multiple items (e.x. `findAll`) return an items iterator by default. See the "Collections" section +Methods that return multiple items (e.x. `getTasks`, `getProjects`, `getPortfolios`, etc.) return an items iterator by default. See the "Collections" section ## Options @@ -130,7 +130,7 @@ Asana\Client::$DEFAULTS['page_size'] = 1000; $client->options['page_size'] = 1000; // per-request: -$client->tasks->findAll(array('project' => 1234), array('page_size' => 1000)); +$client->tasks->getTasks(array('project' => 1234), array('page_size' => 1000)); ``` ### Available options diff --git a/examples/example-accesstoken.php b/examples/example-accesstoken.php index c32cedc..7ee1da6 100644 --- a/examples/example-accesstoken.php +++ b/examples/example-accesstoken.php @@ -20,5 +20,5 @@ // create a $client->with a Personal Access Token $client = Asana\Client::accessToken($ASANA_ACCESS_TOKEN); -$me = $client->users->me(); -echo "me="; var_dump($client->users->me()); +$me = $client->users->getUser('me'); +echo "me="; var_dump($client->users->getUser('me')); diff --git a/examples/example-create-project-and-stream-events.php b/examples/example-create-project-and-stream-events.php index 6715842..2b02ea7 100644 --- a/examples/example-create-project-and-stream-events.php +++ b/examples/example-create-project-and-stream-events.php @@ -17,14 +17,14 @@ // create a $client->with a Personal Access Token $client = Asana\Client::accessToken($ASANA_ACCESS_TOKEN); -$me = $client->users->me(); -echo "me="; var_dump($client->users->me()); +$me = $client->users->getUser('me'); +echo "me="; var_dump($client->users->getUser('me')); // find your "Personal Projects" project $personalProjectsArray = array_filter($me->workspaces, function($item) { return $item->name === 'Personal Projects'; }); $personalProjects = array_pop($personalProjectsArray); var_dump($personalProjects); -$projects = $client->projects->findByWorkspace($personalProjects->id, null, array('iterator_type' => false, 'page_size' => null))->data; +$projects = $client->projects->getProjectsForWorkspace($personalProjects->id, null, array('iterator_type' => false, 'page_size' => null))->data; echo "personal projects="; var_dump($projects); // create a "demo project" if it doesn't exist diff --git a/examples/example-create-task-and-upload.php b/examples/example-create-task-and-upload.php index c85f258..fd894f0 100644 --- a/examples/example-create-task-and-upload.php +++ b/examples/example-create-task-and-upload.php @@ -17,14 +17,14 @@ // create a $client->with a Personal Access Token $client = Asana\Client::accessToken($ASANA_ACCESS_TOKEN); -$me = $client->users->me(); -echo "me="; var_dump($client->users->me()); +$me = $client->users->getUser('me'); +echo "me="; var_dump($client->users->getUser('me')); // find your "Personal Projects" workspace $personalProjectsArray = array_filter($me->workspaces, function($item) { return $item->name === 'Personal Projects'; }); $personalProjects = array_pop($personalProjectsArray); var_dump($personalProjects); -$projects = $client->projects->findByWorkspace($personalProjects->gid, null, array('iterator_type' => false, 'page_size' => null))->data; +$projects = $client->projects->getProjectsForWorkspace($personalProjects->gid, null, array('iterator_type' => false, 'page_size' => null))->data; echo "personal projects="; var_dump($projects); // create a "demo project" if it doesn't exist diff --git a/examples/example-oauth.php b/examples/example-oauth.php index 3d4d6e0..e38c2b1 100644 --- a/examples/example-oauth.php +++ b/examples/example-oauth.php @@ -52,7 +52,7 @@ exit(1); } -echo "Hello " . $client->users->me()->name . "\n"; +echo "Hello " . $client->users->getUser('me')->name . "\n"; echo "Your access token is: " . json_encode($token) . "\n"; echo "Exchanging your refresh token for a new access token because access tokens expire\n"; @@ -61,7 +61,7 @@ echo "Your new access token is: " . json_encode($token) . "\n"; echo "You are a member of the following workspaces:\n"; -$workspaces = $client->workspaces->findAll(); +$workspaces = $client->workspaces->getWorkspaces(); foreach ($workspaces as $workspace) { echo $workspace->name . "\n"; } @@ -76,4 +76,4 @@ 'token' => json_decode($token) )); -echo "Your registered email address is: " . $client->users->me()->email; \ No newline at end of file +echo "Your registered email address is: " . $client->users->getUser('me')->email; \ No newline at end of file diff --git a/examples/example-server.php b/examples/example-server.php index 330508d..b80f971 100644 --- a/examples/example-server.php +++ b/examples/example-server.php @@ -19,7 +19,7 @@ function client($token=null) try { if ('/' == $_SERVER['SCRIPT_NAME']) { if (isset($_SESSION['token'])) { - $me = client($_SESSION['token'])->users->me(); + $me = client($_SESSION['token'])->users->getUser('me'); echo '

Hello ' . $me->name . '

Logout

'; } else { $state = null; diff --git a/tests/Asana/ClientTest.php b/tests/Asana/ClientTest.php index 63ab71e..28ab0d0 100644 --- a/tests/Asana/ClientTest.php +++ b/tests/Asana/ClientTest.php @@ -15,7 +15,7 @@ public function testClientGet() { $this->dispatcher->registerResponse('/users/me', 200, null, '{ "data": "foo" }'); - $result = $this->client->users->me(); + $result = $this->client->users->getUser('me'); $this->assertEquals($result, 'foo'); } @@ -25,7 +25,7 @@ public function testNotAuthorized() $this->dispatcher->registerResponse('/users/me', 401, null, '{ "errors": [{ "message": "Not Authorized" }]}'); - $this->client->users->me(); + $this->client->users->getUser('me'); } public function testInvalidRequest() @@ -34,7 +34,7 @@ public function testInvalidRequest() $this->dispatcher->registerResponse('/tasks?limit=50', 400, null, '{ "errors": [{ "message": "Missing input" }] }'); - $this->client->tasks->findAll(null, array('iterator_type' => false)); + $this->client->tasks->getTasks(null, array('iterator_type' => false)); } public function testServerError() @@ -44,7 +44,7 @@ public function testServerError() $res = '{ "errors": [ { "message": "Server Error", "phrase": "6 sad squid snuggle softly" } ] }'; $this->dispatcher->registerResponse('/users/me', 500, null, $res); - $this->client->users->me(); + $this->client->users->getUser('me'); } public function testNotFound() @@ -54,7 +54,7 @@ public function testNotFound() $res = '{ "errors": [ { "message": "user: Unknown object: 1234" } ] }'; $this->dispatcher->registerResponse('/users/1234', 404, null, $res); - $this->client->users->findById(1234); + $this->client->users->getUser(1234); } public function testForbidden() @@ -64,21 +64,21 @@ public function testForbidden() $res = '{ "errors": [ { "message": "user: Forbidden" } ] }'; $this->dispatcher->registerResponse('/users/1234', 403, null, $res); - $this->client->users->findById(1234); + $this->client->users->getUser(1234); } public function testOptionPretty() { $this->dispatcher->registerResponse('/users/me?opt_pretty=true', 200, null, '{ "data": "foo" }'); - $this->assertEquals($this->client->users->me(null, array('pretty' => true)), 'foo'); + $this->assertEquals($this->client->users->getUser('me', null, array('pretty' => true)), 'foo'); } public function testOptionFields() { $this->dispatcher->registerResponse('/tasks/1224?opt_fields=name%2Cnotes', 200, null, '{ "data": "foo" }'); - $result = $this->client->tasks->findById(1224, null, array("fields" => array('name','notes'))); + $result = $this->client->tasks->getTask(1224, null, array("fields" => array('name','notes'))); $this->assertEquals($result, 'foo'); } @@ -87,7 +87,7 @@ public function testOptionExpand() $req = '{ "data": { "assignee": 1234 }, "options": { "expand" : ["projects"] } }'; $this->dispatcher->registerResponse('/tasks/1001', 200, null, '{ "data": "foo" }'); - $result = $this->client->tasks->update(1001, array('assignee' => 1234), array('expand' => array('projects'))); + $result = $this->client->tasks->updateTask(1001, array('assignee' => 1234), array('expand' => array('projects'))); $this->assertEquals($result, 'foo'); $this->assertEquals(json_decode($this->dispatcher->calls[0]['request']->payload), json_decode($req)); } @@ -107,7 +107,7 @@ public function testPagination() $this->dispatcher->registerResponse('/projects/1337/tasks?limit=5&offset=ABCDEF', 200, null, $res); $options = array( 'limit' => 5, 'offset' => 'ABCDEF', 'iterator_type' => false ); - $result = $this->client->tasks->findByProject(1337, null, $options); + $result = $this->client->tasks->getTasksForProject(1337, null, $options); $this->assertEquals($result, json_decode($res)); } @@ -120,7 +120,7 @@ public function testItemIteratorItemLimitLessThanItems() $this->dispatcher->registerResponse('/projects/1337/tasks?limit=2', 200, null, $res); $options = array('item_limit' => 2, 'page_size' => 2, 'iterator_type' => 'items'); - $iterator = $this->client->tasks->findByProject(1337, null, $options); + $iterator = $this->client->tasks->getTasksForProject(1337, null, $options); $iterator->rewind(); $this->assertEquals($iterator->valid(), true); $this->assertEquals($iterator->current(), 'a'); @@ -142,7 +142,7 @@ public function testItemIteratorItemLimitEqualItems() $this->dispatcher->registerResponse('/projects/1337/tasks?limit=1&offset=a', 200, null, $res); $options = array('item_limit' => 3, 'page_size' => 2, 'iterator_type' => 'items'); - $iterator = $this->client->tasks->findByProject(1337, null, $options); + $iterator = $this->client->tasks->getTasksForProject(1337, null, $options); $iterator->rewind(); $this->assertEquals($iterator->valid(), true); $this->assertEquals($iterator->current(), 'a'); @@ -167,7 +167,7 @@ public function testItemIteratorItemLimitGreaterThanItems() $this->dispatcher->registerResponse('/projects/1337/tasks?limit=2&offset=a', 200, null, $res); $options = array('item_limit' => 4, 'page_size' => 2, 'iterator_type' => 'items'); - $iterator = $this->client->tasks->findByProject(1337, null, $options); + $iterator = $this->client->tasks->getTasksForProject(1337, null, $options); $iterator->rewind(); $this->assertEquals($iterator->valid(), true); $this->assertEquals($iterator->current(), 'a'); @@ -192,7 +192,7 @@ public function testItemIteratorPreserveOptFields() $this->dispatcher->registerResponse('/projects/1337/tasks?limit=1&offset=a&opt_fields=foo', 200, null, $res); $options = array('fields' => array('foo'), 'item_limit' => 3, 'page_size' => 2, 'iterator_type' => 'items'); - $iterator = $this->client->tasks->findByProject(1337, null, $options); + $iterator = $this->client->tasks->getTasksForProject(1337, null, $options); $iterator->rewind(); $this->assertEquals($iterator->valid(), true); $this->assertEquals($iterator->current(), 'a'); @@ -220,7 +220,7 @@ function () use (&$res) { } ); - $result = $this->client->users->me(); + $result = $this->client->users->getUser('me'); $this->assertEquals($result, 'me'); $this->assertEquals(count($this->dispatcher->calls), 2); $this->assertEquals($sleepCalls, array(0.1)); @@ -241,7 +241,7 @@ function () use (&$res) { } ); - $result = $this->client->users->me(); + $result = $this->client->users->getUser('me'); $this->assertEquals($result, 'me'); $this->assertEquals(count($this->dispatcher->calls), 3); $this->assertEquals($sleepCalls, array(0.1, 0.1)); @@ -261,7 +261,7 @@ function () use (&$res) { } ); - $result = $this->client->users->me(null, array('max_retries' => 1)); + $result = $this->client->users->getUser('me', null, array('max_retries' => 1)); $this->assertEquals(count($this->dispatcher->calls), 2); $this->assertEquals($sleepCalls, array(1.0)); } @@ -282,7 +282,7 @@ function () use (&$res) { } ); - $result = $this->client->users->me(); + $result = $this->client->users->getUser('me'); $this->assertEquals(count($this->dispatcher->calls), 4); $this->assertEquals($sleepCalls, array(1.0, 2.0, 4.0)); } @@ -293,7 +293,7 @@ public function testGetNamedParameters() $this->dispatcher->registerResponse('/tasks?limit=50&workspace=14916&assignee=me', 200, null, $res); $options = array('iterator_type' => false); - $result = $this->client->tasks->findAll(array('workspace' => 14916, 'assignee' => 'me'), $options); + $result = $this->client->tasks->getTasks(array('workspace' => 14916, 'assignee' => 'me'), $options); $this->assertEquals($result, json_decode('{ "data": "foo" }')); } @@ -308,7 +308,7 @@ public function testPostNamedParameters() }'; $this->dispatcher->registerResponse('/tasks', 201, null, '{ "data": "foo" }'); - $result = $this->client->tasks->create( + $result = $this->client->tasks->createTask( array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world.") ); $this->assertEquals($result, 'foo'); @@ -326,7 +326,7 @@ public function testPutNamedParameters() }'; $this->dispatcher->registerResponse('/tasks/1001', 200, null, '{ "data": "foo" }'); - $result = $this->client->tasks->update( + $result = $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world.") ); @@ -344,7 +344,7 @@ public function testAsanaChangeHeaderNone() null, '{ "data": "foo" }'); - $this->client->tasks->update( + $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world.") ); @@ -362,7 +362,7 @@ public function testAsanaChangeHeaderEnable() array('asana-change' => 'name=string_ids;info=something;affected=true'), '{ "data": "foo" }'); - $this->client->tasks->update( + $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world."), array('headers' => array('asana-enable' => 'string_ids')) @@ -381,7 +381,7 @@ public function testAsanaChangeHeaderDisable() array('asana-change' => 'name=string_ids;info=something;affected=true'), '{ "data": "foo" }'); - $this->client->tasks->update( + $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world."), array('headers' => array('asana-disable' => 'string_ids')) @@ -400,7 +400,7 @@ public function testAsanaChangeHeaderSingle() array('asana-change' => 'name=string_ids;info=something;affected=true'), '{ "data": "foo" }'); - $this->client->tasks->update( + $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world.") ); @@ -418,7 +418,7 @@ public function testAsanaChangeHeaderMultiple() array('asana-change' => 'name=string_ids;info=something;affected=true,name=new_sections;info=something;affected=true'), '{ "data": "foo" }'); - $this->client->tasks->update( + $this->client->tasks->updateTask( 1001, array('assignee' => 1235, 'followers' => array(5678), 'name' => "Hello, world.") ); diff --git a/tests/Asana/Resources/WebhooksTest.php b/tests/Asana/Resources/WebhooksTest.php index a7679ed..b3363ac 100644 --- a/tests/Asana/Resources/WebhooksTest.php +++ b/tests/Asana/Resources/WebhooksTest.php @@ -24,11 +24,11 @@ private function verifyWebhookData($webhook) $this->assertEquals($webhook->active, $this->data['active']); } - public function testWebhooksCreate() + public function testWebhooksCreateWebhook() { $this->dispatcher->registerResponse('/webhooks', 200, null, '{ "data": ' . json_encode($this->data) . ' }'); - $result = $this->client->webhooks->create(array('resource' => 111, 'target' => 'https://foo/123')); + $result = $this->client->webhooks->createWebhook(array('resource' => 111, 'target' => 'https://foo/123')); $this->verifyWebhookData($result); } diff --git a/tests/Asana/ResourcesTest.php b/tests/Asana/ResourcesTest.php index 1cf3eba..97ca206 100644 --- a/tests/Asana/ResourcesTest.php +++ b/tests/Asana/ResourcesTest.php @@ -26,75 +26,75 @@ public function testResourcesExist() } } - public function testAttachmentsFindById() + public function testAttachmentsGetAttachment() { $this->dispatcher->registerResponse('/attachments/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->attachments->findById(1); + $result = $this->client->attachments->getAttachment(1); $this->assertEquals($result, 'foo'); } - public function testCustomFieldsFindById() + public function testCustomFieldsGetCustomField() { $this->dispatcher->registerResponse('/custom_fields/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->customfields->findById(1); + $result = $this->client->customfields->getCustomField(1); $this->assertEquals($result, 'foo'); } - public function testProjectsFindById() + public function testProjectsGetProject() { $this->dispatcher->registerResponse('/projects/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->projects->findById(1); + $result = $this->client->projects->getProject(1); $this->assertEquals($result, 'foo'); } - public function testStoriesFindById() + public function testStoriesGetStory() { $this->dispatcher->registerResponse('/stories/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->stories->findById(1); + $result = $this->client->stories->getStory(1); $this->assertEquals($result, 'foo'); } - public function testTagsFindById() + public function testTagsGetTag() { $this->dispatcher->registerResponse('/tags/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->tags->findById(1); + $result = $this->client->tags->getTag(1); $this->assertEquals($result, 'foo'); } - public function testTasksFindById() + public function testTasksGetTask() { $this->dispatcher->registerResponse('/tasks/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->tasks->findById(1); + $result = $this->client->tasks->getTask(1); $this->assertEquals($result, 'foo'); } - public function testTeamsFindById() + public function testTeamsGetTeam() { $this->dispatcher->registerResponse('/teams/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->teams->findById(1); + $result = $this->client->teams->getTeam(1); $this->assertEquals($result, 'foo'); } - public function testUsersFindById() + public function testUsersGetUser() { $this->dispatcher->registerResponse('/users/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->users->findById(1); + $result = $this->client->users->getUser(1); $this->assertEquals($result, 'foo'); } - public function testWorkspacesFindById() + public function testWorkspacesGetWorkspace() { $this->dispatcher->registerResponse('/workspaces/1', 200, null, '{ "data": "foo" }'); - $result = $this->client->workspaces->findById(1); + $result = $this->client->workspaces->getWorkspace(1); $this->assertEquals($result, 'foo'); } }