You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/19 20:21:53 UTC

[43/55] [abbrv] git commit: [DPS-865] Client will accept a 'default_qs' object with the options that will automatically populate the query string for each subsequent request. any query params passed directly to the request method will override these defa

[DPS-865] Client will accept a 'default_qs' object with the options that will automatically populate the query string for each subsequent request. any query params passed directly to the request method will override these defaults in the event of a conflict.


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

Branch: refs/pull/76/head
Commit: 00afe2c166956681c1c1145989ca9d83942b63f8
Parents: dee2ca9
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 13 09:08:24 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 13 10:28:48 2014 -0400

----------------------------------------------------------------------
 sdks/html5-javascript/lib/Usergrid.js       | 13 ++++++++++++-
 sdks/html5-javascript/lib/modules/Client.js | 10 ++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00afe2c1/sdks/html5-javascript/lib/Usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/Usergrid.js b/sdks/html5-javascript/lib/Usergrid.js
index a4dbe9b..2595e7c 100644
--- a/sdks/html5-javascript/lib/Usergrid.js
+++ b/sdks/html5-javascript/lib/Usergrid.js
@@ -40,7 +40,18 @@ function extend(subClass, superClass) {
     }
     return subClass;
 }
-
+function propCopy(from, to){
+    for(var prop in from){
+        if(from.hasOwnProperty(prop)){
+            if("object"===typeof from[prop] && "object"===typeof to[prop]){
+                to[prop]=propCopy(from[prop], to[prop]);
+            }else{
+                to[prop]=from[prop];
+            }
+        }
+    }
+    return to;
+}
 function NOOP(){}
 
 //Usergrid namespace encapsulates this SDK

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00afe2c1/sdks/html5-javascript/lib/modules/Client.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/modules/Client.js b/sdks/html5-javascript/lib/modules/Client.js
index 38db3b1..242b08b 100644
--- a/sdks/html5-javascript/lib/modules/Client.js
+++ b/sdks/html5-javascript/lib/modules/Client.js
@@ -12,7 +12,9 @@
     if (options.appName) {
       this.set('appName', options.appName);
     }
-
+    if(options.qs){
+      this.setObject('default_qs', options.qs);
+    }
     //other options
     this.buildCurl = options.buildCurl || false;
     this.logging = options.logging || false;
@@ -48,6 +50,7 @@
     var mQuery = options.mQuery || false; //is this a query to the management endpoint?
     var orgName = this.get('orgName');
     var appName = this.get('appName');
+    var default_qs=this.get('default_qs');
     var uri;
       var logoutCallback=function(){
           if (typeof(this.logoutCallback) === 'function') {
@@ -69,6 +72,9 @@
        xhr.withCredentials = true;
        */
     }
+    if(default_qs){
+      qs=propCopy(qs, default_qs);
+    }
       var req = new Usergrid.Request(method, uri, qs, body, function (err, response) {
           if ([
               "auth_expired_session_token",
@@ -238,7 +244,7 @@
    */
   Usergrid.Client.prototype.createCollection = function (options, callback) {
     options.client = this;
-    var collection = new Usergrid.Collection(options, function(err, data) {
+    new Usergrid.Collection(options, function(err, data, collection) {
         doCallback(callback, [err, collection, data]);
     });
   };