diff --git a/lib/fuel-soap.js b/lib/fuel-soap.js index c5e9cb6..f6844c2 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({ @@ -354,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: { @@ -365,8 +379,6 @@ FuelSoap.prototype.delete = function(type, props, options, callback) { } }; - body.DeleteRequest.Objects.$ = { 'xsi:type': type }; - updateQueryAllAccounts(body.DeleteRequest, 'Options'); this.soapRequest({