Skip to content

Commit

Permalink
Add conversations.requestSharedInvite.* APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Sep 14, 2024
1 parent 292929b commit 46ff68d
Show file tree
Hide file tree
Showing 20 changed files with 382 additions and 325 deletions.
515 changes: 208 additions & 307 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
},
"homepage": "https://github.com/seratch/slack-web-api-client#readme",
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@vitest/coverage-v8": "^2.0.5",
"msw": "^2.4.4",
"@biomejs/biome": "^1.9.0",
"@vitest/coverage-v8": "^2.1.1",
"msw": "^2.4.6",
"typescript": "^5.6.2",
"vitest": "^2.0.5"
"vitest": "^2.1.1"
},
"overrides": {
"msw": {
Expand Down
18 changes: 16 additions & 2 deletions src/client/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ import type {
ConversationsOpenRequest,
ConversationsRenameRequest,
ConversationsRepliesRequest,
ConversationsRequestSharedInviteApproveRequest,
ConversationsRequestSharedInviteDenyRequest,
ConversationsSetPurposeRequest,
ConversationsSetTopicRequest,
ConversationsUnarchiveRequest,
Expand Down Expand Up @@ -471,6 +473,8 @@ import type {
TeamExternalTeamsListResponse,
ConversationsExternalInvitePermissionsSetResponse,
TeamExternalTeamsDisconnectResponse,
ConversationsRequestSharedInviteApproveResponse,
ConversationsRequestSharedInviteDenyResponse,
} from "./generated-response/index";

import type { SlackAPIResponse } from "./response";
Expand Down Expand Up @@ -538,7 +542,7 @@ export class SlackAPIClient {
retryHandlerState: RetryHandlerState | undefined = undefined,
): Promise<SlackAPIResponse> {
const url = `${this.#baseUrl}${name}`;
const token = params ? params.token ?? this.#token : this.#token;
const token = params ? (params.token ?? this.#token) : this.#token;
// deno-lint-ignore no-explicit-any
const _params: any = {};
Object.assign(_params, params);
Expand Down Expand Up @@ -627,7 +631,7 @@ export class SlackAPIClient {
retryHandlerState: RetryHandlerState | undefined = undefined,
): Promise<SlackAPIResponse> {
const url = `${this.#baseUrl}${name}`;
const token = params ? params.token ?? this.#token : this.#token;
const token = params ? (params.token ?? this.#token) : this.#token;
const body = new FormData();
for (const [key, value] of Object.entries(params)) {
if (value === undefined || value === null || key === "token") {
Expand Down Expand Up @@ -904,6 +908,16 @@ export class SlackAPIClient {
AdminConversationsRestrictAccessRemoveGroupResponse
>(this, "admin.conversations.restrictAccess.removeGroup"),
},
requestSharedInvite: {
approve: this.#bindApiCall<ConversationsRequestSharedInviteApproveRequest, ConversationsRequestSharedInviteApproveResponse>(
this,
"conversations.requestSharedInvite.approve",
),
deny: this.#bindApiCall<ConversationsRequestSharedInviteDenyRequest, ConversationsRequestSharedInviteDenyResponse>(
this,
"conversations.requestSharedInvite.deny",
),
},
getCustomRetention: this.#bindApiCall<AdminConversationsGetCustomRetentionRequest, AdminConversationsGetCustomRetentionResponse>(
this,
"admin.conversations.getCustomRetention",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ export type ConversationsListConnectInvitesResponse = SlackAPIResponse & {
export interface InviteElement {
acceptances?: Acceptance[];
channel?: Channel;
date_created?: number;
date_invalid?: number;
date_last_updated?: number;
direction?: string;
id?: string;
invite?: InviteInvite;
invite_payload?: InvitePayload;
invite_type?: string;
inviting_team?: IngTeam;
inviting_user?: TingUser;
link?: string;
recipient_user_id?: string;
sig?: string;
status?: string;
}

Expand All @@ -42,6 +51,7 @@ export interface IngTeam {
id?: string;
is_verified?: boolean;
name?: string;
requires_sponsorship?: boolean;
}

export interface Icon {
Expand Down Expand Up @@ -106,6 +116,14 @@ export interface InviteInvite {
link?: string;
recipient_email?: string;
recipient_user_id?: string;
sig?: string;
}

export interface InvitePayload {
channel?: Channel;
invite_type?: string;
is_external_limited?: boolean;
is_sponsored?: boolean;
}

export interface ResponseMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// deno-lint-ignore-file ban-unused-ignore no-explicit-any no-empty-interface
///////////////////////////////////
// !!! DO NOT EDIT THIS FILE !!! //
///////////////////////////////////

import type { SlackAPIResponse } from "../response";
export type ConversationsRequestSharedInviteApproveResponse = SlackAPIResponse & {
error?: string;
invite_id?: string;
needed?: string;
ok: boolean;
provided?: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// deno-lint-ignore-file ban-unused-ignore no-explicit-any no-empty-interface
///////////////////////////////////
// !!! DO NOT EDIT THIS FILE !!! //
///////////////////////////////////

import type { SlackAPIResponse } from "../response";
export type ConversationsRequestSharedInviteDenyResponse = SlackAPIResponse & {
error?: string;
invite_id?: string;
needed?: string;
ok: boolean;
provided?: string;
};
4 changes: 2 additions & 2 deletions src/client/generated-response/SearchAllResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface FilesMatch {
dm_mpdm_users_with_file_access?: DmMpdmUsersWithFileAccess[];
edit_link?: string;
editable?: boolean;
editors?: LastEditor[];
editors?: string[];
editors_count?: number;
external_id?: string;
external_type?: string;
Expand Down Expand Up @@ -993,7 +993,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/client/generated-response/SearchFilesResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface Match {
dm_mpdm_users_with_file_access?: DmMpdmUsersWithFileAccess[];
edit_link?: string;
editable?: boolean;
editors?: LastEditor[];
editors?: string[];
editors_count?: number;
external_id?: string;
external_type?: string;
Expand Down Expand Up @@ -972,7 +972,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/client/generated-response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export type { ConversationsMembersResponse } from "./ConversationsMembersRespons
export type { ConversationsOpenResponse } from "./ConversationsOpenResponse";
export type { ConversationsRenameResponse } from "./ConversationsRenameResponse";
export type { ConversationsRepliesResponse } from "./ConversationsRepliesResponse";
export type { ConversationsRequestSharedInviteApproveResponse } from "./ConversationsRequestSharedInviteApproveResponse";
export type { ConversationsRequestSharedInviteDenyResponse } from "./ConversationsRequestSharedInviteDenyResponse";
export type { ConversationsSetPurposeResponse } from "./ConversationsSetPurposeResponse";
export type { ConversationsSetTopicResponse } from "./ConversationsSetTopicResponse";
export type { ConversationsUnarchiveResponse } from "./ConversationsUnarchiveResponse";
Expand Down
13 changes: 13 additions & 0 deletions src/client/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,19 @@ export interface ConversationsExternalInvitePermissionsSetRequest extends SlackA
channel: string;
target_team: string;
}
export interface ConversationsRequestSharedInviteApproveRequest extends SlackAPIRequest {
invite_id: string;
team_id?: string;
is_external_limited?: boolean;
message?: {
text: string;
is_override: boolean;
};
}
export interface ConversationsRequestSharedInviteDenyRequest extends SlackAPIRequest {
invite_id: string;
message: string;
}

/*
* `dnd.*`
Expand Down
24 changes: 22 additions & 2 deletions src_deno/client/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ import type {
ConversationsOpenRequest,
ConversationsRenameRequest,
ConversationsRepliesRequest,
ConversationsRequestSharedInviteApproveRequest,
ConversationsRequestSharedInviteDenyRequest,
ConversationsSetPurposeRequest,
ConversationsSetTopicRequest,
ConversationsUnarchiveRequest,
Expand Down Expand Up @@ -390,6 +392,8 @@ import type {
ConversationsOpenResponse,
ConversationsRenameResponse,
ConversationsRepliesResponse,
ConversationsRequestSharedInviteApproveResponse,
ConversationsRequestSharedInviteDenyResponse,
ConversationsSetPurposeResponse,
ConversationsSetTopicResponse,
ConversationsUnarchiveResponse,
Expand Down Expand Up @@ -548,7 +552,7 @@ export class SlackAPIClient {
retryHandlerState: RetryHandlerState | undefined = undefined,
): Promise<SlackAPIResponse> {
const url = `${this.#baseUrl}${name}`;
const token = params ? params.token ?? this.#token : this.#token;
const token = params ? (params.token ?? this.#token) : this.#token;
// deno-lint-ignore no-explicit-any
const _params: any = {};
Object.assign(_params, params);
Expand Down Expand Up @@ -656,7 +660,7 @@ export class SlackAPIClient {
retryHandlerState: RetryHandlerState | undefined = undefined,
): Promise<SlackAPIResponse> {
const url = `${this.#baseUrl}${name}`;
const token = params ? params.token ?? this.#token : this.#token;
const token = params ? (params.token ?? this.#token) : this.#token;
const body = new FormData();
for (const [key, value] of Object.entries(params)) {
if (value === undefined || value === null || key === "token") {
Expand Down Expand Up @@ -1064,6 +1068,22 @@ export class SlackAPIClient {
AdminConversationsRestrictAccessRemoveGroupResponse
>(this, "admin.conversations.restrictAccess.removeGroup"),
},
requestSharedInvite: {
approve: this.#bindApiCall<
ConversationsRequestSharedInviteApproveRequest,
ConversationsRequestSharedInviteApproveResponse
>(
this,
"conversations.requestSharedInvite.approve",
),
deny: this.#bindApiCall<
ConversationsRequestSharedInviteDenyRequest,
ConversationsRequestSharedInviteDenyResponse
>(
this,
"conversations.requestSharedInvite.deny",
),
},
getCustomRetention: this.#bindApiCall<
AdminConversationsGetCustomRetentionRequest,
AdminConversationsGetCustomRetentionResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ export type ConversationsListConnectInvitesResponse = SlackAPIResponse & {
export interface InviteElement {
acceptances?: Acceptance[];
channel?: Channel;
date_created?: number;
date_invalid?: number;
date_last_updated?: number;
direction?: string;
id?: string;
invite?: InviteInvite;
invite_payload?: InvitePayload;
invite_type?: string;
inviting_team?: IngTeam;
inviting_user?: TingUser;
link?: string;
recipient_user_id?: string;
sig?: string;
status?: string;
}

Expand All @@ -42,6 +51,7 @@ export interface IngTeam {
id?: string;
is_verified?: boolean;
name?: string;
requires_sponsorship?: boolean;
}

export interface Icon {
Expand Down Expand Up @@ -106,6 +116,14 @@ export interface InviteInvite {
link?: string;
recipient_email?: string;
recipient_user_id?: string;
sig?: string;
}

export interface InvitePayload {
channel?: Channel;
invite_type?: string;
is_external_limited?: boolean;
is_sponsored?: boolean;
}

export interface ResponseMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// deno-lint-ignore-file ban-unused-ignore no-explicit-any no-empty-interface
///////////////////////////////////
// !!! DO NOT EDIT THIS FILE !!! //
///////////////////////////////////

import type { SlackAPIResponse } from "../response.ts";
export type ConversationsRequestSharedInviteApproveResponse =
& SlackAPIResponse
& {
error?: string;
invite_id?: string;
needed?: string;
ok: boolean;
provided?: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// deno-lint-ignore-file ban-unused-ignore no-explicit-any no-empty-interface
///////////////////////////////////
// !!! DO NOT EDIT THIS FILE !!! //
///////////////////////////////////

import type { SlackAPIResponse } from "../response.ts";
export type ConversationsRequestSharedInviteDenyResponse = SlackAPIResponse & {
error?: string;
invite_id?: string;
needed?: string;
ok: boolean;
provided?: string;
};
4 changes: 2 additions & 2 deletions src_deno/client/generated-response/SearchAllResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface FilesMatch {
dm_mpdm_users_with_file_access?: DmMpdmUsersWithFileAccess[];
edit_link?: string;
editable?: boolean;
editors?: LastEditor[];
editors?: string[];
editors_count?: number;
external_id?: string;
external_type?: string;
Expand Down Expand Up @@ -993,7 +993,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src_deno/client/generated-response/SearchFilesResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface Match {
dm_mpdm_users_with_file_access?: DmMpdmUsersWithFileAccess[];
edit_link?: string;
editable?: boolean;
editors?: LastEditor[];
editors?: string[];
editors_count?: number;
external_id?: string;
external_type?: string;
Expand Down Expand Up @@ -972,7 +972,7 @@ export interface Comment {
preview_is_truncated?: boolean;
public_url_shared?: boolean;
size?: number;
timestamp?: number;
timestamp?: string;
title?: string;
url_private?: string;
url_private_download?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src_deno/client/generated-response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export type { ConversationsMembersResponse } from "./ConversationsMembersRespons
export type { ConversationsOpenResponse } from "./ConversationsOpenResponse.ts";
export type { ConversationsRenameResponse } from "./ConversationsRenameResponse.ts";
export type { ConversationsRepliesResponse } from "./ConversationsRepliesResponse.ts";
export type { ConversationsRequestSharedInviteApproveResponse } from "./ConversationsRequestSharedInviteApproveResponse.ts";
export type { ConversationsRequestSharedInviteDenyResponse } from "./ConversationsRequestSharedInviteDenyResponse.ts";
export type { ConversationsSetPurposeResponse } from "./ConversationsSetPurposeResponse.ts";
export type { ConversationsSetTopicResponse } from "./ConversationsSetTopicResponse.ts";
export type { ConversationsUnarchiveResponse } from "./ConversationsUnarchiveResponse.ts";
Expand Down
Loading

0 comments on commit 46ff68d

Please sign in to comment.