lib/flightstats.js
function( options, callback ) {

    var self = this

    var year = options.date.getFullYear()
    var month = options.date.getMonth() + 1
    var day = options.date.getDate()
    var hour = options.date.getHours()
    var minute = options.date.getMinutes()

    var url = '/connections/rest/v2/json/' + options.type + '/' + options.departureAirport + '/to/' + options.arrivalAirport +
      options.verb + year + '/' + month + '/' + day + '/' + hour + '/' + minute

    var extensions = []

    if( Array.isArray( options.extendedOptions ) ) {
      extensions = extensions.concat( options.extendedOptions )
    }

    var query = {
      numHours: options.numHours,
      maxResults: options.maxResults,
      maxConnections: options.maxConnections,
      minimumConnectTime: options.minimumConnectTime,
      payloadType: options.payloadType,
      includeAirlines: options.includeAirlines,
      excludeAirlines: options.excludeAirlines,
      includeAirports: options.includeAirports,
      excludeAirports: options.excludeAirports,
      includeSurface: options.includeSurface,
      includeCodeshares: options.includeCodeshares,
      includeMultipleCarriers: options.includeMultipleCarriers,
    }

    Object.keys( query ).forEach( function( key ) {
      query[key] = query[key] != null ?
        query[key] : undefined
    })

    return this._clientRequest({
      url: url,
      qs: query,
      extendedOptions: extensions,
    }, function( error, data ) {
      callback.call( self, error, data )
    })

  }
function( options, callback ) {

    var self = this

    var year = options.date.getFullYear()
    var month = options.date.getMonth() + 1
    var day = options.date.getDate()
    var hour = options.date.getHours()
    var minute = options.date.getMinutes()

    var url = '/connections/rest/v2/json/' + options.type + '/' + options.departureAirport + '/to/' + options.arrivalAirport +
      options.verb + year + '/' + month + '/' + day + '/' + hour + '/' + minute

    var extensions = []

    if( Array.isArray( options.extendedOptions ) ) {
      extensions = extensions.concat( options.extendedOptions )
    }

    var query = {
      numHours: options.numHours,
      maxResults: options.maxResults,
      maxConnections: options.maxConnections,
      minimumConnectTime: options.minimumConnectTime,
      payloadType: options.payloadType,
      includeAirlines: options.includeAirlines,
      excludeAirlines: options.excludeAirlines,
      includeAirports: options.includeAirports,
      excludeAirports: options.excludeAirports,
      includeSurface: options.includeSurface,
      includeCodeshares: options.includeCodeshares,
      includeMultipleCarriers: options.includeMultipleCarriers,
    }

    Object.keys( query ).forEach( function( key ) {
      query[key] = query[key] != null ?
        query[key] : undefined
    })

    return this._clientRequest({
      url: url,
      qs: query,
      extendedOptions: extensions,
    }, function( error, data ) {
      callback.call( self, error, data )
    })

  }
function ( options , callback ) { var self = this var year = options . date . getFullYear ( ) var month = options . date . getMonth ( ) + 1 var day = options . date . getDate ( ) var hour = options . date . getHours ( ) var minute = options . date . getMinutes ( ) var url = '/connections/rest/v2/json/' + options . type + '/' + options . departureAirport + '/to/' + options . arrivalAirport + options . verb + year + '/' + month + '/' + day + '/' + hour + '/' + minute var extensions = [ ] if ( Array . isArray ( options . extendedOptions ) ) { extensions = extensions . concat ( options . extendedOptions ) } var query = { numHours : options . numHours , maxResults : options . maxResults , maxConnections : options . maxConnections , minimumConnectTime : options . minimumConnectTime , payloadType : options . payloadType , includeAirlines : options . includeAirlines , excludeAirlines : options . excludeAirlines , includeAirports : options . includeAirports , excludeAirports : options . excludeAirports , includeSurface : options . includeSurface , includeCodeshares : options . includeCodeshares , includeMultipleCarriers : options . includeMultipleCarriers , } Object . keys ( query ) . forEach ( function ( key ) { query [ key ] = query [ key ] != null ? query [ key ] : undefined } ) return this . _clientRequest ( { url : url , qs : query , extendedOptions : extensions , } , function ( error , data ) { callback . call ( self , error , data ) } ) }
Get connecting flights between two airports
@internal used by {first,last}Flight{In,Out} methods
@param {Object} options
@param {?String} [options.type] optional, only used by `.connections()`
@param {String} options.departureAirport
@param {String} options.arrivalAirport
@param {Date} options.date
@param {?Number} [options.numHours=6] optional
@param {?Number} [options.maxResults=25] optional
@param {?Number} [options.maxConnections=2] optional
@param {?Number} [options.minimumConnectTime] optional
@param {?String} [options.payloadType='passenger'] optional
@param {?Array<String>} [options.includeAirlines] optional
@param {?Array<String>} [options.excludeAirlines] optional
@param {?Array<String>} [options.includeAirports] optional
@param {?Array<String>} [options.excludeAirports] optional
@param {?Boolean} [options.includeSurface=false] optional
@param {?Boolean} [options.includeCodeshares=true] optional
@param {?Boolean} [options.includeMultipleCarriers=true] optional
@param {Array<String>} [options.extendedOptions]
@param {Function} callback
@return {Request}
Get connecting flights between two airports