code: function addDefinition(defName) {
    var definition = definitions[defName];
    return function(params, done) {
      if (!done && typeof params === 'function') {
        done = params;
        params = {};
      }
  
      var url = this.config.baseUrl + definition.url;
      var xtraParams = {};
      xtraParams.fmt = this.config.responseFormat;
      xtraParams.api_key = this.config.apiKey;
  
      try {
        Object.keys(definition.params).forEach(function(paramName) {
          var paramDef = definition.params[paramName];
          if (!params[paramName]) {
            if (paramDef.required) {
              throw new Error('Parameter ' + paramName + ' is required');
            } else {
              return;
            }
          }
          if (paramDef.location === 'url') {
            url = url.replace(new RegExp('{' + paramName + '}', 'g'), params[paramName]);
          } else if (paramDef.location === 'querystring') {
            xtraParams[paramName] = params[paramName];
          }
        });
      } catch (e) {
        return done(e);
      }
  
      return request
        .get(url)
        .query(xtraParams)
        .end(function onEnd(err, res) {
          return done(err, res.body);
        });
    };
  }
docs: Generic handler for API client method