const NotFoundError = require('vn-loopback/util/not-found-error');

module.exports = Self => {
    Self.remoteMethod('test', {
        description: 'Tests connector configuration',
        http: {
            path: `/test`,
            verb: 'GET'
        }
    });

    Self.test = async function() {
        const connector = await Self.getLinker();
        if (!connector) throw new NotFoundError('Linker not configured');
        await connector.test();
    };
};