 
var config = require('../config'),
    request = require('request');

var vanEndpoint = 'https://api.securevan.com/v4';

function echo(apiKey, message, success, failedAuth, catchErr) {
  var url = vanEndpoint + '/echoes/' + message;

  request(url, function(error, response, body) {
    if (error) {
      return catchErr(error);
    }

    if (response.statusCode == 401) {
      return failedAuth();
    }

    if (response.statusCode == 200) {
      return success(body.message);
    }
  });
}

function getActivistCode(apiKey, dbMode, id, unauthorized, badRequest, success) {
  var options = {
    method: 'GET',
    url: config.get('vanEndpoint') + 'activistCodes/' + id,
    headers: { 'Content-Type': 'application/json' },
    auth: { user: 'api', pass: apiKey + '|' + dbMode, sendImmediately: false }
  };
  
  request(options, function(error, response, body) {
    if (error) {
      return badRequest(error);
    }
    else if (response.statusCode == 200) {
      return success(body);
    }
    else if (response.statusCode == 404) {
      return success({});
    }
    else if (response.statusCode == 401) {
      return unauthorized();
    }
  });
}

module.exports = {
  getActivistCode: getActivistCode
};


 
var config = require('../config'),
    request = require('request');

function getActivistCode(apiKey, dbMode, id, unauthorized, badRequest, success) {
  var options = {
    method: 'GET',
    url: config.get('vanEndpoint') + 'activistCodes/' + id,
    headers: { 'Content-Type': 'application/json' },
    auth: { user: 'api', pass: apiKey + '|' + dbMode, sendImmediately: false }
  };
  
  request(options, function(error, response, body) {
    if (error) {
      return badRequest(error);
    }
    else if (response.statusCode == 200) {
      return success(body);
    }
    else if (response.statusCode == 404) {
      return success({});
    }
    else if (response.statusCode == 401) {
      return unauthorized();
    }
  });
}

module.exports = {
  getActivistCode: getActivistCode
};


Clean up old echoes stuff and correct tags/:id 404 code.
Clean up old echoes stuff and correct tags/:id 404 code.

Signed-off-by: Shai Sachs <47bd79f9420edf5d0991d1e2710179d4e040d480@ngpvan.com>
