You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by ro...@apache.org on 2014/12/11 02:50:55 UTC

[10/11] incubator-usergrid git commit: Create Attributes . So now when I have a User entity I don't need to call the api a 2nd time for the device relationship I can get access the device property on the User model e.g.: $user->device; and the SDK will t

Create Attributes . So now when I have a User entity I don't need to call the api a 2nd time for the device relationship I can get access the device property on the User model e.g.: $user->device; and the SDK will take care of the 2nd API call on my behalf.
Also added new response models so groups and roles and notifications and notifiers are all typed model response so they no longer return a entity model but a correctly typed models e.g.: Roles returns a roles model.
Also when asking a Response model for its entities property it now returns the correct model of the correct type: e.g. before this change when asking a user model for its entity you would get the base php collection model class now you get the Typed PHP Collection class so asking a User response for its entities property you get back a Users PHP collection class not BaseCollection class.
All notification endpoints are now mapped. You can send to  user , users, group, groups, device, devices can all be targeted for a push notiifcation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9ffe2b0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9ffe2b0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9ffe2b0d

Branch: refs/heads/master
Commit: 9ffe2b0d4d468b7d7c28f20f50d7e40afbe96c41
Parents: b06a805
Author: Jason Kristian <ja...@apps4u.com.au>
Authored: Fri Nov 21 17:41:12 2014 +1000
Committer: Jason Kristian <ja...@apps4u.com.au>
Committed: Fri Nov 21 17:41:12 2014 +1000

----------------------------------------------------------------------
 .../Examples/attrubites/attributes.php          |  122 +
 .../Examples/collections/books.php              |   26 +-
 .../Examples/collections/data.php               |   40 +-
 .../Examples/collections/users.php              |   29 +-
 sdks/php5/apache-usergrid/Examples/examples.php |    5 +-
 .../Examples/management/management.php          |    4 +-
 .../Examples/messages/messages.php              |    2 +-
 .../Examples/notifications/notifications.php    |    2 +-
 .../Examples/notifications/notifiers.php        |    7 +-
 sdks/php5/apache-usergrid/README.md             |   28 +-
 sdks/php5/apache-usergrid/composer.lock         |  183 +-
 .../src/Api/Exception/BadRequestException.php   |    3 +-
 .../src/Api/Exception/NotFoundException.php     |    3 +-
 .../src/Api/Exception/ServerErrorException.php  |    3 +-
 .../src/Api/Exception/UnauthorizedException.php |    3 +-
 .../src/Api/Exception/UsergridException.php     |   15 +-
 .../src/Api/Models/BaseCollection.php           |   66 +-
 .../apache-usergrid/src/Api/Models/Device.php   |   15 +-
 .../apache-usergrid/src/Api/Models/Group.php    |   54 +
 .../src/Api/Models/GuzzleCommandTrait.php       |    9 +
 .../apache-usergrid/src/Api/Models/Notifier.php |   36 +
 .../src/Api/Models/Organization.php             |   22 -
 .../apache-usergrid/src/Api/Models/Receipt.php  |   36 +
 .../apache-usergrid/src/Api/Models/Role.php     |   54 +
 .../apache-usergrid/src/Api/Models/User.php     |   42 +-
 .../apache-usergrid/src/Api/QueryAggregator.php |    2 +-
 .../src/Api/ResourceIterator.php                |    2 +-
 sdks/php5/apache-usergrid/src/Api/Usergrid.php  |  319 +-
 .../Oauth2/GrantType/AuthorizationCode.php      |    4 +-
 .../Oauth2/GrantType/ClientCredentials.php      |    1 -
 .../GrantType/HWIOAuthBundleRefreshToken.php    |    2 +-
 .../Oauth2/GrantType/PasswordCredentials.php    |    5 +-
 .../Plugin/Oauth2/GrantType/RefreshToken.php    |    1 -
 .../src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php   |  104 +-
 .../Laravel/ApacheUsergridServiceProvider.php   |   40 +-
 .../src/Manifests/1.0.0/Errors.php              |   71 +-
 .../src/Manifests/1.0.1/Application.php         |    3 -
 .../src/Manifests/1.0.1/Custom.php              |    3 +-
 .../src/Manifests/1.0.1/Devices.php             |   88 +-
 .../src/Manifests/1.0.1/Groups.php              |   19 +-
 .../src/Manifests/1.0.1/Notifiers.php           |   39 +-
 .../src/Manifests/1.0.1/Roles.php               |   15 +-
 .../src/Manifests/1.0.1/Users.php               |    3 +-
 .../src/Manifests/Application.php               |  985 ----
 .../src/Manifests/Management.php                | 1381 ------
 .../apache-usergrid/src/Manifests/Manifest.php  |   23 -
 .../apache-usergrid/src/Manifests/Usergrid.php  | 4689 ------------------
 .../src/Manifests/applications.json             | 1262 -----
 .../src/Manifests/management.json               | 1905 -------
 .../src/Manifests/resources.json                |   15 -
 .../Manifests/swagger-json/applications.json    | 1262 +++++
 .../src/Manifests/swagger-json/management.json  | 1905 +++++++
 .../src/Manifests/swagger-json/resources.json   |   15 +
 .../src/Native/Facades/Usergrid.php             |   63 +-
 .../src/Native/UsergridBootstrapper.php         |   25 +-
 sdks/php5/apache-usergrid/src/config/config.php |   12 -
 .../tests/Api/ApplicationTest.php               |    2 +-
 .../apache-usergrid/tests/Api/AttributeTest.php |   59 +
 .../Api/Exception/BadRequestExceptionTest.php   |    4 +-
 .../Api/Exception/InvalidIdExceptionTest.php    |    4 +-
 .../Api/Exception/NotFoundExceptionTest.php     |    4 +-
 .../Api/Exception/ServerErrorExceptionTest.php  |    4 +-
 .../Api/Exception/UnauthorizedExceptionTest.php |    4 +-
 .../tests/Api/Filters/BooleanTest.php           |    2 +-
 .../tests/Api/Filters/DateTest.php              |    2 +-
 .../tests/Api/ManagementTest.php                |    2 +-
 .../tests/Api/QueryAggregatorTest.php           |    2 -
 .../apache-usergrid/tests/Api/UsergridTest.php  |    8 +-
 .../tests/Laravel/Facades/UsergridTest.php      |    2 +-
 sdks/php5/apache-usergrid/tests/bootstrap.php   |   14 +-
 70 files changed, 4388 insertions(+), 10797 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/attrubites/attributes.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/attrubites/attributes.php b/sdks/php5/apache-usergrid/Examples/attrubites/attributes.php
new file mode 100644
index 0000000..0f4f180
--- /dev/null
+++ b/sdks/php5/apache-usergrid/Examples/attrubites/attributes.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+include('vendor/autoload.php');
+
+include('data.php');
+
+use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
+
+/** The PHP SDK returns all responses as Illuminate\Support\Collection subclasses so the word collection below is php collection class not usergrid collection */
+
+/** Source your config from file I'm using array here just for ease of use.
+ * When using Laravel Framework publish the package config file when using with
+ * other modern PHP frameworks just use their default config system .
+ */
+$config = [
+    'usergrid' => [
+        'url' => 'https://api.usergrid.com',
+        'version' => '1.0.1', // set manifest version
+        'orgName' => '',
+        'appName' => '',
+        'manifestPath' => null, //leave as default or change to your own custom folder
+        'clientId' => '',
+        'clientSecret' => '',
+        'username' => '',
+        'password' => '',
+        /**
+         * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
+         * Token from.  You have two options here one is 'application' the other is 'organization'
+         *
+         *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
+         *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
+         */
+        'auth_type' => 'organization',
+        /** The Grant Type to use
+         *
+         * This has to be set to one of the 2 grant types that Apache Usergrid
+         * supports which at the moment is client_credentials or password but at
+         * 2 level organization or application
+         */
+        'grant_type' => 'client_credentials',
+        /**
+         * if you want to manage your own auth flow by calling the token api and setting the token your self just set this to false
+         * */
+        'enable_oauth2_plugin' => true
+    ]
+];
+
+$bootstrapper = new UsergridBootstrapper($config);
+Usergrid::instance($bootstrapper);
+
+
+/**
+ * Attributes are a new feature that make getting related models easy as accessing a property on a model object
+ * The way relationships work before this feature it required you to call the getRelationship method on the application
+ * service which is still available, so for example you would first get the user then once you had the user you create a
+ * array that contained the uuid of the user the related collection name and the relationship name then call the api passing in the
+ * array but for the default relationships we already have the data that we need to make the api call so that is what
+ * I've done.
+ * <pre>
+ * <?php
+ *  $user = Usergrid::users()->findById(['uuid' => '1234abcd']) ;
+ *  $device = $user->device;
+ * ?>
+ * </pre>
+ *  That's all you need to do to get a device for the user this only works when you have one user in your user collection
+ *  if you call this with more then one user in your user collection it will return the device for the first user in the
+ *  collection.
+ *
+ */
+
+$user = Usergrid::users()->findById(['uuid' => '1234abcd']);
+
+echo "device" . PHP_EOL;
+var_dump($user->device);
+var_dump('=================================================================');
+
+echo "roles" . PHP_EOL;
+var_dump($user->roles);
+var_dump('=================================================================');
+
+echo "groups" . PHP_EOL;
+var_dump($user->groups);
+var_dump('=================================================================');
+
+echo "connections" . PHP_EOL;
+var_dump($user->connections);
+var_dump('=================================================================');
+
+
+var_dump('=================================================================');
+echo "GROUPS" . PHP_EOL;
+var_dump('=================================================================');
+
+
+$group = Usergrid::groups()->findById(['uuid' => '121212']);
+
+
+echo "roles" . PHP_EOL;
+var_dump($group->roles);
+var_dump('=================================================================');
+
+echo "groups" . PHP_EOL;
+var_dump($group->users);
+var_dump('=================================================================');
+
+echo "connections" . PHP_EOL;
+var_dump($group->connections);
+var_dump('=================================================================');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/collections/books.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/collections/books.php b/sdks/php5/apache-usergrid/Examples/collections/books.php
index e2d31ae..034046e 100644
--- a/sdks/php5/apache-usergrid/Examples/collections/books.php
+++ b/sdks/php5/apache-usergrid/Examples/collections/books.php
@@ -17,9 +17,9 @@ include('vendor/autoload.php');
 
 include('data.php');
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
-use Apache\Usergrid\Native\Facades\Usergrid;
 use Apache\Usergrid\Api\Filters\Date;
+use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 /** The PHP SDK returns all responses as Illuminate\Support\Collection subclasses so the word collection below is php collection class not usergrid collection */
 
@@ -64,7 +64,7 @@ $bootstrapper = new UsergridBootstrapper($config);
 Usergrid::instance($bootstrapper);
 
 
-foreach($books_data as $book){
+foreach ($books_data as $book) {
     Usergrid::application()->EntityJsonPost($book);
 }
 
@@ -116,15 +116,15 @@ $caching_iterator = $books->entities->getCachingIterator();
 /// Here are some more Methods that you can call on your responses .. To get the most out of this SDK please look at the Illuminate\Support\Collection class
 /// which is the supper class of Apache/Usergrid/Api/Models/BaseCollection class
 /**
-    $books->unique();
-    $books->transform();
-    $books->take();
-    $books->splice();
-    $books->sum($callback );
-    $books->values();
-    $books->sortByDesc($callback);
-    $books->sortBy();
-    $books->shuffle();
-    $books->chunk();
+ * $books->unique();
+ * $books->transform();
+ * $books->take();
+ * $books->splice();
+ * $books->sum($callback );
+ * $books->values();
+ * $books->sortByDesc($callback);
+ * $books->sortBy();
+ * $books->shuffle();
+ * $books->chunk();
  */
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/collections/data.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/collections/data.php b/sdks/php5/apache-usergrid/Examples/collections/data.php
index a926dbe..e9ca805 100644
--- a/sdks/php5/apache-usergrid/Examples/collections/data.php
+++ b/sdks/php5/apache-usergrid/Examples/collections/data.php
@@ -15,24 +15,24 @@
  */
 
 $books_data = [
-['collection' => 'books', 'title' => 'book one', 'name' => 'book_one', 'author' => 'author 1'],
-['collection' => 'books', 'title' => 'book two', 'name' => 'book_two', 'author' => 'author 2'],
-['collection' => 'books', 'title' => 'book three', 'name' => 'book_three', 'author' => 'author 3'],
-['collection' => 'books', 'title' => 'book four', 'name' => 'book_four', 'author' => 'author 4'],
-['collection' => 'books', 'title' => 'book five', 'name' => 'book_five', 'author' => 'author 5'],
-['collection' => 'books', 'title' => 'book six', 'name' => 'book_six', 'author' => 'author 6'],
-['collection' => 'books', 'title' => 'book seven', 'name' => 'book_seven', 'author' => 'author 7'],
-['collection' => 'books', 'title' => 'book eight', 'name' => 'book_eight', 'author' => 'author 8'],
-['collection' => 'books', 'title' => 'book nine', 'name' => 'book_nine', 'author' => 'author 9'],
-['collection' => 'books', 'title' => 'book ten', 'name' => 'book_ten', 'author' => 'author 10'],
-['collection' => 'books', 'title' => 'book eleven', 'name' => 'book_eleven', 'author' => 'author 11'],
-['collection' => 'books', 'title' => 'book twelve', 'name' => 'book_twelve', 'author' => 'author 12'],
-['collection' => 'books', 'title' => 'book thirteen', 'name' => 'book_thirteen', 'author' => 'author 13'],
-['collection' => 'books', 'title' => 'book fourteen', 'name' => 'book_fourteen', 'author' => 'author 14'],
-['collection' => 'books', 'title' => 'book fifteen', 'name' => 'book_fifteen', 'author' => 'author 15'],
-['collection' => 'books', 'title' => 'book sixteen', 'name' => 'book_sixteen', 'author' => 'author 16'],
-['collection' => 'books', 'title' => 'book seventeen', 'name' => 'book_seventeen', 'author' => 'author 17'],
-['collection' => 'books', 'title' => 'book eighteen', 'name' => 'book_eighteen', 'author' => 'author 18'],
-['collection' => 'books', 'title' => 'book nineteen', 'name' => 'book_nineteen', 'author' => 'author 19'],
-['collection' => 'books', 'title' => 'book twenty', 'name' => 'book_twenty', 'author' => 'author 20'],
+    ['collection' => 'books', 'title' => 'book one', 'name' => 'book_one', 'author' => 'author 1'],
+    ['collection' => 'books', 'title' => 'book two', 'name' => 'book_two', 'author' => 'author 2'],
+    ['collection' => 'books', 'title' => 'book three', 'name' => 'book_three', 'author' => 'author 3'],
+    ['collection' => 'books', 'title' => 'book four', 'name' => 'book_four', 'author' => 'author 4'],
+    ['collection' => 'books', 'title' => 'book five', 'name' => 'book_five', 'author' => 'author 5'],
+    ['collection' => 'books', 'title' => 'book six', 'name' => 'book_six', 'author' => 'author 6'],
+    ['collection' => 'books', 'title' => 'book seven', 'name' => 'book_seven', 'author' => 'author 7'],
+    ['collection' => 'books', 'title' => 'book eight', 'name' => 'book_eight', 'author' => 'author 8'],
+    ['collection' => 'books', 'title' => 'book nine', 'name' => 'book_nine', 'author' => 'author 9'],
+    ['collection' => 'books', 'title' => 'book ten', 'name' => 'book_ten', 'author' => 'author 10'],
+    ['collection' => 'books', 'title' => 'book eleven', 'name' => 'book_eleven', 'author' => 'author 11'],
+    ['collection' => 'books', 'title' => 'book twelve', 'name' => 'book_twelve', 'author' => 'author 12'],
+    ['collection' => 'books', 'title' => 'book thirteen', 'name' => 'book_thirteen', 'author' => 'author 13'],
+    ['collection' => 'books', 'title' => 'book fourteen', 'name' => 'book_fourteen', 'author' => 'author 14'],
+    ['collection' => 'books', 'title' => 'book fifteen', 'name' => 'book_fifteen', 'author' => 'author 15'],
+    ['collection' => 'books', 'title' => 'book sixteen', 'name' => 'book_sixteen', 'author' => 'author 16'],
+    ['collection' => 'books', 'title' => 'book seventeen', 'name' => 'book_seventeen', 'author' => 'author 17'],
+    ['collection' => 'books', 'title' => 'book eighteen', 'name' => 'book_eighteen', 'author' => 'author 18'],
+    ['collection' => 'books', 'title' => 'book nineteen', 'name' => 'book_nineteen', 'author' => 'author 19'],
+    ['collection' => 'books', 'title' => 'book twenty', 'name' => 'book_twenty', 'author' => 'author 20'],
 ];

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/collections/users.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/collections/users.php b/sdks/php5/apache-usergrid/Examples/collections/users.php
index 9bcea83..da67ac3 100644
--- a/sdks/php5/apache-usergrid/Examples/collections/users.php
+++ b/sdks/php5/apache-usergrid/Examples/collections/users.php
@@ -17,8 +17,8 @@ include('vendor/autoload.php');
 
 include('data.php');
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 /** The PHP SDK returns all responses as Illuminate\Support\Collection subclasses so the word collection below is php collection class not usergrid collection */
 
@@ -68,12 +68,12 @@ $users_paged = Usergrid::users()->all();
 var_dump(get_class($users_paged->entities));
 
 //// get user 50 page size
-$users_paged_50= Usergrid::users()->all(['limit' => 50]);
+$users_paged_50 = Usergrid::users()->all(['limit' => 50]);
 var_dump($users_paged_50->entities);
 
 // get all users
-$all_users  = Usergrid::usersIterator();
-foreach($all_users as $user) {
+$all_users = Usergrid::usersIterator();
+foreach ($all_users as $user) {
 //    var_dump($user['uuid']); // as array
 }
 
@@ -95,7 +95,26 @@ echo $user_addr->entities->fetch('adr.city');
 $users_nested = Usergrid::users()->all();
 var_dump($users_nested->entities->fetch('metadata.collections.devices')->first());
 
+// The response that is returned is a PHP collection that has a Zero indexed $item property.
+// but as its a collection class it has some methods that can help you find what you need and one
+// of my fav feature is changing the Zero indexed collection to be indexed by the entity uuid or name or any other property.
+$users_by = Usergrid::users()->all();
+
+$users_by_uuid = $users_by->entities->keyBy('uuid');
+var_dump($users_by_uuid->get('add uuid of user'));
+
+$users_by_name = $users_by->entities->keyBy('username');
+var_dump($users_by_name->get('jasonk'));
+
+$users_by_email = $users_by->entities->keyBy('email');
+var_dump($users_by_email->get('jasonk@apps4u.com.au'));
+
+// sort by key
+$sorted_by_email = $users_by->sortBy('username');
+var_dump($sorted_by_email);
+
+
 // add user to group
 //$user_to_group = Usergrid::groups()->addUser(['entity_name_or_uuid' => 'group_name_or_uuid', 'user_name_or_uuid' => 'user name or uuid']);
 
-//$user_remove_group = Usergrid::groups()->removeUser(['entity_name_or_uuid' => 'group_name_or_uuid', 'user_name_or_uuid' => 'user name or uuid']);
+//$user_remove_group = Usergrid::groups()->removeUser(['entity_name_or_uuid' => 'group_name_or_uuid', 'user_name_or_uuid' => 'user name or uuid']);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/examples.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/examples.php b/sdks/php5/apache-usergrid/Examples/examples.php
index b896ec7..0348610 100644
--- a/sdks/php5/apache-usergrid/Examples/examples.php
+++ b/sdks/php5/apache-usergrid/Examples/examples.php
@@ -17,8 +17,8 @@
 include('vendor/autoload.php');
 
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 /** Source your config from file I'm using array here just for ease of use.
  * When using Laravel Framework publish the package config file when using with
@@ -213,9 +213,8 @@ $fEdited_entity = Usergrid::applications()->EntityPut($fCustom_entity_edit);
 //var_dump($fEdited_entity->entities);
 
 
-
 /** Relationships */
-$related_data =[
+$related_data = [
     'collection' => 'required',
     'entity_id' => 'required',
     'relationship' => 'required',

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/management/management.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/management/management.php b/sdks/php5/apache-usergrid/Examples/management/management.php
index 5808a6c..cfc5d61 100644
--- a/sdks/php5/apache-usergrid/Examples/management/management.php
+++ b/sdks/php5/apache-usergrid/Examples/management/management.php
@@ -16,8 +16,8 @@
 include('vendor/autoload.php');
 
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 /**
  * When working with the management api any calls that require a application to target will use the default app name set in the config but some times you may want to
@@ -74,7 +74,7 @@ $activity_feed = Usergrid::management()->OrgFeedGet();
 $organization_details = Usergrid::management()->OrgGet();
 
 //get organizations application
-$organization_applications  = Usergrid::management()->OrgAppsGet();
+$organization_applications = Usergrid::management()->OrgAppsGet();
 
 //create application
 $app = ['name' => 'app name -- required'];

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/messages/messages.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/messages/messages.php b/sdks/php5/apache-usergrid/Examples/messages/messages.php
index 3cac534..0eded4a 100644
--- a/sdks/php5/apache-usergrid/Examples/messages/messages.php
+++ b/sdks/php5/apache-usergrid/Examples/messages/messages.php
@@ -17,8 +17,8 @@ include('vendor/autoload.php');
 
 include('data.php');
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 
 /** Source your config from file I'm using array here just for ease of use.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/notifications/notifications.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/notifications/notifications.php b/sdks/php5/apache-usergrid/Examples/notifications/notifications.php
index c484d57..1a76ef8 100644
--- a/sdks/php5/apache-usergrid/Examples/notifications/notifications.php
+++ b/sdks/php5/apache-usergrid/Examples/notifications/notifications.php
@@ -17,8 +17,8 @@ include('vendor/autoload.php');
 
 include('data.php');
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 
 /** Source your config from file I'm using array here just for ease of use.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/Examples/notifications/notifiers.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/Examples/notifications/notifiers.php b/sdks/php5/apache-usergrid/Examples/notifications/notifiers.php
index 89fe48a..e32f6f4 100644
--- a/sdks/php5/apache-usergrid/Examples/notifications/notifiers.php
+++ b/sdks/php5/apache-usergrid/Examples/notifications/notifiers.php
@@ -16,8 +16,8 @@
 include('vendor/autoload.php');
 include('data.php');
 
-use Apache\Usergrid\Native\UsergridBootstrapper;
 use Apache\Usergrid\Native\Facades\Usergrid;
+use Apache\Usergrid\Native\UsergridBootstrapper;
 
 
 /** Source your config from file I'm using array here just for ease of use.
@@ -54,7 +54,8 @@ $config = [
          * if you want to manage your own auth flow by calling the token api and setting the token your self just set this to false
          * */
         'enable_oauth2_plugin' => true
-    ]];
+    ]
+];
 
 // You need to add a push cert to this folder and pass the path in the apple_notifier_data array
 
@@ -65,7 +66,7 @@ Usergrid::instance($bootstrapper);
 $apple_notifier_data = [
     'name' => 'apple_test',
     'environment' => 'development',
-    'p12Certificate' =>  @'pushtest_dev.p12'
+    'p12Certificate' => @'pushtest_dev.p12'
 ];
 $apple_notifier = Usergrid::notifiers()->createApple($apple_notifier_data);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/README.md
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/README.md b/sdks/php5/apache-usergrid/README.md
index 54d4e8f..567f3f1 100644
--- a/sdks/php5/apache-usergrid/README.md
+++ b/sdks/php5/apache-usergrid/README.md
@@ -66,7 +66,7 @@ or native use just create a config file
 
 ```
      $bootstrap = new UsergridBootstrapper($config);
-     Usergrid::instance($boostraper);
+     Usergrid::instance($bootstrap);
      $res = Usergrid::application()->EntityGet(['collection' => 'shops']);
 ```
 
@@ -151,6 +151,30 @@ The SDK will check each response to see if their is a cursor and if there is it
     // this will have all devices. 
     }
 ```
+# NEW feature - Attributes
+### Attributes (relationships) 
+The Usergrid PHP SDK has api call on the application service to get a related models but it requires that you make two api calls one to get the entity then a 2nd to get the relationship eg:
+
+```
+$users = Usergrid::users()->all(['limit' => 1]);
+$user_uuid = $users-entities->fetch('uuid');
+$data = [ 'collection' => 'users', 'entity_id' => $user_uuid, 'relationship' => 'devices'];
+$device = Usergrid::application()->GetRelationship($data);
+```
+
+Now the data we require for you to make the relationship api call is already in the SDK we should not force you to make a 2nd api call and give us data we already have. so now you don't need to any more. Just access the default relationships as a property on your response Model.
+
+```
+    $users = Usergrid::users()->all();
+    $user = $users->entities->get(0);
+    $device = $user->device;
+```
+
+that's it, So the take away point is let the SDK do the work for you and if you create custom service descriptors and model classes for your custom collection then look at the User response
+model class at it's deviceAttribute method to see how you can either add it to your custom collections or add custom relationship attributes to the default collections. Remember the SDK is designed
+for you to be able to extend the Guzzle service descriptors (manifest files).
+
+
 ### HTTP headers and UserAgents
 
  When working with http clients & server system you may want to sett additional HTTP Headers. Ive have made this easy as well on the Usergrid class you 
@@ -192,4 +216,4 @@ of it as a helper as some times it good to have access to both world server side
 * Writing tests
 * Code review
 * Code
-* Manifest files
\ No newline at end of file
+* Manifest files

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/composer.lock
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/composer.lock b/sdks/php5/apache-usergrid/composer.lock
index 1dd33b1..3060421 100644
--- a/sdks/php5/apache-usergrid/composer.lock
+++ b/sdks/php5/apache-usergrid/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "b5596d79dd2dd146c428d2e33431ed20",
+    "hash": "f77c404fc8b03f21424d391e5451af8a",
     "packages": [
         {
             "name": "guzzle/guzzle",
@@ -12,12 +12,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/guzzle3.git",
-                "reference": "3c0ca2255751631f1dd64eb16bbe3b9440258297"
+                "reference": "5e6fb7097efac7180bd75006079144025255eb63"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/3c0ca2255751631f1dd64eb16bbe3b9440258297",
-                "reference": "3c0ca2255751631f1dd64eb16bbe3b9440258297",
+                "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/5e6fb7097efac7180bd75006079144025255eb63",
+                "reference": "5e6fb7097efac7180bd75006079144025255eb63",
                 "shasum": ""
             },
             "require": {
@@ -96,7 +96,7 @@
                 "rest",
                 "web service"
             ],
-            "time": "2014-10-15 19:36:56"
+            "time": "2014-10-29 23:08:23"
         },
         {
             "name": "illuminate/support",
@@ -194,17 +194,17 @@
         },
         {
             "name": "symfony/event-dispatcher",
-            "version": "dev-master",
+            "version": "2.7.x-dev",
             "target-dir": "Symfony/Component/EventDispatcher",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/EventDispatcher.git",
-                "reference": "e133748fd9165e24f8e9498ef5862f8bd37004e5"
+                "reference": "8e5829263631e686bf4d1254b02411263b8fa228"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e133748fd9165e24f8e9498ef5862f8bd37004e5",
-                "reference": "e133748fd9165e24f8e9498ef5862f8bd37004e5",
+                "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8e5829263631e686bf4d1254b02411263b8fa228",
+                "reference": "8e5829263631e686bf4d1254b02411263b8fa228",
                 "shasum": ""
             },
             "require": {
@@ -224,7 +224,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "2.6-dev"
+                    "dev-master": "2.7-dev"
                 }
             },
             "autoload": {
@@ -248,7 +248,7 @@
             ],
             "description": "Symfony EventDispatcher Component",
             "homepage": "http://symfony.com",
-            "time": "2014-10-04 06:08:58"
+            "time": "2014-11-10 18:00:54"
         }
     ],
     "packages-dev": [
@@ -312,12 +312,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/padraic/mockery.git",
-                "reference": "8e567de2249a8f7eb8051a855b9d0a6472d38c8e"
+                "reference": "30eb319efcf2ebe6b4529be51f60df78340bdbb5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/padraic/mockery/zipball/8e567de2249a8f7eb8051a855b9d0a6472d38c8e",
-                "reference": "8e567de2249a8f7eb8051a855b9d0a6472d38c8e",
+                "url": "https://api.github.com/repos/padraic/mockery/zipball/30eb319efcf2ebe6b4529be51f60df78340bdbb5",
+                "reference": "30eb319efcf2ebe6b4529be51f60df78340bdbb5",
                 "shasum": ""
             },
             "require": {
@@ -370,7 +370,115 @@
                 "test double",
                 "testing"
             ],
-            "time": "2014-10-16 09:15:15"
+            "time": "2014-11-10 08:31:38"
+        },
+        {
+            "name": "phpdocumentor/reflection-docblock",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
+                "reference": "fd0ac2007401505fb596fdfb859ec4e103d69e55"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/fd0ac2007401505fb596fdfb859ec4e103d69e55",
+                "reference": "fd0ac2007401505fb596fdfb859ec4e103d69e55",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4.0"
+            },
+            "suggest": {
+                "dflydev/markdown": "~1.0",
+                "erusev/parsedown": "~1.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "phpDocumentor": [
+                        "src/"
+                    ]
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mike van Riel",
+                    "email": "mike.vanriel@naenius.com"
+                }
+            ],
+            "time": "2014-09-02 14:26:20"
+        },
+        {
+            "name": "phpspec/prophecy",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpspec/prophecy.git",
+                "reference": "2bbc78d0b4b1ce8049479395ba950d4b13f21d94"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/2bbc78d0b4b1ce8049479395ba950d4b13f21d94",
+                "reference": "2bbc78d0b4b1ce8049479395ba950d4b13f21d94",
+                "shasum": ""
+            },
+            "require": {
+                "doctrine/instantiator": "~1.0,>=1.0.2",
+                "phpdocumentor/reflection-docblock": "~2.0"
+            },
+            "require-dev": {
+                "phpspec/phpspec": "~2.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.2.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "Prophecy\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Konstantin Kudryashov",
+                    "email": "ever.zet@gmail.com",
+                    "homepage": "http://everzet.com"
+                },
+                {
+                    "name": "Marcello Duarte",
+                    "email": "marcello.duarte@gmail.com"
+                }
+            ],
+            "description": "Highly opinionated mocking framework for PHP 5.3+",
+            "homepage": "http://phpspec.org",
+            "keywords": [
+                "Double",
+                "Dummy",
+                "fake",
+                "mock",
+                "spy",
+                "stub"
+            ],
+            "time": "2014-10-05 19:43:51"
         },
         {
             "name": "phpunit/php-code-coverage",
@@ -378,12 +486,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
-                "reference": "28d21b57c189cb72829056353de603c4d4da55a0"
+                "reference": "21b9006b7ceb7e1cb0b705615af31f67c8cd1692"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28d21b57c189cb72829056353de603c4d4da55a0",
-                "reference": "28d21b57c189cb72829056353de603c4d4da55a0",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/21b9006b7ceb7e1cb0b705615af31f67c8cd1692",
+                "reference": "21b9006b7ceb7e1cb0b705615af31f67c8cd1692",
                 "shasum": ""
             },
             "require": {
@@ -432,7 +540,7 @@
                 "testing",
                 "xunit"
             ],
-            "time": "2014-10-05 10:46:54"
+            "time": "2014-11-11 14:18:30"
         },
         {
             "name": "phpunit/php-file-iterator",
@@ -622,12 +730,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "628bcfbbefa0e47dbb7d773021338590bd7586ee"
+                "reference": "247756f342dfb0a319f8985ef06f21a00d98b59c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/628bcfbbefa0e47dbb7d773021338590bd7586ee",
-                "reference": "628bcfbbefa0e47dbb7d773021338590bd7586ee",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/247756f342dfb0a319f8985ef06f21a00d98b59c",
+                "reference": "247756f342dfb0a319f8985ef06f21a00d98b59c",
                 "shasum": ""
             },
             "require": {
@@ -637,6 +745,7 @@
                 "ext-reflection": "*",
                 "ext-spl": "*",
                 "php": ">=5.3.3",
+                "phpspec/prophecy": "~1.2",
                 "phpunit/php-code-coverage": "3.0.*@dev",
                 "phpunit/php-file-iterator": "~1.3.2",
                 "phpunit/php-text-template": "~1.2",
@@ -685,7 +794,7 @@
                 "testing",
                 "xunit"
             ],
-            "time": "2014-10-22 11:54:43"
+            "time": "2014-11-06 08:43:29"
         },
         {
             "name": "phpunit/phpunit-mock-objects",
@@ -812,12 +921,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/diff.git",
-                "reference": "92d423df43b160006907ea4297b916fdf00415d8"
+                "reference": "3e22c89be2e1cddf7db89699cb23a9159df12e0c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/92d423df43b160006907ea4297b916fdf00415d8",
-                "reference": "92d423df43b160006907ea4297b916fdf00415d8",
+                "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3e22c89be2e1cddf7db89699cb23a9159df12e0c",
+                "reference": "3e22c89be2e1cddf7db89699cb23a9159df12e0c",
                 "shasum": ""
             },
             "require": {
@@ -856,7 +965,7 @@
             "keywords": [
                 "diff"
             ],
-            "time": "2014-10-19 13:19:30"
+            "time": "2014-11-05 15:28:21"
         },
         {
             "name": "sebastian/environment",
@@ -864,12 +973,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/environment.git",
-                "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d"
+                "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d",
-                "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d",
+                "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7",
+                "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7",
                 "shasum": ""
             },
             "require": {
@@ -906,7 +1015,7 @@
                 "environment",
                 "hhvm"
             ],
-            "time": "2014-10-22 06:38:05"
+            "time": "2014-10-25 08:00:45"
         },
         {
             "name": "sebastian/exporter",
@@ -1061,17 +1170,17 @@
         },
         {
             "name": "symfony/yaml",
-            "version": "dev-master",
+            "version": "2.7.x-dev",
             "target-dir": "Symfony/Component/Yaml",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/Yaml.git",
-                "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a"
+                "reference": "6165f4b5224c22de2873deb6a3a4e622044f0705"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Yaml/zipball/499f7d7aa96747ad97940089bd7a1fb24ad8182a",
-                "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a",
+                "url": "https://api.github.com/repos/symfony/Yaml/zipball/6165f4b5224c22de2873deb6a3a4e622044f0705",
+                "reference": "6165f4b5224c22de2873deb6a3a4e622044f0705",
                 "shasum": ""
             },
             "require": {
@@ -1080,7 +1189,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "2.6-dev"
+                    "dev-master": "2.7-dev"
                 }
             },
             "autoload": {
@@ -1104,7 +1213,7 @@
             ],
             "description": "Symfony Yaml Component",
             "homepage": "http://symfony.com",
-            "time": "2014-10-05 13:53:50"
+            "time": "2014-11-10 18:00:54"
         }
     ],
     "aliases": [],

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Exception/BadRequestException.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Exception/BadRequestException.php b/sdks/php5/apache-usergrid/src/Api/Exception/BadRequestException.php
index c6a2453..1e63c40 100644
--- a/sdks/php5/apache-usergrid/src/Api/Exception/BadRequestException.php
+++ b/sdks/php5/apache-usergrid/src/Api/Exception/BadRequestException.php
@@ -28,6 +28,7 @@ namespace Apache\Usergrid\Api\Exception;
  * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
  * @link       http://baas-platform.com
  */
-class BadRequestException extends UsergridException{
+class BadRequestException extends UsergridException
+{
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Exception/NotFoundException.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Exception/NotFoundException.php b/sdks/php5/apache-usergrid/src/Api/Exception/NotFoundException.php
index a13277b..c371538 100644
--- a/sdks/php5/apache-usergrid/src/Api/Exception/NotFoundException.php
+++ b/sdks/php5/apache-usergrid/src/Api/Exception/NotFoundException.php
@@ -27,6 +27,7 @@ namespace Apache\Usergrid\Api\Exception;
  * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
  * @link       http://baas-platform.com
  */
-class NotFoundException extends UsergridException {
+class NotFoundException extends UsergridException
+{
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Exception/ServerErrorException.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Exception/ServerErrorException.php b/sdks/php5/apache-usergrid/src/Api/Exception/ServerErrorException.php
index 2525e12..2286133 100644
--- a/sdks/php5/apache-usergrid/src/Api/Exception/ServerErrorException.php
+++ b/sdks/php5/apache-usergrid/src/Api/Exception/ServerErrorException.php
@@ -27,6 +27,7 @@ namespace Apache\Usergrid\Api\Exception;
  * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
  * @link       http://baas-platform.com
  */
-class ServerErrorException extends UsergridException {
+class ServerErrorException extends UsergridException
+{
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Exception/UnauthorizedException.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Exception/UnauthorizedException.php b/sdks/php5/apache-usergrid/src/Api/Exception/UnauthorizedException.php
index d7d3694..3e3ae41 100644
--- a/sdks/php5/apache-usergrid/src/Api/Exception/UnauthorizedException.php
+++ b/sdks/php5/apache-usergrid/src/Api/Exception/UnauthorizedException.php
@@ -28,6 +28,7 @@ namespace Apache\Usergrid\Api\Exception;
  * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
  * @link       http://baas-platform.com
  */
-class UnauthorizedException extends UsergridException {
+class UnauthorizedException extends UsergridException
+{
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Exception/UsergridException.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Exception/UsergridException.php b/sdks/php5/apache-usergrid/src/Api/Exception/UsergridException.php
index 4c6057f..8aedb03 100644
--- a/sdks/php5/apache-usergrid/src/Api/Exception/UsergridException.php
+++ b/sdks/php5/apache-usergrid/src/Api/Exception/UsergridException.php
@@ -68,14 +68,11 @@ class UsergridException extends Exception implements ErrorResponseExceptionInter
 
         $message = array_get($errors, 'error.message', null);
 
-        $class = '\\Apache\\Usergrid\\Api\\Exception\\'.studly_case($type).'Exception';
+        $class = '\\Apache\\Usergrid\\Api\\Exception\\' . studly_case($type) . 'Exception';
 
-        if (class_exists($class))
-        {
+        if (class_exists($class)) {
             $exception = new $class($message, $response->getStatusCode());
-        }
-        else
-        {
+        } else {
             $exception = new static($message, $response->getStatusCode());
         }
 
@@ -101,7 +98,7 @@ class UsergridException extends Exception implements ErrorResponseExceptionInter
     /**
      * Sets the Guzzle request.
      *
-     * @param  \Guzzle\Http\Message\Request  $request
+     * @param  \Guzzle\Http\Message\Request $request
      * @return void
      */
     public function setRequest(Request $request)
@@ -122,7 +119,7 @@ class UsergridException extends Exception implements ErrorResponseExceptionInter
     /**
      * Sets the Guzzle response.
      *
-     * @param  \Guzzle\Http\Message\Response  $response
+     * @param  \Guzzle\Http\Message\Response $response
      * @return void
      */
     public function setResponse(Response $response)
@@ -143,7 +140,7 @@ class UsergridException extends Exception implements ErrorResponseExceptionInter
     /**
      * Sets the error type returned by Usergrid.
      *
-     * @param  string  $errorType
+     * @param  string $errorType
      * @return void
      */
     public function setErrorType($errorType)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/BaseCollection.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/BaseCollection.php b/sdks/php5/apache-usergrid/src/Api/Models/BaseCollection.php
index 9384fde..4cc7d67 100644
--- a/sdks/php5/apache-usergrid/src/Api/Models/BaseCollection.php
+++ b/sdks/php5/apache-usergrid/src/Api/Models/BaseCollection.php
@@ -17,7 +17,7 @@
 namespace Apache\Usergrid\Api\Models;
 
 
-use  Apache\Usergrid\Api\Usergrid;
+use Apache\Usergrid\Api\Usergrid;
 use Illuminate\Support\Collection;
 
 /**
@@ -48,28 +48,6 @@ class BaseCollection extends Collection
     protected $apiClient;
 
     /**
-     * Returns the Usergrid API client instance.
-     *
-     * @return  /Apache\Usergrid\Api\Usergrid  /Apache\Usergrid\Api\Usergrid
-     */
-    public function getApiClient()
-    {
-        return $this->apiClient;
-    }
-
-    /**
-     * Sets the Usergrid API client instance.
-     *
-     * @param Usergrid $client
-     * @internal param $ /Apache\Usergrid\Api\Usergrid $client
-     * @return void
-     */
-    public function setApiClient(Usergrid $client)
-    {
-        $this->apiClient = $client;
-    }
-
-    /**
      * Returns the given key value from the collection.
      *
      * @param  mixed $key
@@ -87,14 +65,52 @@ class BaseCollection extends Collection
             } else {
                 $data = $this->get($key, []);
             }
+            // create a new class of self so subclasses get new collection from entities of the correct model
+            // eg: before when asking  the User Model for its entities returned a collection of the BaseCollection class not the user class..
+            $class = self::instance($data);
+            //set the api client on collection so api attribute properties can make api calls to get related models
+            $class->setApiClient($this->getApiClient());
+            // return class.
+            return $class;
 
-            return new Collection($data);
         }
-
+        // check to see if the property you asked for is a attribute method
         if (method_exists($this, $method = "{$key}Attribute")) {
             return $this->{$method}($this->get($key));
         }
 
+        //else return key
         return $this->get($key, null);
     }
+
+    /**
+     * @param $data
+     * @return static
+     */
+    private static function instance($data)
+    {
+        return new static($data);
+    }
+
+    /**
+     * Returns the Usergrid API client instance.
+     *
+     * @return  /Apache\Usergrid\Api\Usergrid  /Apache\Usergrid\Api\Usergrid
+     */
+    public function getApiClient()
+    {
+        return $this->apiClient;
+    }
+
+    /**
+     * Sets the Usergrid API client instance.
+     *
+     * @param Usergrid $client
+     * @internal param $ /Apache\Usergrid\Api\Usergrid $client
+     * @return void
+     */
+    public function setApiClient(Usergrid $client)
+    {
+        $this->apiClient = $client;
+    }
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Device.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Device.php b/sdks/php5/apache-usergrid/src/Api/Models/Device.php
index 4949ffe..403ff8d 100644
--- a/sdks/php5/apache-usergrid/src/Api/Models/Device.php
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Device.php
@@ -33,7 +33,18 @@ class Device extends BaseCollection implements ResponseClassInterface
 {
     use GuzzleCommandTrait;
 
-
-
+    public function userAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'devices',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'users'
+        ])->toArray();
+    }
+
+    public function notifierAttribute()
+    {
+
+    }
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Group.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Group.php b/sdks/php5/apache-usergrid/src/Api/Models/Group.php
new file mode 100644
index 0000000..6b034ca
--- /dev/null
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Group.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Api\Models;
+
+
+use Guzzle\Service\Command\ResponseClassInterface;
+
+/**
+ * Class Group
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <ja...@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class Group extends BaseCollection implements ResponseClassInterface
+{
+
+    use GuzzleCommandTrait;
+
+    public function usersAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'groups',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'users'
+        ])->toArray();
+    }
+
+    public function rolesAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'groups',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'roles'
+        ])->toArray();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/GuzzleCommandTrait.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/GuzzleCommandTrait.php b/sdks/php5/apache-usergrid/src/Api/Models/GuzzleCommandTrait.php
index f8bd6fa..e6ccb68 100644
--- a/sdks/php5/apache-usergrid/src/Api/Models/GuzzleCommandTrait.php
+++ b/sdks/php5/apache-usergrid/src/Api/Models/GuzzleCommandTrait.php
@@ -47,4 +47,13 @@ trait GuzzleCommandTrait
         // Return the collection
         return $collection;
     }
+
+    /**
+     *  Returns true if there is a cursor or false if there is not
+     * @return bool
+     */
+    public function hasNextPage()
+    {
+        return $this->has('cursor');
+    }
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Notifier.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Notifier.php b/sdks/php5/apache-usergrid/src/Api/Models/Notifier.php
new file mode 100644
index 0000000..a4c21c8
--- /dev/null
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Notifier.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Api\Models;
+
+
+use Guzzle\Service\Command\ResponseClassInterface;
+
+/**
+ * Class Application
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <ja...@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class Notifier extends BaseCollection implements ResponseClassInterface
+{
+    use GuzzleCommandTrait;
+
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Organization.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Organization.php b/sdks/php5/apache-usergrid/src/Api/Models/Organization.php
index adf9833..d58d3d4 100644
--- a/sdks/php5/apache-usergrid/src/Api/Models/Organization.php
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Organization.php
@@ -34,27 +34,5 @@ class Organization extends BaseCollection implements ResponseClassInterface
 
     use GuzzleCommandTrait;
 
-    /**
-     * @var
-     */
-    protected $name;
 
-    /**
-     *  Collection Applications
-     *
-     * @var \Apache\Usergrid\Api\Models\Application $properties
-     */
-    protected $applications;
-
-    /** Organization UUID
-     * @var UUID $uuid
-     */
-    protected $uuid;
-
-
-    /**
-     *
-     * @var Array $properties
-     */
-    protected $properties = array();
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Receipt.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Receipt.php b/sdks/php5/apache-usergrid/src/Api/Models/Receipt.php
new file mode 100644
index 0000000..bc09235
--- /dev/null
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Receipt.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Api\Models;
+
+
+use Guzzle\Service\Command\ResponseClassInterface;
+
+/**
+ * Class Application
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <ja...@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class Receipt extends BaseCollection implements ResponseClassInterface
+{
+    use GuzzleCommandTrait;
+
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/Role.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/Role.php b/sdks/php5/apache-usergrid/src/Api/Models/Role.php
new file mode 100644
index 0000000..3e93465
--- /dev/null
+++ b/sdks/php5/apache-usergrid/src/Api/Models/Role.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Api\Models;
+
+
+use Guzzle\Service\Command\ResponseClassInterface;
+
+/**
+ * Class Role
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <ja...@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class Role extends BaseCollection implements ResponseClassInterface
+{
+
+    use GuzzleCommandTrait;
+
+    public function usersAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'roles',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'users'
+        ])->toArray();
+    }
+
+    public function groupsAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'roles',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'groups'
+        ])->toArray();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Models/User.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Models/User.php b/sdks/php5/apache-usergrid/src/Api/Models/User.php
index d8ddd81..8bec6d3 100644
--- a/sdks/php5/apache-usergrid/src/Api/Models/User.php
+++ b/sdks/php5/apache-usergrid/src/Api/Models/User.php
@@ -34,4 +34,44 @@ class User extends BaseCollection implements ResponseClassInterface
 
     use GuzzleCommandTrait;
 
-} 
\ No newline at end of file
+    public function deviceAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'users',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'devices'
+        ])->toArray();
+    }
+
+    public function notificationAttribute()
+    {
+
+    }
+
+    public function groupsAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'users',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'groups'
+        ])->toArray();
+    }
+
+    public function rolesAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'users',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'roles'
+        ])->toArray();
+    }
+
+    public function connectionsAttribute()
+    {
+        return $this->getApiClient()->application()->GetRelationship([
+            'collection' => 'users',
+            'entity_id' => $this->entities->fetch('uuid')->first(),
+            'relationship' => 'connections'
+        ])->toArray();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/QueryAggregator.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/QueryAggregator.php b/sdks/php5/apache-usergrid/src/Api/QueryAggregator.php
index f1362a7..eacfcd5 100644
--- a/sdks/php5/apache-usergrid/src/Api/QueryAggregator.php
+++ b/sdks/php5/apache-usergrid/src/Api/QueryAggregator.php
@@ -17,8 +17,8 @@
 namespace Apache\Usergrid\Api;
 
 
-use Guzzle\Http\QueryString;
 use Guzzle\Http\QueryAggregator\QueryAggregatorInterface;
+use Guzzle\Http\QueryString;
 
 /**
  * Class QueryAggregator

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/ResourceIterator.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/ResourceIterator.php b/sdks/php5/apache-usergrid/src/Api/ResourceIterator.php
index 7926d08..7df0dd7 100644
--- a/sdks/php5/apache-usergrid/src/Api/ResourceIterator.php
+++ b/sdks/php5/apache-usergrid/src/Api/ResourceIterator.php
@@ -66,4 +66,4 @@ class ResourceIterator extends BaseIterator
         return $data;
     }
 
-} 
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Api/Usergrid.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Api/Usergrid.php b/sdks/php5/apache-usergrid/src/Api/Usergrid.php
index 3353630..279f2b2 100644
--- a/sdks/php5/apache-usergrid/src/Api/Usergrid.php
+++ b/sdks/php5/apache-usergrid/src/Api/Usergrid.php
@@ -19,9 +19,9 @@ namespace Apache\Usergrid\Api;
 
 use Apache\Usergrid\Guzzle\Plugin\Oauth2\Oauth2Plugin;
 use Guzzle\Common\Event;
-use InvalidArgumentException;
-use Guzzle\Service\Description\ServiceDescription;
 use Guzzle\Plugin\ErrorResponse\ErrorResponsePlugin;
+use Guzzle\Service\Description\ServiceDescription;
+use InvalidArgumentException;
 
 /**
  * Class Usergrid
@@ -42,9 +42,9 @@ class Usergrid
      */
     protected $token;
 
+
     /**
-     *  Grant Type Client Id or password
-     * @var
+     * @var \Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\GrantTypeInterface
      */
     protected $grantType;
     /**
@@ -52,7 +52,7 @@ class Usergrid
      *
      * @var string
      */
-    protected $version = '1.0.0';
+    protected $version = '1.0.1';
     /**
      * The manifests path.
      *
@@ -72,24 +72,6 @@ class Usergrid
      */
     protected $oauth2_plugin;
     /**
-     * @return string
-     */
-    public function getManifestPath()
-    {
-        return $this->manifestPath;
-    }
-
-    /**
-     * @param string $manifestPath
-     * @return $this
-     */
-    public function setManifestPath($manifestPath)
-    {
-        $this->manifestPath = $manifestPath;
-        return $this;
-    }
-
-    /**
      * The cached manifests data.
      *
      * @var array
@@ -101,14 +83,12 @@ class Usergrid
      * @var string
      */
     protected $userAgent = 'BaaS-Usergrid/1.0.0';
-
     /**
      * The headers to be sent to the Guzzle client.
      *
      * @var array
      */
     protected $headers = [];
-
     private $org_name;
     private $app_name;
 
@@ -120,8 +100,14 @@ class Usergrid
      * @param $baseUrl
      * @param Oauth2Plugin $oauth2_plugin
      */
-    function __construct($orgName = null, $appName = null, $manifestPath, $version, $baseUrl, Oauth2Plugin $oauth2_plugin = null)
-    {
+    function __construct(
+        $orgName = null,
+        $appName = null,
+        $manifestPath,
+        $version,
+        $baseUrl,
+        Oauth2Plugin $oauth2_plugin = null
+    ) {
         //Set Version so its added to header
         $this->setVersion($version ?: $this->version);
 
@@ -131,76 +117,21 @@ class Usergrid
         $this->app_name = $appName;
 
         //check if OAuth2 plugin is enabled
-        if($oauth2_plugin != null){
+        if ($oauth2_plugin != null) {
             $this->oauth2_plugin = $oauth2_plugin;
+            $this->grantType = $this->oauth2_plugin->getGrantType();
         }
 
         // Set the manifest path
-        $this->setManifestPath($manifestPath ?: dirname(dirname(__FILE__)).'/Manifests');
-    }
-
-    /**
-     * Returns the Guzzle client headers.
-     *
-     * @return array
-     */
-    public function getHeaders()
-    {
-        return $this->headers;
-    }
-
-    /**
-     * Sets the Guzzle client headers.
-     *
-     * @param  array $headers
-     * @return $this
-     */
-    public function setHeaders(array $headers = [])
-    {
-        $this->headers = array_merge($this->headers, $headers);
-
-        return $this;
-    }
-
-    /**
-     * @return string
-     */
-    public function getVersion()
-    {
-        return $this->version;
-    }
-
-    /**
-     * @param string $version
-     * @return $this
-     */
-    public function setVersion($version)
-    {
-        $this->version = $version;
-
-        $this->setHeaders([
-            'Usergrid-Version' => (string)$version,
-        ]);
-        return $this;
-    }
-
-    /**
-     * @return string
-     */
-    public function getUserAgent()
-    {
-        return $this->userAgent;
+        $this->setManifestPath($manifestPath ?: dirname(dirname(__FILE__)) . '/Manifests');
     }
 
     /**
-     * @param string $userAgent
-     * @return $this
+     * @return mixed
      */
-    public function setUserAgent($userAgent)
+    public function getToken()
     {
-        $this->userAgent = $userAgent;
-
-        return $this;
+        return $this->token;
     }
 
     /**
@@ -219,14 +150,6 @@ class Usergrid
     }
 
     /**
-     * @return mixed
-     */
-    public function getToken()
-    {
-        return $this->token;
-    }
-
-    /**
      * Dynamically handle missing methods.
      *
      * @param  string $method
@@ -245,56 +168,6 @@ class Usergrid
     }
 
     /**
-     * Determines if the request is a single request.
-     *
-     * @return bool
-     */
-    protected function isSingleRequest($method)
-    {
-        return (str_singular($method) === $method && $this->manifestExists(str_plural($method)));
-    }
-
-    /**
-     * Handles a single request.
-     *
-     * @param  string $method
-     * @param  array $arguments
-     * @return \Guzzle\Service\Client
-     * @throws \InvalidArgumentException
-     */
-    protected function handleSingleRequest($method, array $arguments = [])
-    {
-        // Check if we have any arguments
-        if (empty($arguments)) {
-            throw new InvalidArgumentException('Not enough arguments provided!');
-        }
-
-        // Pluralize the method name
-        $pluralMethod = str_plural($method);
-
-        // Get the request manifest payload data
-        $manifest = $this->getRequestManifestPayload($pluralMethod);
-
-        if (!$parameters = array_get($manifest, 'find')) {
-            throw new InvalidArgumentException("Undefined method [{$method}] called.");;
-        }
-
-        // Get the required parameters for the request
-        $required = array_where(array_get($parameters, 'parameters'), function ($key, $value) {
-            return $value['required'] === true;
-        });
-
-        // Prepare the arguments for the request
-        $arguments = array_combine(
-            array_keys($required),
-            count($required) === 1 ? (array)$arguments[0] : $arguments
-        );
-
-        // Execute the request
-        return $this->handleRequest($pluralMethod)->find($arguments);
-    }
-
-    /**
      * Handles an iterator request.
      *
      * @param  string $method
@@ -325,7 +198,8 @@ class Usergrid
         }
 
         // Initialize the Guzzle client
-        $client = new GuzzleClient('',['command.params' => ['app_name_or_uuid' => $this->app_name, 'org_name_or_uuid' => $this->org_name]]);
+        $client = new GuzzleClient('',
+            ['command.params' => ['app_name_or_uuid' => $this->app_name, 'org_name_or_uuid' => $this->org_name]]);
 
         // Set our own usergrid api client for internal
         // usage within our api models.
@@ -352,7 +226,7 @@ class Usergrid
         });
 
         //check if Oauth 2 plugin is a instance of Oauth2Plugin
-        if($this->oauth2_plugin instanceof Oauth2Plugin) {
+        if ($this->oauth2_plugin instanceof Oauth2Plugin) {
             $dispatcher->addSubscriber($this->oauth2_plugin);
         }
 
@@ -367,13 +241,14 @@ class Usergrid
     }
 
     /**
-     * Returns the full versioned manifests path.
+     * Checks if the manifest file for the current request exists.
      *
-     * @return string
+     * @param  string $file
+     * @return bool
      */
-    protected function getFullManifestPath()
+    protected function manifestExists($file)
     {
-        return $this->getManifestPath() . '/' . $this->getVersion();
+        return file_exists($this->getManifestFilePath($file));
     }
 
     /**
@@ -388,6 +263,98 @@ class Usergrid
     }
 
     /**
+     * Returns the full versioned manifests path.
+     *
+     * @return string
+     */
+    protected function getFullManifestPath()
+    {
+        return $this->getManifestPath() . '/' . $this->getVersion();
+    }
+
+    /**
+     * @return string
+     */
+    public function getManifestPath()
+    {
+        return $this->manifestPath;
+    }
+
+    /**
+     * @param string $manifestPath
+     * @return $this
+     */
+    public function setManifestPath($manifestPath)
+    {
+        $this->manifestPath = $manifestPath;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getVersion()
+    {
+        return $this->version;
+    }
+
+    /**
+     * @param string $version
+     * @return $this
+     */
+    public function setVersion($version)
+    {
+        $this->version = $version;
+
+        $this->setHeaders([
+            'Usergrid-Version' => (string)$version,
+        ]);
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getUserAgent()
+    {
+        return $this->userAgent;
+    }
+
+    /**
+     * @param string $userAgent
+     * @return $this
+     */
+    public function setUserAgent($userAgent)
+    {
+        $this->userAgent = $userAgent;
+
+        return $this;
+    }
+
+    /**
+     * Returns the Guzzle client headers.
+     *
+     * @return array
+     */
+    public function getHeaders()
+    {
+        return $this->headers;
+    }
+
+    /**
+     * Sets the Guzzle client headers.
+     *
+     * @param  array $headers
+     * @return $this
+     */
+    public function setHeaders(array $headers = [])
+    {
+        $this->headers = array_merge($this->headers, $headers);
+
+        return $this;
+    }
+
+    /**
      * Returns the current request payload.
      *
      * @param  string $method
@@ -432,14 +399,54 @@ class Usergrid
     }
 
     /**
-     * Checks if the manifest file for the current request exists.
+     * Determines if the request is a single request.
      *
-     * @param  string $file
+     * @param $method
      * @return bool
      */
-    protected function manifestExists($file)
+    protected function isSingleRequest($method)
     {
-        return file_exists($this->getManifestFilePath($file));
+        return (str_singular($method) === $method && $this->manifestExists(str_plural($method)));
+    }
+
+    /**
+     * Handles a single request.
+     *
+     * @param  string $method
+     * @param  array $arguments
+     * @return \Guzzle\Service\Client
+     * @throws \InvalidArgumentException
+     */
+    protected function handleSingleRequest($method, array $arguments = [])
+    {
+        // Check if we have any arguments
+        if (empty($arguments)) {
+            throw new InvalidArgumentException('Not enough arguments provided!');
+        }
+
+        // Pluralize the method name
+        $pluralMethod = str_plural($method);
+
+        // Get the request manifest payload data
+        $manifest = $this->getRequestManifestPayload($pluralMethod);
+
+        if (!$parameters = array_get($manifest, 'find')) {
+            throw new InvalidArgumentException("Undefined method [{$method}] called.");;
+        }
+
+        // Get the required parameters for the request
+        $required = array_where(array_get($parameters, 'parameters'), function ($key, $value) {
+            return $value['required'] === true;
+        });
+
+        // Prepare the arguments for the request
+        $arguments = array_combine(
+            array_keys($required),
+            count($required) === 1 ? (array)$arguments[0] : $arguments
+        );
+
+        // Execute the request
+        return $this->handleRequest($pluralMethod)->find($arguments);
     }
 
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php
index 0a31df6..b03d4a7 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php
@@ -18,7 +18,6 @@ namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType;
 
 use Guzzle\Common\Collection;
 use Guzzle\Http\ClientInterface;
-use Guzzle\Http\Exception\RequestException;
 
 /**
  * Authorization code grant type.
@@ -47,7 +46,8 @@ class AuthorizationCode implements GrantTypeInterface
             'scope' => '',
             'redirect_uri' => '',
         ), array(
-            'client_id', 'code',
+            'client_id',
+            'code',
         ));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php
index bec4968..729f6a5 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php
@@ -18,7 +18,6 @@ namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType;
 
 use Guzzle\Common\Collection;
 use Guzzle\Http\ClientInterface;
-use Guzzle\Http\Exception\RequestException;
 
 /**
  * Client credentials grant type.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php
index c0d3713..f30d593 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php
@@ -16,8 +16,8 @@
 
 namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType;
 
-use Symfony\Component\Security\Core\SecurityContextInterface;
 use HWI\Bundle\OAuthBundle\Security\Http\ResourceOwnerMap;
+use Symfony\Component\Security\Core\SecurityContextInterface;
 
 /**
  * HWIOAuthBundle Aware Refresh token grant type.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php
index 44cf77b..6afc482 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php
@@ -17,7 +17,6 @@ namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType;
 
 use Guzzle\Common\Collection;
 use Guzzle\Http\ClientInterface;
-use Guzzle\Http\Exception\RequestException;
 
 /**
  * Resource owner password credentials grant type.
@@ -45,7 +44,9 @@ class PasswordCredentials implements GrantTypeInterface
             'client_secret' => '',
             'scope' => '',
         ), array(
-            'client_id', 'username', 'password'
+            'client_id',
+            'username',
+            'password'
         ));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php
index 10999b2..149d570 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php
@@ -17,7 +17,6 @@ namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType;
 
 use Guzzle\Common\Collection;
 use Guzzle\Http\ClientInterface;
-use Guzzle\Http\Exception\RequestException;
 
 /**
  * Refresh token grant type.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ffe2b0d/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php
index e5671f5..8454309 100755
--- a/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php
+++ b/sdks/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php
@@ -84,34 +84,6 @@ class Oauth2Plugin implements EventSubscriberInterface
     }
 
     /**
-     * Request error event handler.
-     *
-     * Handles unauthorized errors by acquiring a new access token and
-     * retrying the request.
-     *
-     * @param Event $event Event received
-     */
-    public function onRequestError(Event $event)
-    {
-        if ($event['response']->getStatusCode() == 401) {
-            if ($event['request']->getHeader('X-Guzzle-Retry')) {
-                // We already retried once, give up.
-                return;
-            }
-
-            // Acquire a new access token, and retry the request.
-            $newAccessToken = $this->acquireAccessToken();
-            if ($newAccessToken) {
-                $newRequest = clone $event['request'];
-                $newRequest->setHeader('Authorization', 'Bearer ' . $newAccessToken['access_token']);
-                $newRequest->setHeader('X-Guzzle-Retry', '1');
-                $event['response'] = $newRequest->send();
-                $event->stopPropagation();
-            }
-        }
-    }
-
-    /**
      * Get the access token.
      *
      * Handles token expiration for tokens with an "expires" timestamp.
@@ -144,26 +116,6 @@ class Oauth2Plugin implements EventSubscriberInterface
     }
 
     /**
-     * Get the refresh token.
-     *
-     * @return string
-     */
-    public function getRefreshToken()
-    {
-        return $this->refreshToken;
-    }
-
-    /**
-     * Set the refresh token.
-     *
-     * @param string $refreshToken The refresh token
-     */
-    public function setRefreshToken($refreshToken)
-    {
-        $this->refreshToken = $refreshToken;
-    }
-
-    /**
      * Acquire a new access token from the server.
      *
      * @return array|null
@@ -201,4 +153,60 @@ class Oauth2Plugin implements EventSubscriberInterface
 
         return $this->accessToken;
     }
+
+    /**
+     * Request error event handler.
+     *
+     * Handles unauthorized errors by acquiring a new access token and
+     * retrying the request.
+     *
+     * @param Event $event Event received
+     */
+    public function onRequestError(Event $event)
+    {
+        if ($event['response']->getStatusCode() == 401) {
+            if ($event['request']->getHeader('X-Guzzle-Retry')) {
+                // We already retried once, give up.
+                return;
+            }
+
+            // Acquire a new access token, and retry the request.
+            $newAccessToken = $this->acquireAccessToken();
+            if ($newAccessToken) {
+                $newRequest = clone $event['request'];
+                $newRequest->setHeader('Authorization', 'Bearer ' . $newAccessToken['access_token']);
+                $newRequest->setHeader('X-Guzzle-Retry', '1');
+                $event['response'] = $newRequest->send();
+                $event->stopPropagation();
+            }
+        }
+    }
+
+    /**
+     * Get the refresh token.
+     *
+     * @return string
+     */
+    public function getRefreshToken()
+    {
+        return $this->refreshToken;
+    }
+
+    /**
+     * Set the refresh token.
+     *
+     * @param string $refreshToken The refresh token
+     */
+    public function setRefreshToken($refreshToken)
+    {
+        $this->refreshToken = $refreshToken;
+    }
+
+    /**
+     * @return GrantTypeInterface
+     */
+    public function getGrantType()
+    {
+        return $this->grantType;
+    }
 }