From 6c32bf86d30727f927df38804a702ba1e0989738 Mon Sep 17 00:00:00 2001 From: Damien Pobel Date: Wed, 12 Oct 2016 07:56:45 +0200 Subject: [PATCH 1/2] EZP-26309: Added the ability to set custom headers when loading user's drafts --- src/services/ContentService.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/ContentService.js b/src/services/ContentService.js index 1821905..7193515 100644 --- a/src/services/ContentService.js +++ b/src/services/ContentService.js @@ -565,15 +565,21 @@ define(["structures/ContentCreateStruct", "structures/ContentUpdateStruct", "str * * @method loadUserDrafts * @param userId {String} target user identifier (e.g. "/api/ezp/v2/user/users/14") + * @parma [headers] {Object} additional headers * @param callback {Function} callback executed after performing the request (see * {{#crossLink "ContentService"}} Note on the callbacks usage{{/crossLink}} for more info) */ - ContentService.prototype.loadUserDrafts = function (userId, callback) { + ContentService.prototype.loadUserDrafts = function (userId, headers, callback) { + if ( !callback ) { + callback = headers; + headers = {}; + } + headers.Accept = "application/vnd.ez.api.VersionList+json"; this._connectionManager.request( "GET", userId + "/drafts", "", - {"Accept": "application/vnd.ez.api.VersionList+json"}, + headers, callback ); }; From 5f889a6e71b84fcfaac61bcc66d743b24dd6c987 Mon Sep 17 00:00:00 2001 From: Damien Pobel Date: Wed, 12 Oct 2016 07:58:05 +0200 Subject: [PATCH 2/2] EZP-26309: Added the ability to set custom header when loading versions --- src/services/ContentService.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/services/ContentService.js b/src/services/ContentService.js index 7193515..3c60510 100644 --- a/src/services/ContentService.js +++ b/src/services/ContentService.js @@ -674,12 +674,20 @@ define(["structures/ContentCreateStruct", "structures/ContentUpdateStruct", "str * * @method loadVersions * @param contentId {String} target content identifier (e.g. "/api/ezp/v2/content/objects/108") + * @param [headers] {Object} * @param callback {Function} callback executed after performing the request (see * {{#crossLink "ContentService"}}Note on the callbacks usage{{/crossLink}} for more info) */ - ContentService.prototype.loadVersions = function (contentId, callback) { + ContentService.prototype.loadVersions = function (contentId, headers, callback) { var that = this; + if ( !callback ) { + callback = headers; + headers = {}; + } + + // TODO instead of loading the content info and then the corresponding + // versions we could maybe use REST embedding here as well. this.loadContentInfo( contentId, function (error, contentResponse) { @@ -690,11 +698,12 @@ define(["structures/ContentCreateStruct", "structures/ContentUpdateStruct", "str var contentVersions = contentResponse.document.Content.Versions; + headers.Accept = contentVersions["_media-type"]; that._connectionManager.request( "GET", contentVersions._href, "", - {"Accept": contentVersions["_media-type"]}, + headers, callback ); }