Skip to content

Commit

Permalink
Merge pull request #520 from ryanseys/ack-id
Browse files Browse the repository at this point in the history
fix message.id and message.ackId documentation
  • Loading branch information
stephenplusplus committed May 4, 2015
2 parents f833b3b + d4991f7 commit a0c4a73
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/pubsub/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ var util = require('../common/util.js');
* // Register a listener for `message` events.
* function onMessage(message) {
* // Called every time a message is received.
* // message.id = ID used to acknowledge its receival.
* // message.id = ID of the message.
* // message.ackId = ID used to acknowledge the message receival.
* // message.data = Contents of the message.
* }
* subscription.on('message', onMessage);
Expand Down Expand Up @@ -243,24 +244,24 @@ Subscription.prototype.startPulling_ = function() {

/**
* Acknowledge to the backend that the message was retrieved. You must provide
* either a single ID or an array of IDs.
* either a single ackId or an array of ackIds.
*
* @throws {Error} If at least one id is not provided.
* @throws {Error} If at least one ackId is not provided.
*
* @param {string|string[]} ids - An ID or array of message IDs.
* @param {string|string[]} ackIds - An ackId or array of ackIds.
* @param {function=} callback - The callback function.
*
* @example
* subscription.ack('ePHEESyhuE8e...', function(err, apiResponse) {});
*/
Subscription.prototype.ack = function(ids, callback) {
if (!ids || ids.length === 0) {
Subscription.prototype.ack = function(ackIds, callback) {
if (!ackIds || ackIds.length === 0) {
throw new Error(
'At least one ID must be specified before it can be acknowledged.');
}
ids = util.arrayize(ids);
ackIds = util.arrayize(ackIds);
var body = {
ackIds: ids
ackIds: ackIds
};
var path = this.name + ':acknowledge';
this.makeReq_('POST', path, null, body, callback || util.noop);
Expand Down

0 comments on commit a0c4a73

Please sign in to comment.