import { ConnectionValidatorAPI, IntegrationAPI } from '../../IntegrationApi';
import { StudioMonitor } from 'studiomonitor-api';
const axios = require('axios').default;

module.exports = (api: IntegrationAPI) => {
	//Register a action
	api.registerAction('source', require('./actions/source'));

	api.registerConnectionValidator('studiomonitor', (ValidatorAPI: ConnectionValidatorAPI) => {
		var monitor = new StudioMonitor(ValidatorAPI.properties.ip, ValidatorAPI.properties.port, (err) => {
			ValidatorAPI.callback(
				err == undefined,
				err == undefined ? null : 'Unable to connect to the StudioMonitor.'
			);

			ValidatorAPI.setInstance(monitor);
		});
	});
};

interface StudioMonitor_Properties {
	ip: string;
	port: number;
}
