api/notifications.js
function getNotifications(account, urlBase, options, callback) {
  validate.address(account);

  var self = this;

  function getTransactions(_callback) {

    var resultsPerPage = options.results_per_page ||
      transactions.DEFAULT_RESULTS_PER_PAGE;
    var offset = resultsPerPage * ((options.page || 1) - 1);

    var args = {
      account: account,
      direction: options.direction,
      min: resultsPerPage,
      max: resultsPerPage,
      ledger_index_min: options.ledger_min,
      ledger_index_max: options.ledger_max,
      offset: offset,
      earliestFirst: options.earliest_first
    };

    transactions.getAccountTransactions(self, args, _callback);
  }

  function parseNotifications(baseTransactions, _callback) {
    var numTransactions = baseTransactions.length;

    function parseNotification(transaction, __callback) {
      var args = {
        account: account,
        identifier: transaction.hash,
        transaction: transaction
      };

      // Attaching previous and next identifiers
      var idx = baseTransactions.indexOf(transaction);
      var previous = baseTransactions[idx - 1];
      var next = baseTransactions[idx + 1];

      if (!options.earliest_first) {
        args.previous_hash = previous ? previous.hash : undefined;
        args.next_hash = next ? next.hash : undefined;
      } else {
        args.previous_hash = next ? next.hash : undefined;
        args.next_hash = previous ? previous.hash : undefined;
      }

      args.previous_transaction_identifier = args.previous_hash;
      args.next_transaction_identifier = args.next_hash;

      var firstAndPaging = options.page &&
        (options.earliest_first ?
         args.previous_hash === undefined : args.next_hash === undefined);

      var last = idx === numTransactions - 1;

      if (firstAndPaging || last) {
        attachPreviousAndNextTransactionIdentifiers(self, args,
          function(err, _args) {
            return __callback(err, NotificationParser.parse(_args, urlBase));
          }
        );
      } else {
        return __callback(null, NotificationParser.parse(args, urlBase));
      }
    }

    return async.map(baseTransactions, parseNotification, _callback);
  }

  function formatResponse(notifications, _callback) {
    _callback(null, {notifications: notifications});
  }

  var steps = [
    getTransactions,
    _.partial(utils.attachDate, self),
    parseNotifications,
    formatResponse
  ];

  return async.waterfall(steps, callback);
}
function getNotifications(account, urlBase, options, callback) {
  validate.address(account);

  var self = this;

  function getTransactions(_callback) {

    var resultsPerPage = options.results_per_page ||
      transactions.DEFAULT_RESULTS_PER_PAGE;
    var offset = resultsPerPage * ((options.page || 1) - 1);

    var args = {
      account: account,
      direction: options.direction,
      min: resultsPerPage,
      max: resultsPerPage,
      ledger_index_min: options.ledger_min,
      ledger_index_max: options.ledger_max,
      offset: offset,
      earliestFirst: options.earliest_first
    };

    transactions.getAccountTransactions(self, args, _callback);
  }

  function parseNotifications(baseTransactions, _callback) {
    var numTransactions = baseTransactions.length;

    function parseNotification(transaction, __callback) {
      var args = {
        account: account,
        identifier: transaction.hash,
        transaction: transaction
      };

      // Attaching previous and next identifiers
      var idx = baseTransactions.indexOf(transaction);
      var previous = baseTransactions[idx - 1];
      var next = baseTransactions[idx + 1];

      if (!options.earliest_first) {
        args.previous_hash = previous ? previous.hash : undefined;
        args.next_hash = next ? next.hash : undefined;
      } else {
        args.previous_hash = next ? next.hash : undefined;
        args.next_hash = previous ? previous.hash : undefined;
      }

      args.previous_transaction_identifier = args.previous_hash;
      args.next_transaction_identifier = args.next_hash;

      var firstAndPaging = options.page &&
        (options.earliest_first ?
         args.previous_hash === undefined : args.next_hash === undefined);

      var last = idx === numTransactions - 1;

      if (firstAndPaging || last) {
        attachPreviousAndNextTransactionIdentifiers(self, args,
          function(err, _args) {
            return __callback(err, NotificationParser.parse(_args, urlBase));
          }
        );
      } else {
        return __callback(null, NotificationParser.parse(args, urlBase));
      }
    }

    return async.map(baseTransactions, parseNotification, _callback);
  }

  function formatResponse(notifications, _callback) {
    _callback(null, {notifications: notifications});
  }

  var steps = [
    getTransactions,
    _.partial(utils.attachDate, self),
    parseNotifications,
    formatResponse
  ];

  return async.waterfall(steps, callback);
}
function getNotifications ( account , urlBase , options , callback ) { validate . address ( account ) ; var self = this ; function getTransactions ( _callback ) { var resultsPerPage = options . results_per_page || transactions . DEFAULT_RESULTS_PER_PAGE ; var offset = resultsPerPage * ( ( options . page || 1 ) - 1 ) ; var args = { account : account , direction : options . direction , min : resultsPerPage , max : resultsPerPage , ledger_index_min : options . ledger_min , ledger_index_max : options . ledger_max , offset : offset , earliestFirst : options . earliest_first } ; transactions . getAccountTransactions ( self , args , _callback ) ; } function parseNotifications ( baseTransactions , _callback ) { var numTransactions = baseTransactions . length ; function parseNotification ( transaction , __callback ) { var args = { account : account , identifier : transaction . hash , transaction : transaction } ; // Attaching previous and next identifiers var idx = baseTransactions . indexOf ( transaction ) ; var previous = baseTransactions [ idx - 1 ] ; var next = baseTransactions [ idx + 1 ] ; if ( ! options . earliest_first ) { args . previous_hash = previous ? previous . hash : undefined ; args . next_hash = next ? next . hash : undefined ; } else { args . previous_hash = next ? next . hash : undefined ; args . next_hash = previous ? previous . hash : undefined ; } args . previous_transaction_identifier = args . previous_hash ; args . next_transaction_identifier = args . next_hash ; var firstAndPaging = options . page && ( options . earliest_first ? args . previous_hash === undefined : args . next_hash === undefined ) ; var last = idx === numTransactions - 1 ; if ( firstAndPaging || last ) { attachPreviousAndNextTransactionIdentifiers ( self , args , function ( err , _args ) { return __callback ( err , NotificationParser . parse ( _args , urlBase ) ) ; } ) ; } else { return __callback ( null , NotificationParser . parse ( args , urlBase ) ) ; } } return async . map ( baseTransactions , parseNotification , _callback ) ; } function formatResponse ( notifications , _callback ) { _callback ( null , { notifications : notifications } ) ; } var steps = [ getTransactions , _ . partial ( utils . attachDate , self ) , parseNotifications , formatResponse ] ; return async . waterfall ( steps , callback ) ; }
Get a notifications corresponding to the specified
account.

This function calls transactions.getAccountTransactions
recursively to retrieve results_per_page number of transactions
and filters the results using client-specified parameters.

@param {RippleAddress} account
@param {string} urlBase - The url to use for the transaction status URL

@param {string} options.source_account
@param {Number} options.ledger_min
@param {Number} options.ledger_max
@param {string} [false] options.earliest_first
@param {string[]} options.types - @see transactions.getAccountTransactions

 TODO: If given ledger range, check for ledger gaps
Get a notifications corresponding to the specified account .