diff --git a/lib/pubsub/subscription.js b/lib/pubsub/subscription.js index fe110e4a51a..97d80ea6927 100644 --- a/lib/pubsub/subscription.js +++ b/lib/pubsub/subscription.js @@ -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); @@ -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);