'use strict';

var request = require('request');
var util = require('./util');

function backend(path) {
  return function(client, payload, callback) {
    if (!util.is('Function', callback)) {
      callback = function defaultCallback(err, res, body){};
    }

    if (!client.apiKey) {
      callback(new Error('API key is missing or invalid.'));
      return;
    }

    var headers = {
      'content-type':'application/json',
      'X-API-Key': client.apiKey,
      'Accept':'application/json'
    };

    request.post({
      url: client.endpoint + path,
      headers: headers,
      json: payload
    }, callback);
  }
}

module.exports = {
  notice: backend('/v1/notices'),
  metrics: backend('/v1/metrics')
}

@@ -678,42 +678,7 @@
 es')
-,%0A  metrics: backend('/v1/metrics')
 %0A%7D%0A

Remove metrics endpoint from backend.