All files / src client.js

90% Statements 9/10
100% Branches 0/0
83.33% Functions 5/6
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1x   1x   1x 1x       8x 8x       8x     8x   8x                
'use strict';
var soap = require('soap');
 
module.exports = class {
    constructor(appKey, appSecret) {
        this.appKey = appKey;
        this.appSecret = appSecret;
    }
 
    call(url, function_name, payload) {
        return new Promise((resolve, reject) => {
            payload.auth = {
                appKey: this.appKey,
                appSecret: this.appSecret
            }
            soap.createClientAsync(url, {
                    attributesKey: '$attr'
                }).then((client) => {
                    return client[function_name + 'Async'](payload).then((result) => {
            
                        resolve(result);
                    });
                })
                .catch(err => {
                    reject(err);
                });
        })
    }
}