Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix message.id and message.ackId documentation #520

Merged
merged 1 commit into from
May 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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