api/notifications.js
function getNotificationHelper(api, account, identifier, urlBase, topCallback) {

  function getTransaction(callback) {
    try {
      transactions.getTransaction(api, account, identifier, {}, callback);
    } catch(err) {
      callback(err);
    }
  }

  function checkLedger(baseTransaction, callback) {
    serverLib.remoteHasLedger(api.remote, baseTransaction.ledger_index,
        function(error, remoteHasLedger) {
      if (error) {
        return callback(error);
      }
      if (remoteHasLedger) {
        callback(null, baseTransaction);
      } else {
        callback(new errors.NotFoundError('Cannot Get Notification. ' +
          'This transaction is not in the ripple\'s complete ledger set. ' +
          'Because there is a gap in the rippled\'s historical database it ' +
          'is not possible to determine the transactions that precede this one')
        );
      }
    });
  }

  function prepareNotificationDetails(baseTransaction, callback) {
    var notificationDetails = {
      account: account,
      identifier: identifier,
      transaction: baseTransaction
    };

    // Move client_resource_id to notificationDetails from transaction
    if (baseTransaction.client_resource_id) {
      notificationDetails.client_resource_id =
        baseTransaction.client_resource_id;
    }
    attachPreviousAndNextTransactionIdentifiers(api, notificationDetails,
      callback);
  }

  // Parse the Notification object from the notificationDetails
  function parseNotificationDetails(notificationDetails, callback) {
    callback(null, NotificationParser.parse(notificationDetails, urlBase));
  }

  function formatNotificationResponse(notificationDetails, callback) {
    var responseBody = {
      notification: notificationDetails
    };

    // Move client_resource_id to response body instead of inside
    // the Notification
    var client_resource_id = responseBody.notification.client_resource_id;
    delete responseBody.notification.client_resource_id;
    if (client_resource_id) {
      responseBody.client_resource_id = client_resource_id;
    }

    callback(null, responseBody);
  }


  var steps = [
    getTransaction,
    checkLedger,
    prepareNotificationDetails,
    parseNotificationDetails,
    formatNotificationResponse
  ];

  async.waterfall(steps, topCallback);
}
function getNotificationHelper(api, account, identifier, urlBase, topCallback) {

  function getTransaction(callback) {
    try {
      transactions.getTransaction(api, account, identifier, {}, callback);
    } catch(err) {
      callback(err);
    }
  }

  function checkLedger(baseTransaction, callback) {
    serverLib.remoteHasLedger(api.remote, baseTransaction.ledger_index,
        function(error, remoteHasLedger) {
      if (error) {
        return callback(error);
      }
      if (remoteHasLedger) {
        callback(null, baseTransaction);
      } else {
        callback(new errors.NotFoundError('Cannot Get Notification. ' +
          'This transaction is not in the ripple\'s complete ledger set. ' +
          'Because there is a gap in the rippled\'s historical database it ' +
          'is not possible to determine the transactions that precede this one')
        );
      }
    });
  }

  function prepareNotificationDetails(baseTransaction, callback) {
    var notificationDetails = {
      account: account,
      identifier: identifier,
      transaction: baseTransaction
    };

    // Move client_resource_id to notificationDetails from transaction
    if (baseTransaction.client_resource_id) {
      notificationDetails.client_resource_id =
        baseTransaction.client_resource_id;
    }
    attachPreviousAndNextTransactionIdentifiers(api, notificationDetails,
      callback);
  }

  // Parse the Notification object from the notificationDetails
  function parseNotificationDetails(notificationDetails, callback) {
    callback(null, NotificationParser.parse(notificationDetails, urlBase));
  }

  function formatNotificationResponse(notificationDetails, callback) {
    var responseBody = {
      notification: notificationDetails
    };

    // Move client_resource_id to response body instead of inside
    // the Notification
    var client_resource_id = responseBody.notification.client_resource_id;
    delete responseBody.notification.client_resource_id;
    if (client_resource_id) {
      responseBody.client_resource_id = client_resource_id;
    }

    callback(null, responseBody);
  }


  var steps = [
    getTransaction,
    checkLedger,
    prepareNotificationDetails,
    parseNotificationDetails,
    formatNotificationResponse
  ];

  async.waterfall(steps, topCallback);
}
function getNotificationHelper ( api , account , identifier , urlBase , topCallback ) { function getTransaction ( callback ) { try { transactions . getTransaction ( api , account , identifier , { } , callback ) ; } catch ( err ) { callback ( err ) ; } } function checkLedger ( baseTransaction , callback ) { serverLib . remoteHasLedger ( api . remote , baseTransaction . ledger_index , function ( error , remoteHasLedger ) { if ( error ) { return callback ( error ) ; } if ( remoteHasLedger ) { callback ( null , baseTransaction ) ; } else { callback ( new errors . NotFoundError ( 'Cannot Get Notification. ' + 'This transaction is not in the ripple\'s complete ledger set. ' + 'Because there is a gap in the rippled\'s historical database it ' + 'is not possible to determine the transactions that precede this one' ) ) ; } } ) ; } function prepareNotificationDetails ( baseTransaction , callback ) { var notificationDetails = { account : account , identifier : identifier , transaction : baseTransaction } ; // Move client_resource_id to notificationDetails from transaction if ( baseTransaction . client_resource_id ) { notificationDetails . client_resource_id = baseTransaction . client_resource_id ; } attachPreviousAndNextTransactionIdentifiers ( api , notificationDetails , callback ) ; } // Parse the Notification object from the notificationDetails function parseNotificationDetails ( notificationDetails , callback ) { callback ( null , NotificationParser . parse ( notificationDetails , urlBase ) ) ; } function formatNotificationResponse ( notificationDetails , callback ) { var responseBody = { notification : notificationDetails } ; // Move client_resource_id to response body instead of inside // the Notification var client_resource_id = responseBody . notification . client_resource_id ; delete responseBody . notification . client_resource_id ; if ( client_resource_id ) { responseBody . client_resource_id = client_resource_id ; } callback ( null , responseBody ) ; } var steps = [ getTransaction , checkLedger , prepareNotificationDetails , parseNotificationDetails , formatNotificationResponse ] ; async . waterfall ( steps , topCallback ) ; }
Get a notification corresponding to the specified
account and transaction identifier. Send errors back
to the client using the res.json method or pass
the notification json to the callback function.

@param {Remote} $.remote
@param {/lib/db-interface} $.dbinterface
@param {RippleAddress} req.params.account
@param {Hex-encoded String|ResourceId} req.params.identifier
@param {Express.js Response} res
@param {Function} callback

@callback
@param {Error} error
@param {Notification} notification
Get a notification corresponding to the specified account and transaction identifier . Send errors back to the client using the res . json method or pass the notification json to the callback function .