var util = require('util');
var EventEmitter = require('events').EventEmitter;
var request = require('request');

var CTDOApi= function(url) {
    var self = this;

    this.poll = function() {
        request({url: "https://" + url}, function(error, res, response) {
            if (error) {
                self.emit('failed', error)
            } else {
                var parsedResponse = JSON.parse(response);

                self.emit('done', parsedResponse);
            }
        });
    };
};

util.inherits(CTDOApi, EventEmitter);
module.exports = CTDOApi;
