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

Add multiple deletion #137

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

yebl
Copy link

@yebl yebl commented Jun 2, 2020

No description provided.

yebl and others added 4 commits May 14, 2020 11:30
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.
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.
Enable sending multiple subscribers in one request
@renatovico
Copy link

plz add this !

@colins44
Copy link

colins44 commented May 6, 2022

@yebl can this change be tested?

@renatovico
Copy link

Hi colins44 i have this monkeypatch implemented over 1 year, and working perfect:

client.SoapClient.soapRequestAsync = util.promisify(client.SoapClient.soapRequest);

    client.SoapClient.updateArray = async (type, props, options) => {
        const updateQueryAllAccounts = configureQueryAllAccounts(options);

        if (Array.isArray(props)) {
            // eslint-disable-next-line no-return-assign
            props.forEach(item => (item.$ = { 'xsi:type': type }));
        } else {
            props.$ = { 'xsi:type': type };
        }

        const reqOptions = helpers.parseReqOptions(options);
        const body = {
            UpdateRequest: {
                $: {
                    xmlns: 'http://exacttarget.com/wsdl/partnerAPI'
                },
                Options: options,
                Objects: props
            }
        };

        updateQueryAllAccounts(body.UpdateRequest, 'Options');

        try {
            const resp = await client.SoapClient.soapRequestAsync({
                action: 'Update',
                req: body,
                key: 'UpdateResponse',
                retry: true,
                reqOptions
            });

            if (lodash.get(resp, 'body.OverallStatus') === 'OK') {
                logger.notice('Request OK');
                // logger.debug(util.inspect(resp.res.request.body));
                // logger.debug(util.inspect(resp.body));
            } else {
                logger.error(util.inspect(resp), { props });
                logger.debug(JSON.stringify(body));
                // logger.error(props);
            }
        } catch (err) {
            if (err && err.results) {
                const errors = lodash.reject(err.results, { StatusCode: 'OK' });
                logger.error('sales force error integration', { errors });
                const valueErrors = lodash.get(errors, '0');
                if (valueErrors) {
                    logger.debug(util.inspect(valueErrors.Object.Properties));
                    logger.debug(util.inspect(valueErrors.ValueErrors));
                }
            } else {
                logger.error(util.inspect(err), { props });
                logger.debug(JSON.stringify(body));
            }

            // logger.error(props);
            // logger.error(err.results[0]);
        }
    };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants