messaging-api-slack
Advanced tools
Comparing version 1.0.0-beta.9 to 1.0.0-beta.10
import { AxiosInstance } from 'axios'; | ||
import { OnRequestFunction } from 'messaging-api-common'; | ||
import * as SlackTypes from './SlackTypes'; | ||
import * as Types from './SlackTypes'; | ||
export default class SlackOAuthClient { | ||
@@ -9,26 +9,26 @@ _token: string; | ||
chat: { | ||
postMessage: (options: SlackTypes.PostMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
postEphemeral: (options: SlackTypes.PostEphemeralOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
update: (options: SlackTypes.UpdateMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
delete: (options: SlackTypes.DeleteMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
meMessage: (options: SlackTypes.MeMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
getPermalink: (options: SlackTypes.GetPermalinkOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
scheduleMessage: (options: SlackTypes.ScheduleMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
deleteScheduledMessage: (options: SlackTypes.DeleteScheduledMessageOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
unfurl: (options: SlackTypes.UnfurlOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
postMessage: (options: Types.PostMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
postEphemeral: (options: Types.PostEphemeralOptions) => Promise<Types.OAuthAPIResponse>; | ||
update: (options: Types.UpdateMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
delete: (options: Types.DeleteMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
meMessage: (options: Types.MeMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
getPermalink: (options: Types.GetPermalinkOptions) => Promise<Types.OAuthAPIResponse>; | ||
scheduleMessage: (options: Types.ScheduleMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
deleteScheduledMessage: (options: Types.DeleteScheduledMessageOptions) => Promise<Types.OAuthAPIResponse>; | ||
unfurl: (options: Types.UnfurlOptions) => Promise<Types.OAuthAPIResponse>; | ||
scheduledMessages: { | ||
list: (options: SlackTypes.GetScheduledMessagesOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
list: (options: Types.GetScheduledMessagesOptions) => Promise<Types.OAuthAPIResponse>; | ||
}; | ||
}; | ||
views: { | ||
open: (options: SlackTypes.OpenViewOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
publish: (options: SlackTypes.PublishViewOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
push: (options: SlackTypes.PushViewOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
update: (options: SlackTypes.UpdateViewOptions) => Promise<SlackTypes.OAuthAPIResponse>; | ||
open: (options: Types.OpenViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
publish: (options: Types.PublishViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
push: (options: Types.PushViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
update: (options: Types.UpdateViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
}; | ||
static connect(accessTokenOrConfig: string | SlackTypes.ClientConfig): SlackOAuthClient; | ||
constructor(accessTokenOrConfig: string | SlackTypes.ClientConfig); | ||
static connect(accessTokenOrConfig: string | Types.ClientConfig): SlackOAuthClient; | ||
constructor(accessTokenOrConfig: string | Types.ClientConfig); | ||
get axios(): AxiosInstance; | ||
get accessToken(): string; | ||
callMethod(method: SlackTypes.AvailableMethod, inputBody?: Record<string, any>): Promise<SlackTypes.OAuthAPIResponse>; | ||
callMethod(method: Types.AvailableMethod, inputBody?: Record<string, any>): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -39,3 +39,3 @@ * Gets information about a channel. | ||
*/ | ||
getChannelInfo(channelId: string, options?: SlackTypes.GetInfoOptions): Promise<SlackTypes.Channel>; | ||
getChannelInfo(channelId: string, options?: Types.GetInfoOptions): Promise<Types.Channel>; | ||
/** | ||
@@ -46,3 +46,3 @@ * Retrieve information about a conversation. | ||
*/ | ||
getConversationInfo(channelId: string, options?: SlackTypes.GetInfoOptions): Promise<SlackTypes.Channel>; | ||
getConversationInfo(channelId: string, options?: Types.GetInfoOptions): Promise<Types.Channel>; | ||
/** | ||
@@ -53,7 +53,7 @@ * Retrieve members of a conversation. | ||
*/ | ||
getConversationMembers(channelId: string, options?: SlackTypes.ConversationMembersOptions): Promise<{ | ||
getConversationMembers(channelId: string, options?: Types.ConversationMembersOptions): Promise<{ | ||
members: string[]; | ||
next?: string; | ||
}>; | ||
getAllConversationMembers(channelId: string, options?: Omit<SlackTypes.ConversationMembersOptions, 'cursor'>): Promise<string[]>; | ||
getAllConversationMembers(channelId: string, options?: Omit<Types.ConversationMembersOptions, 'cursor'>): Promise<string[]>; | ||
/** | ||
@@ -64,7 +64,7 @@ * Lists all channels in a Slack team. | ||
*/ | ||
getConversationList(options?: SlackTypes.ConversationListOptions): Promise<{ | ||
channels: SlackTypes.Channel[]; | ||
getConversationList(options?: Types.ConversationListOptions): Promise<{ | ||
channels: Types.Channel[]; | ||
next?: string; | ||
}>; | ||
getAllConversationList(options?: Omit<SlackTypes.ConversationListOptions, 'cursor'>): Promise<SlackTypes.Channel[]>; | ||
getAllConversationList(options?: Omit<Types.ConversationListOptions, 'cursor'>): Promise<Types.Channel[]>; | ||
/** | ||
@@ -75,3 +75,3 @@ * Sends a message to a channel. | ||
*/ | ||
postMessage(channel: string, inputMessage: SlackTypes.Message | string, options?: SlackTypes.PostMessageOptionalOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
postMessage(channel: string, inputMessage: Types.Message | string, options?: Types.PostMessageOptionalOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -82,3 +82,3 @@ * Sends a message to a channel. | ||
*/ | ||
_postMessage(options: SlackTypes.PostMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_postMessage(options: Types.PostMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -89,3 +89,3 @@ * Sends an ephemeral message to a user in a channel. | ||
*/ | ||
postEphemeral(channel: string, user: string, inputMessage: SlackTypes.Message | string, options?: SlackTypes.PostEphemeralOptionalOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
postEphemeral(channel: string, user: string, inputMessage: Types.Message | string, options?: Types.PostEphemeralOptionalOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -96,3 +96,3 @@ * Sends an ephemeral message to a user in a channel. | ||
*/ | ||
_postEphemeral(options: SlackTypes.PostEphemeralOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_postEphemeral(options: Types.PostEphemeralOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -103,3 +103,3 @@ * Updates a message. | ||
*/ | ||
_updateMessage(options: SlackTypes.UpdateMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_updateMessage(options: Types.UpdateMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -110,3 +110,3 @@ * Deletes a message. | ||
*/ | ||
_deleteMessage(options: SlackTypes.DeleteMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_deleteMessage(options: Types.DeleteMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -117,3 +117,3 @@ * Share a me message into a channel. | ||
*/ | ||
_meMessage(options: SlackTypes.MeMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_meMessage(options: Types.MeMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -124,3 +124,3 @@ * Retrieve a permalink URL for a specific extant message | ||
*/ | ||
_getPermalink(options: SlackTypes.GetPermalinkOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_getPermalink(options: Types.GetPermalinkOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -131,3 +131,3 @@ * Schedules a message to be sent to a channel. | ||
*/ | ||
_scheduleMessage(options: SlackTypes.ScheduleMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_scheduleMessage(options: Types.ScheduleMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -138,3 +138,3 @@ * Deletes a pending scheduled message from the queue. | ||
*/ | ||
_deleteScheduledMessage(options: SlackTypes.DeleteScheduledMessageOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_deleteScheduledMessage(options: Types.DeleteScheduledMessageOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -145,3 +145,3 @@ * Returns a list of scheduled messages. | ||
*/ | ||
_getScheduledMessages(options?: SlackTypes.GetScheduledMessagesOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_getScheduledMessages(options?: Types.GetScheduledMessagesOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -152,3 +152,3 @@ * Provide custom unfurl behavior for user-posted URLs | ||
*/ | ||
_unfurl(options: SlackTypes.UnfurlOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_unfurl(options: Types.UnfurlOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -159,3 +159,3 @@ * Open a view for a user. | ||
*/ | ||
_openView(options: SlackTypes.OpenViewOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_openView(options: Types.OpenViewOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -166,3 +166,3 @@ * Publish a static view for a User. | ||
*/ | ||
_publishView(options: SlackTypes.PublishViewOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_publishView(options: Types.PublishViewOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -173,3 +173,3 @@ * Update an existing view. | ||
*/ | ||
_updateView(options: SlackTypes.UpdateViewOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_updateView(options: Types.UpdateViewOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -180,3 +180,3 @@ * Push a view onto the stack of a root view. | ||
*/ | ||
_pushView(options: SlackTypes.PushViewOptions): Promise<SlackTypes.OAuthAPIResponse>; | ||
_pushView(options: Types.PushViewOptions): Promise<Types.OAuthAPIResponse>; | ||
/** | ||
@@ -187,3 +187,3 @@ * Gets information about a user. | ||
*/ | ||
getUserInfo(userId: string, options?: SlackTypes.UserInfoOptions): Promise<SlackTypes.User>; | ||
getUserInfo(userId: string, options?: Types.UserInfoOptions): Promise<Types.User>; | ||
/** | ||
@@ -194,8 +194,8 @@ * Lists all users in a Slack team. | ||
*/ | ||
getUserList(options?: SlackTypes.UserListOptions): Promise<{ | ||
members: SlackTypes.User[]; | ||
getUserList(options?: Types.UserListOptions): Promise<{ | ||
members: Types.User[]; | ||
next?: string; | ||
}>; | ||
getAllUserList(options?: Omit<SlackTypes.UserListOptions, 'cursor'>): Promise<SlackTypes.User[]>; | ||
getAllUserList(options?: Omit<Types.UserListOptions, 'cursor'>): Promise<Types.User[]>; | ||
} | ||
//# sourceMappingURL=SlackOAuthClient.d.ts.map |
@@ -340,3 +340,3 @@ import { OnRequestFunction } from 'messaging-api-common'; | ||
export declare type ScheduleMessageOptions = CommonOptions & Message & { | ||
channelId: string; | ||
channel: string; | ||
asUser?: boolean; | ||
@@ -343,0 +343,0 @@ attachments?: string | Attachment[]; |
import { AxiosInstance } from 'axios'; | ||
import { OnRequestFunction } from 'messaging-api-common'; | ||
import { Attachment, SendMessageSuccessResponse } from './SlackTypes'; | ||
declare type URL = string; | ||
import * as Types from './SlackTypes'; | ||
interface ClientConfig { | ||
url: URL; | ||
url: string; | ||
onRequest?: OnRequestFunction; | ||
@@ -12,7 +11,7 @@ } | ||
_onRequest: OnRequestFunction | undefined; | ||
static connect(urlOrConfig: URL | ClientConfig): SlackWebhookClient; | ||
constructor(urlOrConfig: URL | ClientConfig); | ||
static connect(urlOrConfig: string | ClientConfig): SlackWebhookClient; | ||
constructor(urlOrConfig: string | ClientConfig); | ||
get axios(): AxiosInstance; | ||
sendRawBody(body: Record<string, any>): Promise<SendMessageSuccessResponse>; | ||
sendText(text: string): Promise<SendMessageSuccessResponse>; | ||
sendRawBody(body: Record<string, any>): Promise<Types.SendMessageSuccessResponse>; | ||
sendText(text: string): Promise<Types.SendMessageSuccessResponse>; | ||
/** | ||
@@ -23,6 +22,6 @@ * Attachments | ||
*/ | ||
sendAttachments(attachments: Attachment[]): Promise<SendMessageSuccessResponse>; | ||
sendAttachment(attachment: Attachment): Promise<SendMessageSuccessResponse>; | ||
sendAttachments(attachments: Types.Attachment[]): Promise<Types.SendMessageSuccessResponse>; | ||
sendAttachment(attachment: Types.Attachment): Promise<Types.SendMessageSuccessResponse>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=SlackWebhookClient.d.ts.map |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "1.0.0-beta.9", | ||
"version": "1.0.0-beta.10", | ||
"main": "dist/index.js", | ||
@@ -31,3 +31,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "8663c6cd509a20e91755061dace7cb0f47248791" | ||
"gitHead": "9ce7ddd82779b579beab4256d71ccd4599e6c58f" | ||
} |
@@ -14,3 +14,3 @@ import querystring from 'querystring'; | ||
import * as SlackTypes from './SlackTypes'; | ||
import * as Types from './SlackTypes'; | ||
@@ -42,32 +42,30 @@ const DEFAULT_PAYLOAD_FIELDS_TO_STRINGIFY = ['attachments', 'blocks']; | ||
postMessage: ( | ||
options: SlackTypes.PostMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.PostMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
postEphemeral: ( | ||
options: SlackTypes.PostEphemeralOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.PostEphemeralOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
update: ( | ||
options: SlackTypes.UpdateMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.UpdateMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
delete: ( | ||
options: SlackTypes.DeleteMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.DeleteMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
meMessage: ( | ||
options: SlackTypes.MeMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.MeMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
getPermalink: ( | ||
options: SlackTypes.GetPermalinkOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.GetPermalinkOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
scheduleMessage: ( | ||
options: SlackTypes.ScheduleMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.ScheduleMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
deleteScheduledMessage: ( | ||
options: SlackTypes.DeleteScheduledMessageOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
unfurl: ( | ||
options: SlackTypes.UnfurlOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.DeleteScheduledMessageOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
unfurl: (options: Types.UnfurlOptions) => Promise<Types.OAuthAPIResponse>; | ||
scheduledMessages: { | ||
list: ( | ||
options: SlackTypes.GetScheduledMessagesOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.GetScheduledMessagesOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
}; | ||
@@ -77,18 +75,14 @@ }; | ||
views: { | ||
open: ( | ||
options: SlackTypes.OpenViewOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
open: (options: Types.OpenViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
publish: ( | ||
options: SlackTypes.PublishViewOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
push: ( | ||
options: SlackTypes.PushViewOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.PublishViewOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
push: (options: Types.PushViewOptions) => Promise<Types.OAuthAPIResponse>; | ||
update: ( | ||
options: SlackTypes.UpdateViewOptions | ||
) => Promise<SlackTypes.OAuthAPIResponse>; | ||
options: Types.UpdateViewOptions | ||
) => Promise<Types.OAuthAPIResponse>; | ||
}; | ||
static connect( | ||
accessTokenOrConfig: string | SlackTypes.ClientConfig | ||
accessTokenOrConfig: string | Types.ClientConfig | ||
): SlackOAuthClient { | ||
@@ -98,3 +92,3 @@ return new SlackOAuthClient(accessTokenOrConfig); | ||
constructor(accessTokenOrConfig: string | SlackTypes.ClientConfig) { | ||
constructor(accessTokenOrConfig: string | Types.ClientConfig) { | ||
let origin; | ||
@@ -158,5 +152,5 @@ | ||
async callMethod( | ||
method: SlackTypes.AvailableMethod, | ||
method: Types.AvailableMethod, | ||
inputBody: Record<string, any> = {} | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
): Promise<Types.OAuthAPIResponse> { | ||
try { | ||
@@ -175,3 +169,3 @@ const body = { | ||
response.data | ||
) as any) as SlackTypes.OAuthAPIResponse; | ||
) as any) as Types.OAuthAPIResponse; | ||
@@ -201,4 +195,4 @@ if (!data.ok) { | ||
channelId: string, | ||
options?: SlackTypes.GetInfoOptions | ||
): Promise<SlackTypes.Channel> { | ||
options?: Types.GetInfoOptions | ||
): Promise<Types.Channel> { | ||
return this.callMethod('channels.info', { | ||
@@ -217,4 +211,4 @@ channel: channelId, | ||
channelId: string, | ||
options?: SlackTypes.GetInfoOptions | ||
): Promise<SlackTypes.Channel> { | ||
options?: Types.GetInfoOptions | ||
): Promise<Types.Channel> { | ||
return this.callMethod('conversations.info', { | ||
@@ -233,3 +227,3 @@ channel: channelId, | ||
channelId: string, | ||
options?: SlackTypes.ConversationMembersOptions | ||
options?: Types.ConversationMembersOptions | ||
): Promise<{ | ||
@@ -250,3 +244,3 @@ members: string[]; | ||
channelId: string, | ||
options?: Omit<SlackTypes.ConversationMembersOptions, 'cursor'> | ||
options?: Omit<Types.ConversationMembersOptions, 'cursor'> | ||
): Promise<string[]> { | ||
@@ -282,5 +276,5 @@ let allMembers: string[] = []; | ||
getConversationList( | ||
options?: SlackTypes.ConversationListOptions | ||
options?: Types.ConversationListOptions | ||
): Promise<{ | ||
channels: SlackTypes.Channel[]; | ||
channels: Types.Channel[]; | ||
next?: string; | ||
@@ -295,5 +289,5 @@ }> { | ||
async getAllConversationList( | ||
options?: Omit<SlackTypes.ConversationListOptions, 'cursor'> | ||
): Promise<SlackTypes.Channel[]> { | ||
let allChannels: SlackTypes.Channel[] = []; | ||
options?: Omit<Types.ConversationListOptions, 'cursor'> | ||
): Promise<Types.Channel[]> { | ||
let allChannels: Types.Channel[] = []; | ||
let continuationCursor: string | undefined; | ||
@@ -324,5 +318,5 @@ | ||
channel: string, | ||
inputMessage: SlackTypes.Message | string, | ||
options: SlackTypes.PostMessageOptionalOptions = {} | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
inputMessage: Types.Message | string, | ||
options: Types.PostMessageOptionalOptions = {} | ||
): Promise<Types.OAuthAPIResponse> { | ||
warning( | ||
@@ -349,4 +343,4 @@ false, | ||
_postMessage( | ||
options: SlackTypes.PostMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.PostMessageOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.postMessage', stringifyPayloadFields(options)); | ||
@@ -363,5 +357,5 @@ } | ||
user: string, | ||
inputMessage: SlackTypes.Message | string, | ||
options: SlackTypes.PostEphemeralOptionalOptions = {} | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
inputMessage: Types.Message | string, | ||
options: Types.PostEphemeralOptionalOptions = {} | ||
): Promise<Types.OAuthAPIResponse> { | ||
warning( | ||
@@ -389,4 +383,4 @@ false, | ||
_postEphemeral( | ||
options: SlackTypes.PostEphemeralOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.PostEphemeralOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -404,4 +398,4 @@ 'chat.postEphemeral', | ||
_updateMessage( | ||
options: SlackTypes.UpdateMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.UpdateMessageOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.update', stringifyPayloadFields(options)); | ||
@@ -416,4 +410,4 @@ } | ||
_deleteMessage( | ||
options: SlackTypes.DeleteMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.DeleteMessageOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.delete', options); | ||
@@ -427,5 +421,3 @@ } | ||
*/ | ||
_meMessage( | ||
options: SlackTypes.MeMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
_meMessage(options: Types.MeMessageOptions): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.meMessage', options); | ||
@@ -440,4 +432,4 @@ } | ||
_getPermalink( | ||
options: SlackTypes.GetPermalinkOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.GetPermalinkOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.getPermalink', options); | ||
@@ -452,4 +444,4 @@ } | ||
_scheduleMessage( | ||
options: SlackTypes.ScheduleMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.ScheduleMessageOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -467,4 +459,4 @@ 'chat.scheduleMessage', | ||
_deleteScheduledMessage( | ||
options: SlackTypes.DeleteScheduledMessageOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.DeleteScheduledMessageOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.deleteScheduledMessage', options); | ||
@@ -479,4 +471,4 @@ } | ||
_getScheduledMessages( | ||
options: SlackTypes.GetScheduledMessagesOptions = {} | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.GetScheduledMessagesOptions = {} | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod('chat.scheduledMessages.list', options); | ||
@@ -490,5 +482,3 @@ } | ||
*/ | ||
_unfurl( | ||
options: SlackTypes.UnfurlOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
_unfurl(options: Types.UnfurlOptions): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -505,5 +495,3 @@ 'chat.unfurl', | ||
*/ | ||
_openView( | ||
options: SlackTypes.OpenViewOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
_openView(options: Types.OpenViewOptions): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -521,4 +509,4 @@ 'views.open', | ||
_publishView( | ||
options: SlackTypes.PublishViewOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.PublishViewOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -536,4 +524,4 @@ 'views.publish', | ||
_updateView( | ||
options: SlackTypes.UpdateViewOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
options: Types.UpdateViewOptions | ||
): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -550,5 +538,3 @@ 'views.update', | ||
*/ | ||
_pushView( | ||
options: SlackTypes.PushViewOptions | ||
): Promise<SlackTypes.OAuthAPIResponse> { | ||
_pushView(options: Types.PushViewOptions): Promise<Types.OAuthAPIResponse> { | ||
return this.callMethod( | ||
@@ -567,4 +553,4 @@ 'views.push', | ||
userId: string, | ||
options?: SlackTypes.UserInfoOptions | ||
): Promise<SlackTypes.User> { | ||
options?: Types.UserInfoOptions | ||
): Promise<Types.User> { | ||
return this.callMethod('users.info', { user: userId, ...options }).then( | ||
@@ -581,5 +567,5 @@ data => data.user | ||
getUserList( | ||
options?: SlackTypes.UserListOptions | ||
options?: Types.UserListOptions | ||
): Promise<{ | ||
members: SlackTypes.User[]; | ||
members: Types.User[]; | ||
next?: string; | ||
@@ -594,5 +580,5 @@ }> { | ||
async getAllUserList( | ||
options?: Omit<SlackTypes.UserListOptions, 'cursor'> | ||
): Promise<SlackTypes.User[]> { | ||
let allUsers: SlackTypes.User[] = []; | ||
options?: Omit<Types.UserListOptions, 'cursor'> | ||
): Promise<Types.User[]> { | ||
let allUsers: Types.User[] = []; | ||
let continuationCursor; | ||
@@ -605,3 +591,3 @@ | ||
}: { | ||
members: SlackTypes.User[]; | ||
members: Types.User[]; | ||
next?: string; | ||
@@ -608,0 +594,0 @@ // eslint-disable-next-line no-await-in-loop |
@@ -617,3 +617,3 @@ import { OnRequestFunction } from 'messaging-api-common'; | ||
Message & { | ||
channelId: string; | ||
channel: string; | ||
asUser?: boolean; | ||
@@ -620,0 +620,0 @@ attachments?: string | Attachment[]; |
@@ -8,8 +8,6 @@ import axios, { AxiosInstance } from 'axios'; | ||
import { Attachment, SendMessageSuccessResponse } from './SlackTypes'; | ||
import * as Types from './SlackTypes'; | ||
type URL = string; | ||
interface ClientConfig { | ||
url: URL; | ||
url: string; | ||
onRequest?: OnRequestFunction; | ||
@@ -23,7 +21,7 @@ } | ||
static connect(urlOrConfig: URL | ClientConfig): SlackWebhookClient { | ||
static connect(urlOrConfig: string | ClientConfig): SlackWebhookClient { | ||
return new SlackWebhookClient(urlOrConfig); | ||
} | ||
constructor(urlOrConfig: URL | ClientConfig) { | ||
constructor(urlOrConfig: string | ClientConfig) { | ||
let url; | ||
@@ -56,7 +54,9 @@ | ||
sendRawBody(body: Record<string, any>): Promise<SendMessageSuccessResponse> { | ||
sendRawBody( | ||
body: Record<string, any> | ||
): Promise<Types.SendMessageSuccessResponse> { | ||
return this._axios.post('', snakecaseKeysDeep(body)).then(res => res.data); | ||
} | ||
sendText(text: string): Promise<SendMessageSuccessResponse> { | ||
sendText(text: string): Promise<Types.SendMessageSuccessResponse> { | ||
return this.sendRawBody({ text }); | ||
@@ -72,10 +72,12 @@ } | ||
sendAttachments( | ||
attachments: Attachment[] | ||
): Promise<SendMessageSuccessResponse> { | ||
attachments: Types.Attachment[] | ||
): Promise<Types.SendMessageSuccessResponse> { | ||
return this.sendRawBody({ attachments }); | ||
} | ||
sendAttachment(attachment: Attachment): Promise<SendMessageSuccessResponse> { | ||
sendAttachment( | ||
attachment: Types.Attachment | ||
): Promise<Types.SendMessageSuccessResponse> { | ||
return this.sendAttachments([attachment]); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
298794
5288