| 3162 | // All methods must be defined with arrow function syntax. See the docstring |
| 3163 | // above the ApiMethods class for a full explanation. |
| 3164 | class ExperimentalApiMethods { |
| 3165 | constructor(protected readonly axios: AxiosInstance) {} |
| 3166 | |
| 3167 | getChatsByWorkspace = async ( |
| 3168 | workspaceIds: readonly string[], |
| 3169 | ): Promise<Record<string, string>> => { |
| 3170 | const res = await this.axios.get("/api/experimental/chats/by-workspace", { |
| 3171 | params: { workspace_ids: workspaceIds.join(",") }, |
| 3172 | }); |
| 3173 | return res.data; |
| 3174 | }; |
| 3175 | |
| 3176 | uploadChatFile = async ( |
| 3177 | file: File, |
| 3178 | organizationId: string, |
| 3179 | ): Promise<TypesGen.UploadChatFileResponse> => { |
| 3180 | const response = await this.axios.post( |
| 3181 | `/api/experimental/chats/files?organization=${organizationId}`, |
| 3182 | file, |
| 3183 | { |
| 3184 | headers: { |
| 3185 | "Content-Type": file.type || "application/octet-stream", |
| 3186 | // Use RFC 5987 encoding for the filename to support |
| 3187 | // non-ASCII characters. Placing the raw name directly in |
| 3188 | // the header causes XMLHttpRequest to throw because HTTP |
| 3189 | // headers only allow ISO-8859-1 code points. |
| 3190 | "Content-Disposition": `attachment; filename="file"; filename*=UTF-8''${encodeURIComponent(file.name)}`, |
| 3191 | }, |
| 3192 | }, |
| 3193 | ); |
| 3194 | return response.data; |
| 3195 | }; |
| 3196 | |
| 3197 | getChatFileText = async (fileId: string): Promise<string> => { |
| 3198 | const response = await this.axios.get( |
| 3199 | `/api/experimental/chats/files/${fileId}`, |
| 3200 | { responseType: "text" }, |
| 3201 | ); |
| 3202 | return response.data as string; |
| 3203 | }; |
| 3204 | |
| 3205 | // Chat API methods |
| 3206 | getChatACL = async (chatId: string): Promise<TypesGen.ChatACL> => { |
| 3207 | const response = await this.axios.get<TypesGen.ChatACL>( |
| 3208 | `/api/experimental/chats/${chatId}/acl`, |
| 3209 | ); |
| 3210 | return response.data; |
| 3211 | }; |
| 3212 | |
| 3213 | updateChatACL = async ( |
| 3214 | chatId: string, |
| 3215 | req: TypesGen.UpdateChatACL, |
| 3216 | ): Promise<void> => { |
| 3217 | await this.axios.patch(`/api/experimental/chats/${chatId}/acl`, req); |
| 3218 | }; |
| 3219 | |
| 3220 | getChats = async (req?: { |
| 3221 | after_id?: string; |
nothing calls this directly
no test coverage detected