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

Add chat.postEphemeral to Node SDK #384

Merged
merged 2 commits into from Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/clients/web/facets/chat.js
Expand Up @@ -4,6 +4,7 @@
* This provides functions to call:
* - delete: {@link https://api.slack.com/methods/chat.delete|chat.delete}
* - meMessage: {@link https://api.slack.com/methods/chat.meMessage|chat.meMessage}
* - postEphemeral: {@link https://api.slack.com/methods/chat.postEphemeral|chat.postEphemeral}
* - postMessage: {@link https://api.slack.com/methods/chat.postMessage|chat.postMessage}
* - update: {@link https://api.slack.com/methods/chat.update|chat.update}
*
Expand Down Expand Up @@ -56,6 +57,36 @@ ChatFacet.prototype.meMessage = function meMessage(channel, text, optCb) {
};


/**
* Sends an ephemeral message to a user in a channel.
* @see {@link https://api.slack.com/methods/chat.postEphemeral|chat.postEphemeral}
*
* @param {?} channel - Channel, private group, or IM channel to send message to. Can be an
* encoded ID, or a name. See [below](#channels) for more details.
* @param {?} text - Text of the message to send. See below for an explanation of
* [formatting](#formatting). This field is usually required, unless you're providing only
* `attachments` instead.
* @param {?} user - `id` of the user who will receive the ephemeral message.
* The user should be in the channel specified by the `channel` argument.
* @param {Object=} opts
* @param {?} opts.parse - Change how messages are treated. Defaults to `none`. See
* [below](#formatting).
* @param {?} opts.link_names - Find and link channel names and usernames.
* @param {?} opts.attachments - Structured message attachments.
* @param {?} opts.as_user - Pass true to post the message as the authed user, instead of as a
* bot. Defaults to false. See [authorship](#authorship) below.
* @param {function=} optCb Optional callback, if not using promises.
*/
ChatFacet.prototype.postEphemeral = function postEphemeral(channel, text, user, opts, optCb) {
var requiredArgs = {
channel: channel,
text: text,
user: user
};

return this.makeAPICall('chat.postEphemeral', requiredArgs, opts, optCb);
};

/**
* Sends a message to a channel.
* @see {@link https://api.slack.com/methods/chat.postMessage|chat.postMessage}
Expand Down