import axios from 'axios';
import { IntegrationAPI } from '../../IntegrationApi';
import { Protor } from './ProtorClass';

module.exports = (api: IntegrationAPI) => {
	api.registerAction('fadeIn', 'Fade in', require('./actions/fadeIn'));
	api.registerAction('fadeOut', 'Fade out', require('./actions/fadeOut'));

	api.registerConnectionValidator('protor', (validatorAPI) => {
		if (validatorAPI.properties.ip != undefined && validatorAPI.properties.port != undefined) {
			var protor = new Protor(validatorAPI.properties.ip, validatorAPI.properties.port)
			protor.isOnline((online: boolean) => {
				validatorAPI.callback(online, online ? null : 'Unable to reach Protor instance')
				validatorAPI.setInstance(protor)
			})
		} else validatorAPI.callback(false, 'No ip or port specified');
	});
};
