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 missing API methods #1222

Merged
merged 2 commits into from May 7, 2021
Merged
Show file tree
Hide file tree
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
144 changes: 82 additions & 62 deletions packages/web-api/src/methods.ts
Expand Up @@ -182,6 +182,8 @@ import { WorkflowsUpdateStepResponse } from './response/WorkflowsUpdateStepRespo
import { AdminUsersSessionGetSettingsResponse } from './response/AdminUsersSessionGetSettingsResponse';
import { AdminUsersSessionSetSettingsResponse } from './response/AdminUsersSessionSetSettingsResponse';
import { AdminUsersSessionClearSettingsResponse } from './response/AdminUsersSessionClearSettingsResponse';
import { AdminAppsClearResolutionResponse } from './response/AdminAppsClearResolutionResponse';
import { AdminAppsUninstallResponse } from './response/AdminAppsUninstallResponse';

// NOTE: could create a named type alias like data types like `SlackUserID: string`

Expand Down Expand Up @@ -221,11 +223,13 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
public abstract apiCall(method: string, options?: WebAPICallOptions): Promise<WebAPICallResult>;

public readonly admin = {
// TODO: admin.analytics.getFile
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described at #1191 , this endpoint returns binary data. We will work on it separately.

apps: {
approve: bindApiCall<AdminAppsApproveArguments, AdminAppsApproveResponse>(this, 'admin.apps.approve'),
approved: {
list: bindApiCall<AdminAppsApprovedListArguments, AdminAppsApprovedListResponse>(this, 'admin.apps.approved.list'),
},
clearResolution: bindApiCall<AdminAppsClearResolutionArguments, AdminAppsClearResolutionResponse>(this, 'admin.apps.clearResolution'),
requests: {
list: bindApiCall<AdminAppsRequestsListArguments, AdminAppsRequestsListResponse>(this, 'admin.apps.requests.list'),
},
Expand All @@ -234,6 +238,7 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
list:
bindApiCall<AdminAppsRestrictedListArguments, AdminAppsRestrictedListResponse>(this, 'admin.apps.restricted.list'),
},
uninstall: bindApiCall<AdminAppsUninstallArguments, AdminAppsUninstallResponse>(this, 'admin.apps.uninstall'),
},
barriers: {
create: bindApiCall<AdminBarriersCreateArguments, AdminBarriersCreateResponse>(this, 'admin.barriers.create'),
Expand Down Expand Up @@ -412,24 +417,6 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
},
};

public readonly channels = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

archive: bindApiCall<ChannelsArchiveArguments, WebAPICallResult>(this, 'channels.archive'),
create: bindApiCall<ChannelsCreateArguments, WebAPICallResult>(this, 'channels.create'),
history: bindApiCall<ChannelsHistoryArguments, WebAPICallResult>(this, 'channels.history'),
info: bindApiCall<ChannelsInfoArguments, WebAPICallResult>(this, 'channels.info'),
invite: bindApiCall<ChannelsInviteArguments, WebAPICallResult>(this, 'channels.invite'),
join: bindApiCall<ChannelsJoinArguments, WebAPICallResult>(this, 'channels.join'),
kick: bindApiCall<ChannelsKickArguments, WebAPICallResult>(this, 'channels.kick'),
leave: bindApiCall<ChannelsLeaveArguments, WebAPICallResult>(this, 'channels.leave'),
list: bindApiCall<ChannelsListArguments, WebAPICallResult>(this, 'channels.list'),
mark: bindApiCall<ChannelsMarkArguments, WebAPICallResult>(this, 'channels.mark'),
rename: bindApiCall<ChannelsRenameArguments, WebAPICallResult>(this, 'channels.rename'),
replies: bindApiCall<ChannelsRepliesArguments, WebAPICallResult>(this, 'channels.replies'),
setPurpose: bindApiCall<ChannelsSetPurposeArguments, WebAPICallResult>(this, 'channels.setPurpose'),
setTopic: bindApiCall<ChannelsSetTopicArguments, WebAPICallResult>(this, 'channels.setTopic'),
unarchive: bindApiCall<ChannelsUnarchiveArguments, WebAPICallResult>(this, 'channels.unarchive'),
};

public readonly chat = {
delete: bindApiCall<ChatDeleteArguments, ChatDeleteResponse>(this, 'chat.delete'),
deleteScheduledMessage:
Expand Down Expand Up @@ -473,13 +460,6 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
this, 'conversations.unarchive'),
};

public readonly views = {
open: bindApiCall<ViewsOpenArguments, ViewsOpenResponse>(this, 'views.open'),
publish: bindApiCall<ViewsPublishArguments, ViewsPublishResponse>(this, 'views.publish'),
push: bindApiCall<ViewsPushArguments, ViewsPushResponse>(this, 'views.push'),
update: bindApiCall<ViewsUpdateArguments, ViewsUpdateResponse>(this, 'views.update'),
};

public readonly dialog = {
open: bindApiCall<DialogOpenArguments, DialogOpenResponse>(this, 'dialog.open'),
};
Expand Down Expand Up @@ -518,47 +498,10 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
},
};

public readonly groups = {
archive: bindApiCall<GroupsArchiveArguments, WebAPICallResult>(this, 'groups.archive'),
create: bindApiCall<GroupsCreateArguments, WebAPICallResult>(this, 'groups.create'),
createChild: bindApiCall<GroupsCreateChildArguments, WebAPICallResult>(this, 'groups.createChild'),
history: bindApiCall<GroupsHistoryArguments, WebAPICallResult>(this, 'groups.history'),
info: bindApiCall<GroupsInfoArguments, WebAPICallResult>(this, 'groups.info'),
invite: bindApiCall<GroupsInviteArguments, WebAPICallResult>(this, 'groups.invite'),
kick: bindApiCall<GroupsKickArguments, WebAPICallResult>(this, 'groups.kick'),
leave: bindApiCall<GroupsLeaveArguments, WebAPICallResult>(this, 'groups.leave'),
list: bindApiCall<GroupsListArguments, WebAPICallResult>(this, 'groups.list'),
mark: bindApiCall<GroupsMarkArguments, WebAPICallResult>(this, 'groups.mark'),
open: bindApiCall<GroupsOpenArguments, WebAPICallResult>(this, 'groups.open'),
rename: bindApiCall<GroupsRenameArguments, WebAPICallResult>(this, 'groups.rename'),
replies: bindApiCall<GroupsRepliesArguments, WebAPICallResult>(this, 'groups.replies'),
setPurpose: bindApiCall<GroupsSetPurposeArguments, WebAPICallResult>(this, 'groups.setPurpose'),
setTopic: bindApiCall<GroupsSetTopicArguments, WebAPICallResult>(this, 'groups.setTopic'),
unarchive: bindApiCall<GroupsUnarchiveArguments, WebAPICallResult>(this, 'groups.unarchive'),
};

public readonly im = {
close: bindApiCall<IMCloseArguments, WebAPICallResult>(this, 'im.close'),
history: bindApiCall<IMHistoryArguments, WebAPICallResult>(this, 'im.history'),
list: bindApiCall<IMListArguments, WebAPICallResult>(this, 'im.list'),
mark: bindApiCall<IMMarkArguments, WebAPICallResult>(this, 'im.mark'),
open: bindApiCall<IMOpenArguments, WebAPICallResult>(this, 'im.open'),
replies: bindApiCall<IMRepliesArguments, WebAPICallResult>(this, 'im.replies'),
};

public readonly migration = {
exchange: bindApiCall<MigrationExchangeArguments, MigrationExchangeResponse>(this, 'migration.exchange'),
};

public readonly mpim = {
close: bindApiCall<MPIMCloseArguments, WebAPICallResult>(this, 'mpim.close'),
history: bindApiCall<MPIMHistoryArguments, WebAPICallResult>(this, 'mpim.history'),
list: bindApiCall<MPIMListArguments, WebAPICallResult>(this, 'mpim.list'),
mark: bindApiCall<MPIMMarkArguments, WebAPICallResult>(this, 'mpim.mark'),
open: bindApiCall<MPIMOpenArguments, WebAPICallResult>(this, 'mpim.open'),
replies: bindApiCall<MPIMRepliesArguments, WebAPICallResult>(this, 'mpim.replies'),
};

public readonly oauth = {
access: bindApiCall<OAuthAccessArguments, OauthAccessResponse>(this, 'oauth.access'),
v2: {
Expand Down Expand Up @@ -645,12 +588,79 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
},
};

public readonly views = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this one to make the list here alphabetical order

open: bindApiCall<ViewsOpenArguments, ViewsOpenResponse>(this, 'views.open'),
publish: bindApiCall<ViewsPublishArguments, ViewsPublishResponse>(this, 'views.publish'),
push: bindApiCall<ViewsPushArguments, ViewsPushResponse>(this, 'views.push'),
update: bindApiCall<ViewsUpdateArguments, ViewsUpdateResponse>(this, 'views.update'),
};

public readonly workflows = {
stepCompleted: bindApiCall<WorkflowsStepCompletedArguments, WorkflowsStepCompletedResponse>(
this, 'workflows.stepCompleted'),
stepFailed: bindApiCall<WorkflowsStepFailedArguments, WorkflowsStepFailedResponse>(this, 'workflows.stepFailed'),
updateStep: bindApiCall<WorkflowsUpdateStepArguments, WorkflowsUpdateStepResponse>(this, 'workflows.updateStep'),
};

// ---------------------------------
// Deprecated methods
// ---------------------------------

public readonly channels = {
archive: bindApiCall<ChannelsArchiveArguments, WebAPICallResult>(this, 'channels.archive'),
create: bindApiCall<ChannelsCreateArguments, WebAPICallResult>(this, 'channels.create'),
history: bindApiCall<ChannelsHistoryArguments, WebAPICallResult>(this, 'channels.history'),
info: bindApiCall<ChannelsInfoArguments, WebAPICallResult>(this, 'channels.info'),
invite: bindApiCall<ChannelsInviteArguments, WebAPICallResult>(this, 'channels.invite'),
join: bindApiCall<ChannelsJoinArguments, WebAPICallResult>(this, 'channels.join'),
kick: bindApiCall<ChannelsKickArguments, WebAPICallResult>(this, 'channels.kick'),
leave: bindApiCall<ChannelsLeaveArguments, WebAPICallResult>(this, 'channels.leave'),
list: bindApiCall<ChannelsListArguments, WebAPICallResult>(this, 'channels.list'),
mark: bindApiCall<ChannelsMarkArguments, WebAPICallResult>(this, 'channels.mark'),
rename: bindApiCall<ChannelsRenameArguments, WebAPICallResult>(this, 'channels.rename'),
replies: bindApiCall<ChannelsRepliesArguments, WebAPICallResult>(this, 'channels.replies'),
setPurpose: bindApiCall<ChannelsSetPurposeArguments, WebAPICallResult>(this, 'channels.setPurpose'),
setTopic: bindApiCall<ChannelsSetTopicArguments, WebAPICallResult>(this, 'channels.setTopic'),
unarchive: bindApiCall<ChannelsUnarchiveArguments, WebAPICallResult>(this, 'channels.unarchive'),
};

public readonly groups = {
archive: bindApiCall<GroupsArchiveArguments, WebAPICallResult>(this, 'groups.archive'),
create: bindApiCall<GroupsCreateArguments, WebAPICallResult>(this, 'groups.create'),
createChild: bindApiCall<GroupsCreateChildArguments, WebAPICallResult>(this, 'groups.createChild'),
history: bindApiCall<GroupsHistoryArguments, WebAPICallResult>(this, 'groups.history'),
info: bindApiCall<GroupsInfoArguments, WebAPICallResult>(this, 'groups.info'),
invite: bindApiCall<GroupsInviteArguments, WebAPICallResult>(this, 'groups.invite'),
kick: bindApiCall<GroupsKickArguments, WebAPICallResult>(this, 'groups.kick'),
leave: bindApiCall<GroupsLeaveArguments, WebAPICallResult>(this, 'groups.leave'),
list: bindApiCall<GroupsListArguments, WebAPICallResult>(this, 'groups.list'),
mark: bindApiCall<GroupsMarkArguments, WebAPICallResult>(this, 'groups.mark'),
open: bindApiCall<GroupsOpenArguments, WebAPICallResult>(this, 'groups.open'),
rename: bindApiCall<GroupsRenameArguments, WebAPICallResult>(this, 'groups.rename'),
replies: bindApiCall<GroupsRepliesArguments, WebAPICallResult>(this, 'groups.replies'),
setPurpose: bindApiCall<GroupsSetPurposeArguments, WebAPICallResult>(this, 'groups.setPurpose'),
setTopic: bindApiCall<GroupsSetTopicArguments, WebAPICallResult>(this, 'groups.setTopic'),
unarchive: bindApiCall<GroupsUnarchiveArguments, WebAPICallResult>(this, 'groups.unarchive'),
};

public readonly im = {
close: bindApiCall<IMCloseArguments, WebAPICallResult>(this, 'im.close'),
history: bindApiCall<IMHistoryArguments, WebAPICallResult>(this, 'im.history'),
list: bindApiCall<IMListArguments, WebAPICallResult>(this, 'im.list'),
mark: bindApiCall<IMMarkArguments, WebAPICallResult>(this, 'im.mark'),
open: bindApiCall<IMOpenArguments, WebAPICallResult>(this, 'im.open'),
replies: bindApiCall<IMRepliesArguments, WebAPICallResult>(this, 'im.replies'),
};

public readonly mpim = {
close: bindApiCall<MPIMCloseArguments, WebAPICallResult>(this, 'mpim.close'),
history: bindApiCall<MPIMHistoryArguments, WebAPICallResult>(this, 'mpim.history'),
list: bindApiCall<MPIMListArguments, WebAPICallResult>(this, 'mpim.list'),
mark: bindApiCall<MPIMMarkArguments, WebAPICallResult>(this, 'mpim.mark'),
open: bindApiCall<MPIMOpenArguments, WebAPICallResult>(this, 'mpim.open'),
replies: bindApiCall<MPIMRepliesArguments, WebAPICallResult>(this, 'mpim.replies'),
};

}

/**
Expand Down Expand Up @@ -718,6 +728,11 @@ export interface AdminAppsApprovedListArguments extends WebAPICallOptions, Token
team_id?: string;
enterprise_id?: string;
}
export interface AdminAppsClearResolutionArguments extends WebAPICallOptions {
app_id: string;
enterprise_id?: string;
team_id?: string;
}
cursorPaginationEnabledMethods.add('admin.apps.approved.list');
export interface AdminAppsRequestsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled {
team_id?: string;
Expand All @@ -734,6 +749,11 @@ export interface AdminAppsRestrictedListArguments extends WebAPICallOptions, Tok
}
cursorPaginationEnabledMethods.add('admin.apps.restricted.list');

export interface AdminAppsUninstallArguments extends WebAPICallOptions {
app_id: string;
enterprise_id?: string;
team_ids?: string[];
}
export interface AdminBarriersCreateArguments extends WebAPICallOptions, TokenOverridable {
barriered_from_usergroup_ids: string[];
primary_usergroup_id: string;
Expand Down
8 changes: 8 additions & 0 deletions packages/web-api/src/response/AdminAppsUninstallResponse.ts
@@ -0,0 +1,8 @@
/* tslint:disable */
import { WebAPICallResult } from '../WebClient';
export type AdminAppsUninstallResponse = WebAPICallResult & {
ok?: boolean;
error?: string;
needed?: string;
provided?: string;
};
Expand Up @@ -32,4 +32,5 @@ export interface Conversation {
is_pending_ext_shared?: boolean;
connected_team_ids?: string[];
conversation_host_id?: string;
channel_email_addresses?: string[];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran ./scripts/generate-web-api-types.sh

}
10 changes: 10 additions & 0 deletions packages/web-api/src/response/UsersInfoResponse.ts
Expand Up @@ -30,6 +30,16 @@ export interface User {
locale?: string;
has_2fa?: boolean;
is_email_confirmed?: boolean;
enterprise_user?: EnterpriseUser;
}

export interface EnterpriseUser {
id?: string;
enterprise_id?: string;
enterprise_name?: string;
is_admin?: boolean;
is_owner?: boolean;
teams?: string[];
}

export interface Profile {
Expand Down
1 change: 1 addition & 0 deletions packages/web-api/src/response/index.ts
Expand Up @@ -5,6 +5,7 @@ export { AdminAppsClearResolutionResponse } from './AdminAppsClearResolutionResp
export { AdminAppsRequestsListResponse } from './AdminAppsRequestsListResponse';
export { AdminAppsRestrictResponse } from './AdminAppsRestrictResponse';
export { AdminAppsRestrictedListResponse } from './AdminAppsRestrictedListResponse';
export { AdminAppsUninstallResponse } from './AdminAppsUninstallResponse';
export { AdminBarriersCreateResponse } from './AdminBarriersCreateResponse';
export { AdminBarriersDeleteResponse } from './AdminBarriersDeleteResponse';
export { AdminBarriersListResponse } from './AdminBarriersListResponse';
Expand Down