lib/utils.js
function(args) {
    var opts = {
      auth: null,
      headers: {},
    };
    if (args.length > 0) {
      var arg = args[args.length - 1];
      if (utils.isAuthKey(arg)) {
        opts.auth = args.pop();
      } else if (utils.isOptionsHash(arg)) {
        var params = args.pop();

        var extraKeys = Object.keys(params).filter(function(key) {
          return OPTIONS_KEYS.indexOf(key) == -1;
        });

        if (extraKeys.length) {
          emitWarning('Invalid options found (' + extraKeys.join(', ') + '); ignoring.');
        }

        if (params.api_key) {
          opts.auth = params.api_key;
        }
        if (params.idempotency_key) {
          opts.headers['Idempotency-Key'] = params.idempotency_key;
        }
        if (params.stripe_account) {
          opts.headers['Stripe-Account'] = params.stripe_account;
        }
        if (params.stripe_version) {
          opts.headers['Stripe-Version'] = params.stripe_version;
        }
      }
    }
    return opts;
  }
function(args) {
    var opts = {
      auth: null,
      headers: {},
    };
    if (args.length > 0) {
      var arg = args[args.length - 1];
      if (utils.isAuthKey(arg)) {
        opts.auth = args.pop();
      } else if (utils.isOptionsHash(arg)) {
        var params = args.pop();

        var extraKeys = Object.keys(params).filter(function(key) {
          return OPTIONS_KEYS.indexOf(key) == -1;
        });

        if (extraKeys.length) {
          emitWarning('Invalid options found (' + extraKeys.join(', ') + '); ignoring.');
        }

        if (params.api_key) {
          opts.auth = params.api_key;
        }
        if (params.idempotency_key) {
          opts.headers['Idempotency-Key'] = params.idempotency_key;
        }
        if (params.stripe_account) {
          opts.headers['Stripe-Account'] = params.stripe_account;
        }
        if (params.stripe_version) {
          opts.headers['Stripe-Version'] = params.stripe_version;
        }
      }
    }
    return opts;
  }
function ( args ) { var opts = { auth : null , headers : { } , } ; if ( args . length > 0 ) { var arg = args [ args . length - 1 ] ; if ( utils . isAuthKey ( arg ) ) { opts . auth = args . pop ( ) ; } else if ( utils . isOptionsHash ( arg ) ) { var params = args . pop ( ) ; var extraKeys = Object . keys ( params ) . filter ( function ( key ) { return OPTIONS_KEYS . indexOf ( key ) == - 1 ; } ) ; if ( extraKeys . length ) { emitWarning ( 'Invalid options found (' + extraKeys . join ( ', ' ) + '); ignoring.' ) ; } if ( params . api_key ) { opts . auth = params . api_key ; } if ( params . idempotency_key ) { opts . headers [ 'Idempotency-Key' ] = params . idempotency_key ; } if ( params . stripe_account ) { opts . headers [ 'Stripe-Account' ] = params . stripe_account ; } if ( params . stripe_version ) { opts . headers [ 'Stripe-Version' ] = params . stripe_version ; } } } return opts ; }
Return the options hash from a list of arguments
Return the options hash from a list of arguments