diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/common')
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/piwik-api.js | 11 | ||||
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/piwik-api.spec.js | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/piwik-api.js b/plugins/CoreHome/angularjs/common/services/piwik-api.js index aeed3bfe2c..ab6ee9c30d 100644 --- a/plugins/CoreHome/angularjs/common/services/piwik-api.js +++ b/plugins/CoreHome/angularjs/common/services/piwik-api.js @@ -249,10 +249,10 @@ var hasBlockedContent = false; getParams.module = getParams.module || 'API'; if (!getParams.format) { - getParams.format = 'JSON2'; + getParams.format = 'JSON'; } - addParams(getParams, 'GET'); + addParams(getParams); var promise = send(options); @@ -272,6 +272,12 @@ var hasBlockedContent = false; return fetch(getParams, options); } + function addPostParams(_postParams_) { + if (_postParams_) { + angular.merge(postParams, _postParams_); + } + } + /** * Convenience method that will perform a bulk request using Piwik's API.getBulkRequest method. * Bulk requests allow you to execute multiple Piwik requests with one HTTP request. @@ -319,6 +325,7 @@ var hasBlockedContent = false; bulkFetch: bulkFetch, post: post, fetch: fetch, + addPostParams: addPostParams, /** * @deprecated */ diff --git a/plugins/CoreHome/angularjs/common/services/piwik-api.spec.js b/plugins/CoreHome/angularjs/common/services/piwik-api.spec.js index 1faf387ea3..a51067ea46 100644 --- a/plugins/CoreHome/angularjs/common/services/piwik-api.spec.js +++ b/plugins/CoreHome/angularjs/common/services/piwik-api.spec.js @@ -55,7 +55,7 @@ piwikApi.fetch({ method: "SomePlugin.action" }).then(function (response) { - expect(response).to.equal("Request url: index.php?date=&format=JSON2&idSite=1&method=SomePlugin.action&module=API&period=day"); + expect(response).to.equal("Request url: index.php?date=&format=JSON&idSite=1&method=SomePlugin.action&module=API&period=day"); done(); }).catch(function (ex) { @@ -115,7 +115,7 @@ piwikApi.fetch({ method: "SomePlugin.action" }).then(function (response) { - expect(response).to.equal("Request url: index.php?date=&format=JSON2&idSite=1&method=SomePlugin.action&module=API&period=day"); + expect(response).to.equal("Request url: index.php?date=&format=JSON&idSite=1&method=SomePlugin.action&module=API&period=day"); request1Done = true; @@ -127,7 +127,7 @@ piwikApi.fetch({ method: "SomeOtherPlugin.action" }).then(function (response) { - expect(response).to.equal("Request url: index.php?date=&format=JSON2&idSite=1&method=SomeOtherPlugin.action&module=API&period=day"); + expect(response).to.equal("Request url: index.php?date=&format=JSON&idSite=1&method=SomeOtherPlugin.action&module=API&period=day"); request2Done = true; @@ -160,7 +160,7 @@ piwikApi.fetch({ method: "SomeOtherPlugin.action" }).then(function (response) { - expect(response).to.equal("Request url: index.php?date=&format=JSON2&idSite=1&method=SomeOtherPlugin.action&module=API&period=day"); + expect(response).to.equal("Request url: index.php?date=&format=JSON&idSite=1&method=SomeOtherPlugin.action&module=API&period=day"); request2Done = true; @@ -216,7 +216,7 @@ method: "SomeOtherPlugin.action" } ]).then(function (response) { - var restOfExpected = "index.php?date=&format=JSON2&idSite=1&method=API.getBulkRequest&" + + var restOfExpected = "index.php?date=&format=JSON&idSite=1&method=API.getBulkRequest&" + "module=API&period=day - urls%5B%5D=%3Fmethod%3DSomePlugin.action%26param%3D" + "value&urls%5B%5D=%3Fmethod%3DSomeOtherPlugin.action&token_auth=100bf5eeeed1468f3f9d93750044d3dd"; |