Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Enable sending multiple subscribers in one request #136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions lib/fuel-soap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -173,8 +179,6 @@ FuelSoap.prototype.create = function(type, props, options, callback) {
}
};

body.CreateRequest.Objects.$ = { 'xsi:type': type };

updateQueryAllAccounts(body.CreateRequest, 'Options');

this.soapRequest({
Expand Down Expand Up @@ -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: {
Expand All @@ -316,8 +326,6 @@ FuelSoap.prototype.update = function(type, props, options, callback) {
}
};

body.UpdateRequest.Objects.$ = { 'xsi:type': type };

updateQueryAllAccounts(body.UpdateRequest, 'Options');

this.soapRequest({
Expand Down Expand Up @@ -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: {
Expand All @@ -365,8 +379,6 @@ FuelSoap.prototype.delete = function(type, props, options, callback) {
}
};

body.DeleteRequest.Objects.$ = { 'xsi:type': type };

updateQueryAllAccounts(body.DeleteRequest, 'Options');

this.soapRequest({
Expand Down