var request = require('request');
var Scholarcheck = function(apiKey) {
  this.apiUrl = "https://api.scholarcheck.io/api/v1/";
  this.apiKey = apiKey || '';
};

Scholarcheck.prototype._apiCall = function(endpoint, callback) {
  var options = {
    url: this.apiUrl + endpoint,
    headers: {
      'Token': this.apiKey
    },
    rejectUnauthorized: false
  }; //rejectUnauthorized must be true until the SSL cert is changed to include api.scholarcheck.io
  request(options, function(err, res, body) {
    callback(err, JSON.parse(body));
  });
};

Scholarcheck.prototype.valid = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      return cb(err);
    }
    return cb(null, data.valid);
  });
};

Scholarcheck.prototype.institution = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      cb(err);
    }
    return cb(null, data.institution);
  });
};

Scholarcheck.prototype.rawData = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      return cb(err);
    }
    return cb(null, data);
  });
};

module.exports = Scholarcheck;

var request = require('request');
var Scholarcheck = function(apiKey) {
  this.apiUrl = "https://app.scholarcheck.io/api/v1/";
  this.apiKey = apiKey || '';
};

Scholarcheck.prototype._apiCall = function(endpoint, callback) {
  var options = {
    url: this.apiUrl + endpoint,
    headers: {
      'Token': this.apiKey
    },
    rejectUnauthorized: false
  }; //rejectUnauthorized must be true until the SSL cert is changed to include api.scholarcheck.io
  request(options, function(err, res, body) {
    callback(err, JSON.parse(body));
  });
};

Scholarcheck.prototype.valid = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      return cb(err);
    }
    return cb(null, data.valid);
  });
};

Scholarcheck.prototype.institution = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      cb(err);
    }
    return cb(null, data.institution);
  });
};

Scholarcheck.prototype.rawData = function(email, cb) {
  var apiReq = 'email/' + email;
  this._apiCall(apiReq, function(err, data) {
    if (!!err) {
      return cb(err);
    }
    return cb(null, data);
  });
};

module.exports = Scholarcheck;

Fix typo on API URL
Fix typo on API URL
