From cc4ce0b629adb2af4c4a29c914aee4f03205c908 Mon Sep 17 00:00:00 2001 From: Yevhen Blotskyi Date: Thu, 14 May 2020 11:30:59 +0200 Subject: [PATCH 1/3] Enable sending multiple subscribers in one request This change allows setting the props for the subscriber object as an object or array. If it is set as an array, you can send multiple subscribers in one request. --- lib/fuel-soap.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/fuel-soap.js b/lib/fuel-soap.js index c5e9cb6..bd7807f 100644 --- a/lib/fuel-soap.js +++ b/lib/fuel-soap.js @@ -162,6 +162,12 @@ FuelSoap.prototype.create = function(type, props, options, callback) { options = null; } + if (Array.isArray(props)) { + props.forEach(item => item.$ = { 'xsi:type': type }) + } else { + props.$ = { 'xsi:type': type }; + } + reqOptions = helpers.parseReqOptions(options); body = { CreateRequest: { @@ -173,8 +179,6 @@ FuelSoap.prototype.create = function(type, props, options, callback) { } }; - body.CreateRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.CreateRequest, 'Options'); this.soapRequest({ @@ -305,6 +309,12 @@ FuelSoap.prototype.update = function(type, props, options, callback) { options = null; } + if (Array.isArray(props)) { + props.forEach(item => item.$ = { 'xsi:type': type }) + } else { + props.$ = { 'xsi:type': type }; + } + reqOptions = helpers.parseReqOptions(options); body = { UpdateRequest: { @@ -316,8 +326,6 @@ FuelSoap.prototype.update = function(type, props, options, callback) { } }; - body.UpdateRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.UpdateRequest, 'Options'); this.soapRequest({ From 3beb65399740e54ec23f5c1acb4e2b454ced23e2 Mon Sep 17 00:00:00 2001 From: Yevhen Blotskyi Date: Thu, 14 May 2020 11:30:59 +0200 Subject: [PATCH 2/3] Enable sending multiple subscribers in one request This change allows setting the props for the subscriber object as an object or array. If it is set as an array, you can send multiple subscribers in one request. --- lib/fuel-soap.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/fuel-soap.js b/lib/fuel-soap.js index c5e9cb6..4b640dc 100644 --- a/lib/fuel-soap.js +++ b/lib/fuel-soap.js @@ -162,6 +162,12 @@ FuelSoap.prototype.create = function(type, props, options, callback) { options = null; } + if (Array.isArray(props)) { + props.forEach(item => item.$ = { 'xsi:type': type }); + } else { + props.$ = { 'xsi:type': type }; + } + reqOptions = helpers.parseReqOptions(options); body = { CreateRequest: { @@ -173,8 +179,6 @@ FuelSoap.prototype.create = function(type, props, options, callback) { } }; - body.CreateRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.CreateRequest, 'Options'); this.soapRequest({ @@ -305,6 +309,12 @@ FuelSoap.prototype.update = function(type, props, options, callback) { options = null; } + if (Array.isArray(props)) { + props.forEach(item => item.$ = { 'xsi:type': type }); + } else { + props.$ = { 'xsi:type': type }; + } + reqOptions = helpers.parseReqOptions(options); body = { UpdateRequest: { @@ -316,8 +326,6 @@ FuelSoap.prototype.update = function(type, props, options, callback) { } }; - body.UpdateRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.UpdateRequest, 'Options'); this.soapRequest({ From a79c5a1dd17bf168c7731f224d96f9e42dace953 Mon Sep 17 00:00:00 2001 From: Yevhen Blotskyi Date: Tue, 2 Jun 2020 08:30:29 +0200 Subject: [PATCH 3/3] Enable deletion of multiple objects --- lib/fuel-soap.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fuel-soap.js b/lib/fuel-soap.js index 4b640dc..f6844c2 100644 --- a/lib/fuel-soap.js +++ b/lib/fuel-soap.js @@ -362,6 +362,12 @@ FuelSoap.prototype.delete = function(type, props, options, callback) { options = null; } + if (Array.isArray(props)) { + props.forEach(item => item.$ = { 'xsi:type': type }); + } else { + props.$ = { 'xsi:type': type }; + } + reqOptions = helpers.parseReqOptions(options); body = { DeleteRequest: { @@ -373,8 +379,6 @@ FuelSoap.prototype.delete = function(type, props, options, callback) { } }; - body.DeleteRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.DeleteRequest, 'Options'); this.soapRequest({