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

    debug( 'schedule', options )

    var self = this

    var protocol = options.protocol || 'rest'
    var format = options.format || 'json'
    var baseUrl = 'schedules/' + protocol + '/v1/' + format + '/flight'

    var carrier = options.airlineCode
    var flightNumber = options.flightNumber
    var year = options.date.getFullYear()
    var month = options.date.getMonth() + 1
    var day = options.date.getDate()
    var direction = /^dep/i.test( options.direction ) ?
      'departing' : 'arriving'

    var extensions = [
      'includeDirects',
      'includeCargo',
      'useInlinedReferences'
    ]

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

    return this._clientRequest({
      url: baseUrl + '/' + carrier + '/' + flightNumber + '/' + direction + '/' + year + '/' + month + '/' + day,
      extendedOptions: extensions,
    }, function( error, data ) {

      if( data != null ) {
        data = FlightStats.formatSchedule( data )
        if( options.airport && data.flights ) {
          data.flights = FlightStats.filterByAirport( data.flights, options.airport, options.direction )
        }
      }

      callback.call( self, error, data )

    })

  }
function( options, callback ) {

    debug( 'schedule', options )

    var self = this

    var protocol = options.protocol || 'rest'
    var format = options.format || 'json'
    var baseUrl = 'schedules/' + protocol + '/v1/' + format + '/flight'

    var carrier = options.airlineCode
    var flightNumber = options.flightNumber
    var year = options.date.getFullYear()
    var month = options.date.getMonth() + 1
    var day = options.date.getDate()
    var direction = /^dep/i.test( options.direction ) ?
      'departing' : 'arriving'

    var extensions = [
      'includeDirects',
      'includeCargo',
      'useInlinedReferences'
    ]

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

    return this._clientRequest({
      url: baseUrl + '/' + carrier + '/' + flightNumber + '/' + direction + '/' + year + '/' + month + '/' + day,
      extendedOptions: extensions,
    }, function( error, data ) {

      if( data != null ) {
        data = FlightStats.formatSchedule( data )
        if( options.airport && data.flights ) {
          data.flights = FlightStats.filterByAirport( data.flights, options.airport, options.direction )
        }
      }

      callback.call( self, error, data )

    })

  }
function ( options , callback ) { debug ( 'schedule' , options ) var self = this var protocol = options . protocol || 'rest' var format = options . format || 'json' var baseUrl = 'schedules/' + protocol + '/v1/' + format + '/flight' var carrier = options . airlineCode var flightNumber = options . flightNumber var year = options . date . getFullYear ( ) var month = options . date . getMonth ( ) + 1 var day = options . date . getDate ( ) var direction = / ^dep / i . test ( options . direction ) ? 'departing' : 'arriving' var extensions = [ 'includeDirects' , 'includeCargo' , 'useInlinedReferences' ] if ( Array . isArray ( options . extendedOptions ) ) { extensions = extensions . concat ( options . extendedOptions ) } return this . _clientRequest ( { url : baseUrl + '/' + carrier + '/' + flightNumber + '/' + direction + '/' + year + '/' + month + '/' + day , extendedOptions : extensions , } , function ( error , data ) { if ( data != null ) { data = FlightStats . formatSchedule ( data ) if ( options . airport && data . flights ) { data . flights = FlightStats . filterByAirport ( data . flights , options . airport , options . direction ) } } callback . call ( self , error , data ) } ) }
Get a flight's schedule status information
@param {Object} options - see [.lookup()]{@link FlightStats#lookup}
@param {Function} callback
@return {Request}
Get a flight s schedule status information