Skip to content

Commit

Permalink
list api has optional arguments. add some type tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj committed Oct 7, 2024
1 parent 3d0e9db commit 542dc03
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1778,10 +1778,10 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
* @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: bindApiCall<ConversationsRequestSharedInviteListArguments, ConversationsRequestSharedInviteListResponse>(
this,
'conversations.requestSharedInvite.list',
),
list: bindApiCallWithOptionalArgument<
ConversationsRequestSharedInviteListArguments,
ConversationsRequestSharedInviteListResponse
>(this, 'conversations.requestSharedInvite.list'),
},
/**
* @description Sets the purpose for a conversation.
Expand Down
27 changes: 15 additions & 12 deletions packages/web-api/src/types/request/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,21 @@ export interface ConversationsRequestSharedInviteApproveArguments
export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message, TokenOverridable {}

// https://api.slack.com/methods/conversations.requestSharedInvite.list
export interface ConversationsRequestSharedInviteListArguments extends 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;
}
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
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 542dc03

Please sign in to comment.