Skip to content

Commit

Permalink
web-api(feat): add support for conversations.requestShared.list API (
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj authored and mtjandra committed Oct 16, 2024
1 parent 57ac6a7 commit 5f20c92
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ import type {
ConversationsRepliesArguments,
ConversationsRequestSharedInviteApproveArguments,
ConversationsRequestSharedInviteDenyArguments,
ConversationsRequestSharedInviteListArguments,
ConversationsSetPurposeArguments,
ConversationsSetTopicArguments,
ConversationsUnarchiveArguments,
Expand Down Expand Up @@ -417,6 +418,7 @@ import type {
ConversationsRepliesResponse,
ConversationsRequestSharedInviteApproveResponse,
ConversationsRequestSharedInviteDenyResponse,
ConversationsRequestSharedInviteListResponse,
ConversationsSetPurposeResponse,
ConversationsSetTopicResponse,
ConversationsUnarchiveResponse,
Expand Down Expand Up @@ -1772,6 +1774,14 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
this,
'conversations.requestSharedInvite.deny',
),
/**
* @description Lists requests to add external users to channels with ability to filter.
* @see {@link https://api.slack.com/methods/conversations.requestSharedInvite.list `conversations.requestSharedInvite.list` API reference}.
*/
list: bindApiCallWithOptionalArgument<
ConversationsRequestSharedInviteListArguments,
ConversationsRequestSharedInviteListResponse
>(this, 'conversations.requestSharedInvite.list'),
},
/**
* @description Sets the purpose for a conversation.
Expand Down
24 changes: 22 additions & 2 deletions packages/web-api/src/types/request/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ export interface ConversationsRepliesArguments
TimelinePaginationEnabled {}

// https://api.slack.com/methods/conversations.requestSharedInvite.approve
export interface ConversationsRequestSharedInviteApproveArguments extends InviteID, Partial<ChannelID> {
export interface ConversationsRequestSharedInviteApproveArguments
extends InviteID,
Partial<ChannelID>,
TokenOverridable {
/**
* @description Whether the invited team will have post-only permissions in the channel.
* Will override the value on the requested invite.
Expand All @@ -211,7 +214,24 @@ export interface ConversationsRequestSharedInviteApproveArguments extends Invite
}

// https://api.slack.com/methods/conversations.requestSharedInvite.deny
export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message {}
export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message, TokenOverridable {}

// https://api.slack.com/methods/conversations.requestSharedInvite.list
export type ConversationsRequestSharedInviteListArguments = OptionalArgument<
CursorPaginationEnabled &
TokenOverridable & {
/** @description When `true` approved invitation requests will be returned, otherwise they will be excluded. */
include_approved?: boolean;
/** @description When `true` denied invitation requests will be returned, otherwise they will be excluded. */
include_denied?: boolean;
/** @description When `true` expired invitation requests will be returned, otherwise they will be excluded. */
include_expired?: boolean;
/** @description An optional list of invitation ids to look up. */
invite_ids?: string[];
/** @description Optional filter to return invitation requests for the inviting user. */
user_id?: string;
}
>;

// https://api.slack.com/methods/conversations.setPurpose
export interface ConversationsSetPurposeArguments extends Channel, TokenOverridable {
Expand Down
1 change: 1 addition & 0 deletions packages/web-api/src/types/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type {
ConversationsRepliesArguments,
ConversationsRequestSharedInviteApproveArguments,
ConversationsRequestSharedInviteDenyArguments,
ConversationsRequestSharedInviteListArguments,
ConversationsSetPurposeArguments,
ConversationsSetTopicArguments,
ConversationsUnarchiveArguments,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
// //
// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. //
// Please refer to the script code to learn how to update the source data. //
// //
/////////////////////////////////////////////////////////////////////////////////////////

import type { WebAPICallResult } from '../../WebClient';
export type ConversationsRequestSharedInviteListResponse = WebAPICallResult & {
invite_requests?: InviteRequest[];
ok?: boolean;
};

export interface InviteRequest {
channel?: Channel;
date_created?: number;
date_last_updated?: number;
expires_at?: number;
id?: string;
inviting_team?: Team;
inviting_user?: InvitingUser;
is_external_limited?: boolean;
target_user?: TargetUser;
}

export interface Channel {
connections?: Connection[];
date_created?: number;
id?: string;
is_im?: boolean;
is_private?: boolean;
name?: string;
pending_connections?: any[];
previous_connections?: any[];
}

export interface Connection {
is_private?: boolean;
team?: Team;
}

export interface Team {
avatar_base_url?: string;
date_created?: number;
domain?: string;
icon?: Icon;
id?: string;
is_verified?: boolean;
name?: string;
requires_sponsorship?: boolean;
}

export interface Icon {
image_102?: string;
image_132?: string;
image_230?: string;
image_34?: string;
image_44?: string;
image_68?: string;
image_88?: string;
image_default?: boolean;
}

export interface InvitingUser {
id?: string;
name?: string;
profile?: Profile;
team_id?: string;
updated?: number;
who_can_share_contact_card?: string;
}

export interface Profile {
avatar_hash?: string;
display_name?: string;
display_name_normalized?: string;
email?: string;
image_192?: string;
image_24?: string;
image_32?: string;
image_48?: string;
image_512?: string;
image_72?: string;
real_name?: string;
real_name_normalized?: string;
team?: string;
}

export interface TargetUser {
recipient_email?: string;
}
1 change: 1 addition & 0 deletions packages/web-api/src/types/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export { ConversationsRenameResponse } from './ConversationsRenameResponse';
export { ConversationsRepliesResponse } from './ConversationsRepliesResponse';
export { ConversationsRequestSharedInviteApproveResponse } from './ConversationsRequestSharedInviteApproveResponse';
export { ConversationsRequestSharedInviteDenyResponse } from './ConversationsRequestSharedInviteDenyResponse';
export { ConversationsRequestSharedInviteListResponse } from './ConversationsRequestSharedInviteListResponse';
export { ConversationsSetPurposeResponse } from './ConversationsSetPurposeResponse';
export { ConversationsSetTopicResponse } from './ConversationsSetTopicResponse';
export { ConversationsUnarchiveResponse } from './ConversationsUnarchiveResponse';
Expand Down
6 changes: 6 additions & 0 deletions packages/web-api/test/types/methods/conversations.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@ expectAssignable<Parameters<typeof web.conversations.requestSharedInvite.deny>>(
},
]);

// conversations.requestSharedInvite.list
// -- sad path
// -- happy path
expectAssignable<Parameters<typeof web.conversations.requestSharedInvite.list>>([{}]); // all optional args
expectAssignable<Parameters<typeof web.conversations.requestSharedInvite.list>>([]); // no arg is fine

// conversations.setPurpose
// -- sad path
expectError(web.conversations.setPurpose()); // lacking argument
Expand Down

0 comments on commit 5f20c92

Please sign in to comment.