lib/dfp.js
function _makeQuery(conditions, fields) {
  // build up 'Where' string
  var query = fields.reduce(function(condition, field) {
    var addition = '';
    var val = conditions[field];
    var isNumber = typeof val === 'number';
    if (val) {
      addition += field;
      if (isNumber) {
        addition += '=';
      } else {
        addition += ' like \'';
      }

      addition += val;

      if (!isNumber) {
        addition += '\'';
      }

      addition += ' and ';
    }
    return condition + addition;
  }, 'Where ');

  // remove final 'and'
  query = query.replace(/ and $/, '');
  return new nodeGoogleDfp.Statement(query);
}
function _makeQuery(conditions, fields) {
  // build up 'Where' string
  var query = fields.reduce(function(condition, field) {
    var addition = '';
    var val = conditions[field];
    var isNumber = typeof val === 'number';
    if (val) {
      addition += field;
      if (isNumber) {
        addition += '=';
      } else {
        addition += ' like \'';
      }

      addition += val;

      if (!isNumber) {
        addition += '\'';
      }

      addition += ' and ';
    }
    return condition + addition;
  }, 'Where ');

  // remove final 'and'
  query = query.replace(/ and $/, '');
  return new nodeGoogleDfp.Statement(query);
}
function _makeQuery ( conditions , fields ) { // build up 'Where' string var query = fields . reduce ( function ( condition , field ) { var addition = '' ; var val = conditions [ field ] ; var isNumber = typeof val === 'number' ; if ( val ) { addition += field ; if ( isNumber ) { addition += '=' ; } else { addition += ' like \'' ; } addition += val ; if ( ! isNumber ) { addition += '\'' ; } addition += ' and ' ; } return condition + addition ; } , 'Where ' ) ; // remove final 'and' query = query . replace ( /  and $ / , '' ) ; return new nodeGoogleDfp . Statement ( query ) ; }
Converts an object of conditions and possible query fields into a
node-google-dfp statement to query DFP.

@param  {Object} conditions An object of the properties you'd like to query
and the values you'd like them to contain.
@param  {Array} fields      All the fields it is possible to query, as
detailed in the DFP api.
@return {Object}            node-google-dfp statement.
Converts an object of conditions and possible query fields into a node - google - dfp statement to query DFP .