mezon-js 2.7.6 → 2.7.8
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +229 -161
- package/client.ts +31 -0
- package/dist/api.gen.d.ts +25 -10
- package/dist/client.d.ts +3 -1
- package/dist/mezon-js.cjs.js +110 -50
- package/dist/mezon-js.esm.mjs +110 -50
- package/package.json +1 -1
package/api.gen.ts
CHANGED
@@ -172,6 +172,28 @@ export interface ApiCategoryDescList {
|
|
172
172
|
categorydesc?: Array<ApiCategoryDesc>;
|
173
173
|
}
|
174
174
|
|
175
|
+
/** */
|
176
|
+
export interface ApiChannelAttachment {
|
177
|
+
//
|
178
|
+
filename?: string;
|
179
|
+
//
|
180
|
+
filesize?: string;
|
181
|
+
//
|
182
|
+
filetype?: string;
|
183
|
+
//
|
184
|
+
id?: string;
|
185
|
+
//
|
186
|
+
uploader?: string;
|
187
|
+
//
|
188
|
+
url?: string;
|
189
|
+
}
|
190
|
+
|
191
|
+
/** */
|
192
|
+
export interface ApiChannelAttachmentList {
|
193
|
+
//
|
194
|
+
attachments?: Array<ApiChannelAttachment>;
|
195
|
+
}
|
196
|
+
|
175
197
|
/** A list of channel description, usually a result of a list operation. */
|
176
198
|
export interface ApiChannelDescList {
|
177
199
|
//Cacheable cursor to list newer channel description. Durable and designed to be stored, unlike next/prev cursors.
|
@@ -673,7 +695,7 @@ export interface ApiRole {
|
|
673
695
|
//
|
674
696
|
role_channel_active?: string;
|
675
697
|
//
|
676
|
-
|
698
|
+
channel_ids?: Array<string>;
|
677
699
|
}
|
678
700
|
|
679
701
|
/** A list of role description, usually a result of a list operation. */
|
@@ -2222,161 +2244,6 @@ export class MezonApi {
|
|
2222
2244
|
]);
|
2223
2245
|
}
|
2224
2246
|
|
2225
|
-
/** List user channels */
|
2226
|
-
listChannelDescs(bearerToken: string,
|
2227
|
-
limit?:number,
|
2228
|
-
state?:number,
|
2229
|
-
cursor?:string,
|
2230
|
-
clanId?:string,
|
2231
|
-
channelType?:number,
|
2232
|
-
options: any = {}): Promise<ApiChannelDescList> {
|
2233
|
-
|
2234
|
-
const urlPath = "/v2/channeldesc";
|
2235
|
-
const queryParams = new Map<string, any>();
|
2236
|
-
queryParams.set("limit", limit);
|
2237
|
-
queryParams.set("state", state);
|
2238
|
-
queryParams.set("cursor", cursor);
|
2239
|
-
queryParams.set("clan_id", clanId);
|
2240
|
-
queryParams.set("channel_type", channelType);
|
2241
|
-
|
2242
|
-
let bodyJson : string = "";
|
2243
|
-
|
2244
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2245
|
-
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
2246
|
-
if (bearerToken) {
|
2247
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2248
|
-
}
|
2249
|
-
|
2250
|
-
return Promise.race([
|
2251
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2252
|
-
if (response.status == 204) {
|
2253
|
-
return response;
|
2254
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2255
|
-
return response.json();
|
2256
|
-
} else {
|
2257
|
-
throw response;
|
2258
|
-
}
|
2259
|
-
}),
|
2260
|
-
new Promise((_, reject) =>
|
2261
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2262
|
-
),
|
2263
|
-
]);
|
2264
|
-
}
|
2265
|
-
|
2266
|
-
/** Create a new channel with the current user as the owner. */
|
2267
|
-
createChannelDesc(bearerToken: string,
|
2268
|
-
body:ApiCreateChannelDescRequest,
|
2269
|
-
options: any = {}): Promise<ApiChannelDescription> {
|
2270
|
-
|
2271
|
-
if (body === null || body === undefined) {
|
2272
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2273
|
-
}
|
2274
|
-
const urlPath = "/v2/channeldesc";
|
2275
|
-
const queryParams = new Map<string, any>();
|
2276
|
-
|
2277
|
-
let bodyJson : string = "";
|
2278
|
-
bodyJson = JSON.stringify(body || {});
|
2279
|
-
|
2280
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2281
|
-
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2282
|
-
if (bearerToken) {
|
2283
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2284
|
-
}
|
2285
|
-
|
2286
|
-
return Promise.race([
|
2287
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2288
|
-
if (response.status == 204) {
|
2289
|
-
return response;
|
2290
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2291
|
-
return response.json();
|
2292
|
-
} else {
|
2293
|
-
throw response;
|
2294
|
-
}
|
2295
|
-
}),
|
2296
|
-
new Promise((_, reject) =>
|
2297
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2298
|
-
),
|
2299
|
-
]);
|
2300
|
-
}
|
2301
|
-
|
2302
|
-
|
2303
|
-
/** Delete a channel by ID. */
|
2304
|
-
deleteChannelDesc(bearerToken: string,
|
2305
|
-
channelId:string,
|
2306
|
-
options: any = {}): Promise<any> {
|
2307
|
-
|
2308
|
-
if (channelId === null || channelId === undefined) {
|
2309
|
-
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2310
|
-
}
|
2311
|
-
const urlPath = "/v2/channeldesc/{channelId}"
|
2312
|
-
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2313
|
-
const queryParams = new Map<string, any>();
|
2314
|
-
|
2315
|
-
let bodyJson : string = "";
|
2316
|
-
|
2317
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2318
|
-
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
2319
|
-
if (bearerToken) {
|
2320
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2321
|
-
}
|
2322
|
-
|
2323
|
-
return Promise.race([
|
2324
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2325
|
-
if (response.status == 204) {
|
2326
|
-
return response;
|
2327
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2328
|
-
return response.json();
|
2329
|
-
} else {
|
2330
|
-
throw response;
|
2331
|
-
}
|
2332
|
-
}),
|
2333
|
-
new Promise((_, reject) =>
|
2334
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2335
|
-
),
|
2336
|
-
]);
|
2337
|
-
}
|
2338
|
-
|
2339
|
-
/** Update fields in a given channel. */
|
2340
|
-
updateChannelDesc(bearerToken: string,
|
2341
|
-
channelId:string,
|
2342
|
-
body:{},
|
2343
|
-
options: any = {}): Promise<any> {
|
2344
|
-
|
2345
|
-
if (channelId === null || channelId === undefined) {
|
2346
|
-
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2347
|
-
}
|
2348
|
-
if (body === null || body === undefined) {
|
2349
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
2350
|
-
}
|
2351
|
-
const urlPath = "/v2/channeldesc/{channelId}"
|
2352
|
-
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2353
|
-
const queryParams = new Map<string, any>();
|
2354
|
-
|
2355
|
-
let bodyJson : string = "";
|
2356
|
-
bodyJson = JSON.stringify(body || {});
|
2357
|
-
|
2358
|
-
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2359
|
-
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2360
|
-
if (bearerToken) {
|
2361
|
-
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2362
|
-
}
|
2363
|
-
|
2364
|
-
return Promise.race([
|
2365
|
-
fetch(fullUrl, fetchOptions).then((response) => {
|
2366
|
-
if (response.status == 204) {
|
2367
|
-
return response;
|
2368
|
-
} else if (response.status >= 200 && response.status < 300) {
|
2369
|
-
return response.json();
|
2370
|
-
} else {
|
2371
|
-
throw response;
|
2372
|
-
}
|
2373
|
-
}),
|
2374
|
-
new Promise((_, reject) =>
|
2375
|
-
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2376
|
-
),
|
2377
|
-
]);
|
2378
|
-
}
|
2379
|
-
|
2380
2247
|
/** Add users to a channel. */
|
2381
2248
|
addChannelUsers(bearerToken: string,
|
2382
2249
|
channelId:string,
|
@@ -2386,7 +2253,7 @@ export class MezonApi {
|
|
2386
2253
|
if (channelId === null || channelId === undefined) {
|
2387
2254
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2388
2255
|
}
|
2389
|
-
const urlPath = "/v2/
|
2256
|
+
const urlPath = "/v2/channel/{channelId}/add"
|
2390
2257
|
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2391
2258
|
const queryParams = new Map<string, any>();
|
2392
2259
|
queryParams.set("user_ids", userIds);
|
@@ -2415,6 +2282,52 @@ export class MezonApi {
|
|
2415
2282
|
]);
|
2416
2283
|
}
|
2417
2284
|
|
2285
|
+
/** List all attachment that are part of a channel. */
|
2286
|
+
listChannelAttachment(bearerToken: string,
|
2287
|
+
channelId:string,
|
2288
|
+
clanId?:string,
|
2289
|
+
fileType?:string,
|
2290
|
+
limit?:number,
|
2291
|
+
state?:number,
|
2292
|
+
cursor?:string,
|
2293
|
+
options: any = {}): Promise<ApiChannelAttachmentList> {
|
2294
|
+
|
2295
|
+
if (channelId === null || channelId === undefined) {
|
2296
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2297
|
+
}
|
2298
|
+
const urlPath = "/v2/channel/{channelId}/attachment"
|
2299
|
+
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2300
|
+
const queryParams = new Map<string, any>();
|
2301
|
+
queryParams.set("clan_id", clanId);
|
2302
|
+
queryParams.set("file_type", fileType);
|
2303
|
+
queryParams.set("limit", limit);
|
2304
|
+
queryParams.set("state", state);
|
2305
|
+
queryParams.set("cursor", cursor);
|
2306
|
+
|
2307
|
+
let bodyJson : string = "";
|
2308
|
+
|
2309
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2310
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
2311
|
+
if (bearerToken) {
|
2312
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2313
|
+
}
|
2314
|
+
|
2315
|
+
return Promise.race([
|
2316
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2317
|
+
if (response.status == 204) {
|
2318
|
+
return response;
|
2319
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2320
|
+
return response.json();
|
2321
|
+
} else {
|
2322
|
+
throw response;
|
2323
|
+
}
|
2324
|
+
}),
|
2325
|
+
new Promise((_, reject) =>
|
2326
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2327
|
+
),
|
2328
|
+
]);
|
2329
|
+
}
|
2330
|
+
|
2418
2331
|
/** Leave a channel the user is a member of. */
|
2419
2332
|
leaveChannel(bearerToken: string,
|
2420
2333
|
channelId:string,
|
@@ -2423,7 +2336,7 @@ export class MezonApi {
|
|
2423
2336
|
if (channelId === null || channelId === undefined) {
|
2424
2337
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2425
2338
|
}
|
2426
|
-
const urlPath = "/v2/
|
2339
|
+
const urlPath = "/v2/channel/{channelId}/leave"
|
2427
2340
|
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2428
2341
|
const queryParams = new Map<string, any>();
|
2429
2342
|
|
@@ -2460,7 +2373,7 @@ export class MezonApi {
|
|
2460
2373
|
if (channelId === null || channelId === undefined) {
|
2461
2374
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2462
2375
|
}
|
2463
|
-
const urlPath = "/v2/
|
2376
|
+
const urlPath = "/v2/channel/{channelId}/remove"
|
2464
2377
|
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2465
2378
|
const queryParams = new Map<string, any>();
|
2466
2379
|
queryParams.set("user_ids", userIds);
|
@@ -2502,7 +2415,7 @@ export class MezonApi {
|
|
2502
2415
|
if (channelId === null || channelId === undefined) {
|
2503
2416
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2504
2417
|
}
|
2505
|
-
const urlPath = "/v2/
|
2418
|
+
const urlPath = "/v2/channel/{channelId}/user"
|
2506
2419
|
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2507
2420
|
const queryParams = new Map<string, any>();
|
2508
2421
|
queryParams.set("clan_id", clanId);
|
@@ -2535,6 +2448,161 @@ export class MezonApi {
|
|
2535
2448
|
]);
|
2536
2449
|
}
|
2537
2450
|
|
2451
|
+
/** List user channels */
|
2452
|
+
listChannelDescs(bearerToken: string,
|
2453
|
+
limit?:number,
|
2454
|
+
state?:number,
|
2455
|
+
cursor?:string,
|
2456
|
+
clanId?:string,
|
2457
|
+
channelType?:number,
|
2458
|
+
options: any = {}): Promise<ApiChannelDescList> {
|
2459
|
+
|
2460
|
+
const urlPath = "/v2/channeldesc";
|
2461
|
+
const queryParams = new Map<string, any>();
|
2462
|
+
queryParams.set("limit", limit);
|
2463
|
+
queryParams.set("state", state);
|
2464
|
+
queryParams.set("cursor", cursor);
|
2465
|
+
queryParams.set("clan_id", clanId);
|
2466
|
+
queryParams.set("channel_type", channelType);
|
2467
|
+
|
2468
|
+
let bodyJson : string = "";
|
2469
|
+
|
2470
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2471
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
2472
|
+
if (bearerToken) {
|
2473
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2474
|
+
}
|
2475
|
+
|
2476
|
+
return Promise.race([
|
2477
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2478
|
+
if (response.status == 204) {
|
2479
|
+
return response;
|
2480
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2481
|
+
return response.json();
|
2482
|
+
} else {
|
2483
|
+
throw response;
|
2484
|
+
}
|
2485
|
+
}),
|
2486
|
+
new Promise((_, reject) =>
|
2487
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2488
|
+
),
|
2489
|
+
]);
|
2490
|
+
}
|
2491
|
+
|
2492
|
+
/** Create a new channel with the current user as the owner. */
|
2493
|
+
createChannelDesc(bearerToken: string,
|
2494
|
+
body:ApiCreateChannelDescRequest,
|
2495
|
+
options: any = {}): Promise<ApiChannelDescription> {
|
2496
|
+
|
2497
|
+
if (body === null || body === undefined) {
|
2498
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2499
|
+
}
|
2500
|
+
const urlPath = "/v2/channeldesc";
|
2501
|
+
const queryParams = new Map<string, any>();
|
2502
|
+
|
2503
|
+
let bodyJson : string = "";
|
2504
|
+
bodyJson = JSON.stringify(body || {});
|
2505
|
+
|
2506
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2507
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
2508
|
+
if (bearerToken) {
|
2509
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2510
|
+
}
|
2511
|
+
|
2512
|
+
return Promise.race([
|
2513
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2514
|
+
if (response.status == 204) {
|
2515
|
+
return response;
|
2516
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2517
|
+
return response.json();
|
2518
|
+
} else {
|
2519
|
+
throw response;
|
2520
|
+
}
|
2521
|
+
}),
|
2522
|
+
new Promise((_, reject) =>
|
2523
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2524
|
+
),
|
2525
|
+
]);
|
2526
|
+
}
|
2527
|
+
|
2528
|
+
|
2529
|
+
/** Delete a channel by ID. */
|
2530
|
+
deleteChannelDesc(bearerToken: string,
|
2531
|
+
channelId:string,
|
2532
|
+
options: any = {}): Promise<any> {
|
2533
|
+
|
2534
|
+
if (channelId === null || channelId === undefined) {
|
2535
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2536
|
+
}
|
2537
|
+
const urlPath = "/v2/channeldesc/{channelId}"
|
2538
|
+
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2539
|
+
const queryParams = new Map<string, any>();
|
2540
|
+
|
2541
|
+
let bodyJson : string = "";
|
2542
|
+
|
2543
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2544
|
+
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
2545
|
+
if (bearerToken) {
|
2546
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2547
|
+
}
|
2548
|
+
|
2549
|
+
return Promise.race([
|
2550
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2551
|
+
if (response.status == 204) {
|
2552
|
+
return response;
|
2553
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2554
|
+
return response.json();
|
2555
|
+
} else {
|
2556
|
+
throw response;
|
2557
|
+
}
|
2558
|
+
}),
|
2559
|
+
new Promise((_, reject) =>
|
2560
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2561
|
+
),
|
2562
|
+
]);
|
2563
|
+
}
|
2564
|
+
|
2565
|
+
/** Update fields in a given channel. */
|
2566
|
+
updateChannelDesc(bearerToken: string,
|
2567
|
+
channelId:string,
|
2568
|
+
body:{},
|
2569
|
+
options: any = {}): Promise<any> {
|
2570
|
+
|
2571
|
+
if (channelId === null || channelId === undefined) {
|
2572
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
2573
|
+
}
|
2574
|
+
if (body === null || body === undefined) {
|
2575
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
2576
|
+
}
|
2577
|
+
const urlPath = "/v2/channeldesc/{channelId}"
|
2578
|
+
.replace("{channelId}", encodeURIComponent(String(channelId)));
|
2579
|
+
const queryParams = new Map<string, any>();
|
2580
|
+
|
2581
|
+
let bodyJson : string = "";
|
2582
|
+
bodyJson = JSON.stringify(body || {});
|
2583
|
+
|
2584
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
2585
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
2586
|
+
if (bearerToken) {
|
2587
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
2588
|
+
}
|
2589
|
+
|
2590
|
+
return Promise.race([
|
2591
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
2592
|
+
if (response.status == 204) {
|
2593
|
+
return response;
|
2594
|
+
} else if (response.status >= 200 && response.status < 300) {
|
2595
|
+
return response.json();
|
2596
|
+
} else {
|
2597
|
+
throw response;
|
2598
|
+
}
|
2599
|
+
}),
|
2600
|
+
new Promise((_, reject) =>
|
2601
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
2602
|
+
),
|
2603
|
+
]);
|
2604
|
+
}
|
2605
|
+
|
2538
2606
|
/** List all users that are part of a channel. */
|
2539
2607
|
listChannelVoiceUsers(bearerToken: string,
|
2540
2608
|
clanId?:string,
|
@@ -4225,7 +4293,7 @@ export class MezonApi {
|
|
4225
4293
|
/** Create a new group with the current user as the owner. */
|
4226
4294
|
uploadAttachmentFile(bearerToken: string,
|
4227
4295
|
body:ApiUploadAttachmentRequest,
|
4228
|
-
options: any = {}): Promise<
|
4296
|
+
options: any = {}): Promise<ApiUploadAttachment> {
|
4229
4297
|
|
4230
4298
|
if (body === null || body === undefined) {
|
4231
4299
|
throw new Error("'body' is a required parameter but is null or undefined.");
|
package/client.ts
CHANGED
@@ -73,6 +73,7 @@ import {
|
|
73
73
|
ApiMessageRef,
|
74
74
|
ApiChannelMessageHeader,
|
75
75
|
ApiVoiceChannelUserList,
|
76
|
+
ApiChannelAttachmentList,
|
76
77
|
} from "./api.gen";
|
77
78
|
|
78
79
|
import { Session } from "./session";
|
@@ -1062,6 +1063,36 @@ export class Client {
|
|
1062
1063
|
});
|
1063
1064
|
}
|
1064
1065
|
|
1066
|
+
/** List a channel's attachment. */
|
1067
|
+
async listChannelAttachments(session: Session, clanId: string, channelId: string, fileType: string, state?: number, limit?: number, cursor?: string): Promise<ApiChannelAttachmentList> {
|
1068
|
+
if (this.autoRefreshSession && session.refresh_token &&
|
1069
|
+
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
1070
|
+
await this.sessionRefresh(session);
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
return this.apiClient.listChannelAttachment(session.token, clanId, channelId, fileType, limit, state, cursor).then((response: ApiChannelAttachmentList) => {
|
1074
|
+
var result: ApiChannelAttachmentList = {
|
1075
|
+
attachments: [],
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
if (response.attachments == null) {
|
1079
|
+
return Promise.resolve(result);
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
response.attachments!.forEach(at => {
|
1083
|
+
result.attachments!.push({
|
1084
|
+
filename: at.filename,
|
1085
|
+
filesize: at.filetype,
|
1086
|
+
filetype: at.filetype,
|
1087
|
+
id: at.id,
|
1088
|
+
uploader: at.uploader,
|
1089
|
+
url: at.uploader
|
1090
|
+
})
|
1091
|
+
});
|
1092
|
+
return Promise.resolve(result);
|
1093
|
+
});
|
1094
|
+
}
|
1095
|
+
|
1065
1096
|
/** List a channel's users. */
|
1066
1097
|
async listClanUsers(session: Session, clanId: string): Promise<ApiClanUserList> {
|
1067
1098
|
if (this.autoRefreshSession && session.refresh_token &&
|
package/dist/api.gen.d.ts
CHANGED
@@ -99,6 +99,19 @@ export interface ApiCategoryDesc {
|
|
99
99
|
export interface ApiCategoryDescList {
|
100
100
|
categorydesc?: Array<ApiCategoryDesc>;
|
101
101
|
}
|
102
|
+
/** */
|
103
|
+
export interface ApiChannelAttachment {
|
104
|
+
filename?: string;
|
105
|
+
filesize?: string;
|
106
|
+
filetype?: string;
|
107
|
+
id?: string;
|
108
|
+
uploader?: string;
|
109
|
+
url?: string;
|
110
|
+
}
|
111
|
+
/** */
|
112
|
+
export interface ApiChannelAttachmentList {
|
113
|
+
attachments?: Array<ApiChannelAttachment>;
|
114
|
+
}
|
102
115
|
/** A list of channel description, usually a result of a list operation. */
|
103
116
|
export interface ApiChannelDescList {
|
104
117
|
cacheable_cursor?: string;
|
@@ -386,7 +399,7 @@ export interface ApiRole {
|
|
386
399
|
slug?: string;
|
387
400
|
title?: string;
|
388
401
|
role_channel_active?: string;
|
389
|
-
|
402
|
+
channel_ids?: Array<string>;
|
390
403
|
}
|
391
404
|
/** A list of role description, usually a result of a list operation. */
|
392
405
|
export interface ApiRoleList {
|
@@ -619,22 +632,24 @@ export declare class MezonApi {
|
|
619
632
|
listCategoryDescs(bearerToken: string, clanId: string, creatorId?: string, categoryName?: string, categoryId?: string, options?: any): Promise<ApiCategoryDescList>;
|
620
633
|
/** List a channel's message history. */
|
621
634
|
listChannelMessages(bearerToken: string, channelId: string, messageId?: string, direction?: number, limit?: number, options?: any): Promise<ApiChannelMessageList>;
|
622
|
-
/** List user channels */
|
623
|
-
listChannelDescs(bearerToken: string, limit?: number, state?: number, cursor?: string, clanId?: string, channelType?: number, options?: any): Promise<ApiChannelDescList>;
|
624
|
-
/** Create a new channel with the current user as the owner. */
|
625
|
-
createChannelDesc(bearerToken: string, body: ApiCreateChannelDescRequest, options?: any): Promise<ApiChannelDescription>;
|
626
|
-
/** Delete a channel by ID. */
|
627
|
-
deleteChannelDesc(bearerToken: string, channelId: string, options?: any): Promise<any>;
|
628
|
-
/** Update fields in a given channel. */
|
629
|
-
updateChannelDesc(bearerToken: string, channelId: string, body: {}, options?: any): Promise<any>;
|
630
635
|
/** Add users to a channel. */
|
631
636
|
addChannelUsers(bearerToken: string, channelId: string, userIds?: Array<string>, options?: any): Promise<any>;
|
637
|
+
/** List all attachment that are part of a channel. */
|
638
|
+
listChannelAttachment(bearerToken: string, channelId: string, clanId?: string, fileType?: string, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiChannelAttachmentList>;
|
632
639
|
/** Leave a channel the user is a member of. */
|
633
640
|
leaveChannel(bearerToken: string, channelId: string, options?: any): Promise<any>;
|
634
641
|
/** Kick a set of users from a channel. */
|
635
642
|
removeChannelUsers(bearerToken: string, channelId: string, userIds?: Array<string>, options?: any): Promise<any>;
|
636
643
|
/** List all users that are part of a channel. */
|
637
644
|
listChannelUsers(bearerToken: string, clanId: string, channelId: string, channelType?: number, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiChannelUserList>;
|
645
|
+
/** List user channels */
|
646
|
+
listChannelDescs(bearerToken: string, limit?: number, state?: number, cursor?: string, clanId?: string, channelType?: number, options?: any): Promise<ApiChannelDescList>;
|
647
|
+
/** Create a new channel with the current user as the owner. */
|
648
|
+
createChannelDesc(bearerToken: string, body: ApiCreateChannelDescRequest, options?: any): Promise<ApiChannelDescription>;
|
649
|
+
/** Delete a channel by ID. */
|
650
|
+
deleteChannelDesc(bearerToken: string, channelId: string, options?: any): Promise<any>;
|
651
|
+
/** Update fields in a given channel. */
|
652
|
+
updateChannelDesc(bearerToken: string, channelId: string, body: {}, options?: any): Promise<any>;
|
638
653
|
/** List all users that are part of a channel. */
|
639
654
|
listChannelVoiceUsers(bearerToken: string, clanId?: string, channelId?: string, channelType?: number, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiVoiceChannelUserList>;
|
640
655
|
/** List clans */
|
@@ -726,7 +741,7 @@ export declare class MezonApi {
|
|
726
741
|
/** */
|
727
742
|
updateUserProfileByClan(bearerToken: string, clanId: string, body: {}, options?: any): Promise<any>;
|
728
743
|
/** Create a new group with the current user as the owner. */
|
729
|
-
uploadAttachmentFile(bearerToken: string, body: ApiUploadAttachmentRequest, options?: any): Promise<
|
744
|
+
uploadAttachmentFile(bearerToken: string, body: ApiUploadAttachmentRequest, options?: any): Promise<ApiUploadAttachment>;
|
730
745
|
/** Fetch zero or more users by ID and/or username. */
|
731
746
|
getUsers(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, facebookIds?: Array<string>, options?: any): Promise<ApiUsers>;
|
732
747
|
/** */
|
package/dist/client.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList } from "./api.gen";
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -427,6 +427,8 @@ export declare class Client {
|
|
427
427
|
listChannelVoiceUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiVoiceChannelUserList>;
|
428
428
|
/** List a channel's users. */
|
429
429
|
listChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiChannelUserList>;
|
430
|
+
/** List a channel's attachment. */
|
431
|
+
listChannelAttachments(session: Session, clanId: string, channelId: string, fileType: string, state?: number, limit?: number, cursor?: string): Promise<ApiChannelAttachmentList>;
|
430
432
|
/** List a channel's users. */
|
431
433
|
listClanUsers(session: Session, clanId: string): Promise<ApiClanUserList>;
|
432
434
|
/** List channels. */
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -1669,15 +1669,47 @@ var MezonApi = class {
|
|
1669
1669
|
)
|
1670
1670
|
]);
|
1671
1671
|
}
|
1672
|
-
/**
|
1673
|
-
|
1674
|
-
|
1672
|
+
/** Add users to a channel. */
|
1673
|
+
addChannelUsers(bearerToken, channelId, userIds, options = {}) {
|
1674
|
+
if (channelId === null || channelId === void 0) {
|
1675
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1676
|
+
}
|
1677
|
+
const urlPath = "/v2/channel/{channelId}/add".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1678
|
+
const queryParams = /* @__PURE__ */ new Map();
|
1679
|
+
queryParams.set("user_ids", userIds);
|
1680
|
+
let bodyJson = "";
|
1681
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1682
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1683
|
+
if (bearerToken) {
|
1684
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1685
|
+
}
|
1686
|
+
return Promise.race([
|
1687
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
1688
|
+
if (response.status == 204) {
|
1689
|
+
return response;
|
1690
|
+
} else if (response.status >= 200 && response.status < 300) {
|
1691
|
+
return response.json();
|
1692
|
+
} else {
|
1693
|
+
throw response;
|
1694
|
+
}
|
1695
|
+
}),
|
1696
|
+
new Promise(
|
1697
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
1698
|
+
)
|
1699
|
+
]);
|
1700
|
+
}
|
1701
|
+
/** List all attachment that are part of a channel. */
|
1702
|
+
listChannelAttachment(bearerToken, channelId, clanId, fileType, limit, state, cursor, options = {}) {
|
1703
|
+
if (channelId === null || channelId === void 0) {
|
1704
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1705
|
+
}
|
1706
|
+
const urlPath = "/v2/channel/{channelId}/attachment".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1675
1707
|
const queryParams = /* @__PURE__ */ new Map();
|
1708
|
+
queryParams.set("clan_id", clanId);
|
1709
|
+
queryParams.set("file_type", fileType);
|
1676
1710
|
queryParams.set("limit", limit);
|
1677
1711
|
queryParams.set("state", state);
|
1678
1712
|
queryParams.set("cursor", cursor);
|
1679
|
-
queryParams.set("clan_id", clanId);
|
1680
|
-
queryParams.set("channel_type", channelType);
|
1681
1713
|
let bodyJson = "";
|
1682
1714
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1683
1715
|
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
@@ -1699,15 +1731,14 @@ var MezonApi = class {
|
|
1699
1731
|
)
|
1700
1732
|
]);
|
1701
1733
|
}
|
1702
|
-
/**
|
1703
|
-
|
1704
|
-
if (
|
1705
|
-
throw new Error("'
|
1734
|
+
/** Leave a channel the user is a member of. */
|
1735
|
+
leaveChannel(bearerToken, channelId, options = {}) {
|
1736
|
+
if (channelId === null || channelId === void 0) {
|
1737
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1706
1738
|
}
|
1707
|
-
const urlPath = "/v2/
|
1739
|
+
const urlPath = "/v2/channel/{channelId}/leave".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1708
1740
|
const queryParams = /* @__PURE__ */ new Map();
|
1709
1741
|
let bodyJson = "";
|
1710
|
-
bodyJson = JSON.stringify(body || {});
|
1711
1742
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1712
1743
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1713
1744
|
if (bearerToken) {
|
@@ -1728,16 +1759,17 @@ var MezonApi = class {
|
|
1728
1759
|
)
|
1729
1760
|
]);
|
1730
1761
|
}
|
1731
|
-
/**
|
1732
|
-
|
1762
|
+
/** Kick a set of users from a channel. */
|
1763
|
+
removeChannelUsers(bearerToken, channelId, userIds, options = {}) {
|
1733
1764
|
if (channelId === null || channelId === void 0) {
|
1734
1765
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1735
1766
|
}
|
1736
|
-
const urlPath = "/v2/
|
1767
|
+
const urlPath = "/v2/channel/{channelId}/remove".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1737
1768
|
const queryParams = /* @__PURE__ */ new Map();
|
1769
|
+
queryParams.set("user_ids", userIds);
|
1738
1770
|
let bodyJson = "";
|
1739
1771
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1740
|
-
const fetchOptions = buildFetchOptions("
|
1772
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1741
1773
|
if (bearerToken) {
|
1742
1774
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1743
1775
|
}
|
@@ -1756,20 +1788,21 @@ var MezonApi = class {
|
|
1756
1788
|
)
|
1757
1789
|
]);
|
1758
1790
|
}
|
1759
|
-
/**
|
1760
|
-
|
1791
|
+
/** List all users that are part of a channel. */
|
1792
|
+
listChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
|
1761
1793
|
if (channelId === null || channelId === void 0) {
|
1762
1794
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1763
1795
|
}
|
1764
|
-
|
1765
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
1766
|
-
}
|
1767
|
-
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1796
|
+
const urlPath = "/v2/channel/{channelId}/user".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1768
1797
|
const queryParams = /* @__PURE__ */ new Map();
|
1798
|
+
queryParams.set("clan_id", clanId);
|
1799
|
+
queryParams.set("channel_type", channelType);
|
1800
|
+
queryParams.set("limit", limit);
|
1801
|
+
queryParams.set("state", state);
|
1802
|
+
queryParams.set("cursor", cursor);
|
1769
1803
|
let bodyJson = "";
|
1770
|
-
bodyJson = JSON.stringify(body || {});
|
1771
1804
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1772
|
-
const fetchOptions = buildFetchOptions("
|
1805
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
1773
1806
|
if (bearerToken) {
|
1774
1807
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1775
1808
|
}
|
@@ -1788,17 +1821,18 @@ var MezonApi = class {
|
|
1788
1821
|
)
|
1789
1822
|
]);
|
1790
1823
|
}
|
1791
|
-
/**
|
1792
|
-
|
1793
|
-
|
1794
|
-
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1795
|
-
}
|
1796
|
-
const urlPath = "/v2/channeldesc/{channelId}/add".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1824
|
+
/** List user channels */
|
1825
|
+
listChannelDescs(bearerToken, limit, state, cursor, clanId, channelType, options = {}) {
|
1826
|
+
const urlPath = "/v2/channeldesc";
|
1797
1827
|
const queryParams = /* @__PURE__ */ new Map();
|
1798
|
-
queryParams.set("
|
1828
|
+
queryParams.set("limit", limit);
|
1829
|
+
queryParams.set("state", state);
|
1830
|
+
queryParams.set("cursor", cursor);
|
1831
|
+
queryParams.set("clan_id", clanId);
|
1832
|
+
queryParams.set("channel_type", channelType);
|
1799
1833
|
let bodyJson = "";
|
1800
1834
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1801
|
-
const fetchOptions = buildFetchOptions("
|
1835
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
1802
1836
|
if (bearerToken) {
|
1803
1837
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1804
1838
|
}
|
@@ -1817,14 +1851,15 @@ var MezonApi = class {
|
|
1817
1851
|
)
|
1818
1852
|
]);
|
1819
1853
|
}
|
1820
|
-
/**
|
1821
|
-
|
1822
|
-
if (
|
1823
|
-
throw new Error("'
|
1854
|
+
/** Create a new channel with the current user as the owner. */
|
1855
|
+
createChannelDesc(bearerToken, body, options = {}) {
|
1856
|
+
if (body === null || body === void 0) {
|
1857
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
1824
1858
|
}
|
1825
|
-
const urlPath = "/v2/channeldesc
|
1859
|
+
const urlPath = "/v2/channeldesc";
|
1826
1860
|
const queryParams = /* @__PURE__ */ new Map();
|
1827
1861
|
let bodyJson = "";
|
1862
|
+
bodyJson = JSON.stringify(body || {});
|
1828
1863
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1829
1864
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1830
1865
|
if (bearerToken) {
|
@@ -1845,17 +1880,16 @@ var MezonApi = class {
|
|
1845
1880
|
)
|
1846
1881
|
]);
|
1847
1882
|
}
|
1848
|
-
/**
|
1849
|
-
|
1883
|
+
/** Delete a channel by ID. */
|
1884
|
+
deleteChannelDesc(bearerToken, channelId, options = {}) {
|
1850
1885
|
if (channelId === null || channelId === void 0) {
|
1851
1886
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1852
1887
|
}
|
1853
|
-
const urlPath = "/v2/channeldesc/{channelId}
|
1888
|
+
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1854
1889
|
const queryParams = /* @__PURE__ */ new Map();
|
1855
|
-
queryParams.set("user_ids", userIds);
|
1856
1890
|
let bodyJson = "";
|
1857
1891
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1858
|
-
const fetchOptions = buildFetchOptions("
|
1892
|
+
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
1859
1893
|
if (bearerToken) {
|
1860
1894
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1861
1895
|
}
|
@@ -1874,21 +1908,20 @@ var MezonApi = class {
|
|
1874
1908
|
)
|
1875
1909
|
]);
|
1876
1910
|
}
|
1877
|
-
/**
|
1878
|
-
|
1911
|
+
/** Update fields in a given channel. */
|
1912
|
+
updateChannelDesc(bearerToken, channelId, body, options = {}) {
|
1879
1913
|
if (channelId === null || channelId === void 0) {
|
1880
1914
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1881
1915
|
}
|
1882
|
-
|
1916
|
+
if (body === null || body === void 0) {
|
1917
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
1918
|
+
}
|
1919
|
+
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1883
1920
|
const queryParams = /* @__PURE__ */ new Map();
|
1884
|
-
queryParams.set("clan_id", clanId);
|
1885
|
-
queryParams.set("channel_type", channelType);
|
1886
|
-
queryParams.set("limit", limit);
|
1887
|
-
queryParams.set("state", state);
|
1888
|
-
queryParams.set("cursor", cursor);
|
1889
1921
|
let bodyJson = "";
|
1922
|
+
bodyJson = JSON.stringify(body || {});
|
1890
1923
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1891
|
-
const fetchOptions = buildFetchOptions("
|
1924
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
1892
1925
|
if (bearerToken) {
|
1893
1926
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1894
1927
|
}
|
@@ -4507,6 +4540,33 @@ var Client = class {
|
|
4507
4540
|
});
|
4508
4541
|
});
|
4509
4542
|
}
|
4543
|
+
/** List a channel's attachment. */
|
4544
|
+
listChannelAttachments(session, clanId, channelId, fileType, state, limit, cursor) {
|
4545
|
+
return __async(this, null, function* () {
|
4546
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4547
|
+
yield this.sessionRefresh(session);
|
4548
|
+
}
|
4549
|
+
return this.apiClient.listChannelAttachment(session.token, clanId, channelId, fileType, limit, state, cursor).then((response) => {
|
4550
|
+
var result = {
|
4551
|
+
attachments: []
|
4552
|
+
};
|
4553
|
+
if (response.attachments == null) {
|
4554
|
+
return Promise.resolve(result);
|
4555
|
+
}
|
4556
|
+
response.attachments.forEach((at) => {
|
4557
|
+
result.attachments.push({
|
4558
|
+
filename: at.filename,
|
4559
|
+
filesize: at.filetype,
|
4560
|
+
filetype: at.filetype,
|
4561
|
+
id: at.id,
|
4562
|
+
uploader: at.uploader,
|
4563
|
+
url: at.uploader
|
4564
|
+
});
|
4565
|
+
});
|
4566
|
+
return Promise.resolve(result);
|
4567
|
+
});
|
4568
|
+
});
|
4569
|
+
}
|
4510
4570
|
/** List a channel's users. */
|
4511
4571
|
listClanUsers(session, clanId) {
|
4512
4572
|
return __async(this, null, function* () {
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -1641,15 +1641,47 @@ var MezonApi = class {
|
|
1641
1641
|
)
|
1642
1642
|
]);
|
1643
1643
|
}
|
1644
|
-
/**
|
1645
|
-
|
1646
|
-
|
1644
|
+
/** Add users to a channel. */
|
1645
|
+
addChannelUsers(bearerToken, channelId, userIds, options = {}) {
|
1646
|
+
if (channelId === null || channelId === void 0) {
|
1647
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1648
|
+
}
|
1649
|
+
const urlPath = "/v2/channel/{channelId}/add".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1650
|
+
const queryParams = /* @__PURE__ */ new Map();
|
1651
|
+
queryParams.set("user_ids", userIds);
|
1652
|
+
let bodyJson = "";
|
1653
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1654
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1655
|
+
if (bearerToken) {
|
1656
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1657
|
+
}
|
1658
|
+
return Promise.race([
|
1659
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
1660
|
+
if (response.status == 204) {
|
1661
|
+
return response;
|
1662
|
+
} else if (response.status >= 200 && response.status < 300) {
|
1663
|
+
return response.json();
|
1664
|
+
} else {
|
1665
|
+
throw response;
|
1666
|
+
}
|
1667
|
+
}),
|
1668
|
+
new Promise(
|
1669
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
1670
|
+
)
|
1671
|
+
]);
|
1672
|
+
}
|
1673
|
+
/** List all attachment that are part of a channel. */
|
1674
|
+
listChannelAttachment(bearerToken, channelId, clanId, fileType, limit, state, cursor, options = {}) {
|
1675
|
+
if (channelId === null || channelId === void 0) {
|
1676
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1677
|
+
}
|
1678
|
+
const urlPath = "/v2/channel/{channelId}/attachment".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1647
1679
|
const queryParams = /* @__PURE__ */ new Map();
|
1680
|
+
queryParams.set("clan_id", clanId);
|
1681
|
+
queryParams.set("file_type", fileType);
|
1648
1682
|
queryParams.set("limit", limit);
|
1649
1683
|
queryParams.set("state", state);
|
1650
1684
|
queryParams.set("cursor", cursor);
|
1651
|
-
queryParams.set("clan_id", clanId);
|
1652
|
-
queryParams.set("channel_type", channelType);
|
1653
1685
|
let bodyJson = "";
|
1654
1686
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1655
1687
|
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
@@ -1671,15 +1703,14 @@ var MezonApi = class {
|
|
1671
1703
|
)
|
1672
1704
|
]);
|
1673
1705
|
}
|
1674
|
-
/**
|
1675
|
-
|
1676
|
-
if (
|
1677
|
-
throw new Error("'
|
1706
|
+
/** Leave a channel the user is a member of. */
|
1707
|
+
leaveChannel(bearerToken, channelId, options = {}) {
|
1708
|
+
if (channelId === null || channelId === void 0) {
|
1709
|
+
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1678
1710
|
}
|
1679
|
-
const urlPath = "/v2/
|
1711
|
+
const urlPath = "/v2/channel/{channelId}/leave".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1680
1712
|
const queryParams = /* @__PURE__ */ new Map();
|
1681
1713
|
let bodyJson = "";
|
1682
|
-
bodyJson = JSON.stringify(body || {});
|
1683
1714
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1684
1715
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1685
1716
|
if (bearerToken) {
|
@@ -1700,16 +1731,17 @@ var MezonApi = class {
|
|
1700
1731
|
)
|
1701
1732
|
]);
|
1702
1733
|
}
|
1703
|
-
/**
|
1704
|
-
|
1734
|
+
/** Kick a set of users from a channel. */
|
1735
|
+
removeChannelUsers(bearerToken, channelId, userIds, options = {}) {
|
1705
1736
|
if (channelId === null || channelId === void 0) {
|
1706
1737
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1707
1738
|
}
|
1708
|
-
const urlPath = "/v2/
|
1739
|
+
const urlPath = "/v2/channel/{channelId}/remove".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1709
1740
|
const queryParams = /* @__PURE__ */ new Map();
|
1741
|
+
queryParams.set("user_ids", userIds);
|
1710
1742
|
let bodyJson = "";
|
1711
1743
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1712
|
-
const fetchOptions = buildFetchOptions("
|
1744
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1713
1745
|
if (bearerToken) {
|
1714
1746
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1715
1747
|
}
|
@@ -1728,20 +1760,21 @@ var MezonApi = class {
|
|
1728
1760
|
)
|
1729
1761
|
]);
|
1730
1762
|
}
|
1731
|
-
/**
|
1732
|
-
|
1763
|
+
/** List all users that are part of a channel. */
|
1764
|
+
listChannelUsers(bearerToken, clanId, channelId, channelType, limit, state, cursor, options = {}) {
|
1733
1765
|
if (channelId === null || channelId === void 0) {
|
1734
1766
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1735
1767
|
}
|
1736
|
-
|
1737
|
-
throw new Error("'body' is a required parameter but is null or undefined.");
|
1738
|
-
}
|
1739
|
-
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1768
|
+
const urlPath = "/v2/channel/{channelId}/user".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1740
1769
|
const queryParams = /* @__PURE__ */ new Map();
|
1770
|
+
queryParams.set("clan_id", clanId);
|
1771
|
+
queryParams.set("channel_type", channelType);
|
1772
|
+
queryParams.set("limit", limit);
|
1773
|
+
queryParams.set("state", state);
|
1774
|
+
queryParams.set("cursor", cursor);
|
1741
1775
|
let bodyJson = "";
|
1742
|
-
bodyJson = JSON.stringify(body || {});
|
1743
1776
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1744
|
-
const fetchOptions = buildFetchOptions("
|
1777
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
1745
1778
|
if (bearerToken) {
|
1746
1779
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1747
1780
|
}
|
@@ -1760,17 +1793,18 @@ var MezonApi = class {
|
|
1760
1793
|
)
|
1761
1794
|
]);
|
1762
1795
|
}
|
1763
|
-
/**
|
1764
|
-
|
1765
|
-
|
1766
|
-
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1767
|
-
}
|
1768
|
-
const urlPath = "/v2/channeldesc/{channelId}/add".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1796
|
+
/** List user channels */
|
1797
|
+
listChannelDescs(bearerToken, limit, state, cursor, clanId, channelType, options = {}) {
|
1798
|
+
const urlPath = "/v2/channeldesc";
|
1769
1799
|
const queryParams = /* @__PURE__ */ new Map();
|
1770
|
-
queryParams.set("
|
1800
|
+
queryParams.set("limit", limit);
|
1801
|
+
queryParams.set("state", state);
|
1802
|
+
queryParams.set("cursor", cursor);
|
1803
|
+
queryParams.set("clan_id", clanId);
|
1804
|
+
queryParams.set("channel_type", channelType);
|
1771
1805
|
let bodyJson = "";
|
1772
1806
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1773
|
-
const fetchOptions = buildFetchOptions("
|
1807
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
1774
1808
|
if (bearerToken) {
|
1775
1809
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1776
1810
|
}
|
@@ -1789,14 +1823,15 @@ var MezonApi = class {
|
|
1789
1823
|
)
|
1790
1824
|
]);
|
1791
1825
|
}
|
1792
|
-
/**
|
1793
|
-
|
1794
|
-
if (
|
1795
|
-
throw new Error("'
|
1826
|
+
/** Create a new channel with the current user as the owner. */
|
1827
|
+
createChannelDesc(bearerToken, body, options = {}) {
|
1828
|
+
if (body === null || body === void 0) {
|
1829
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
1796
1830
|
}
|
1797
|
-
const urlPath = "/v2/channeldesc
|
1831
|
+
const urlPath = "/v2/channeldesc";
|
1798
1832
|
const queryParams = /* @__PURE__ */ new Map();
|
1799
1833
|
let bodyJson = "";
|
1834
|
+
bodyJson = JSON.stringify(body || {});
|
1800
1835
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1801
1836
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
1802
1837
|
if (bearerToken) {
|
@@ -1817,17 +1852,16 @@ var MezonApi = class {
|
|
1817
1852
|
)
|
1818
1853
|
]);
|
1819
1854
|
}
|
1820
|
-
/**
|
1821
|
-
|
1855
|
+
/** Delete a channel by ID. */
|
1856
|
+
deleteChannelDesc(bearerToken, channelId, options = {}) {
|
1822
1857
|
if (channelId === null || channelId === void 0) {
|
1823
1858
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1824
1859
|
}
|
1825
|
-
const urlPath = "/v2/channeldesc/{channelId}
|
1860
|
+
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1826
1861
|
const queryParams = /* @__PURE__ */ new Map();
|
1827
|
-
queryParams.set("user_ids", userIds);
|
1828
1862
|
let bodyJson = "";
|
1829
1863
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1830
|
-
const fetchOptions = buildFetchOptions("
|
1864
|
+
const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
|
1831
1865
|
if (bearerToken) {
|
1832
1866
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1833
1867
|
}
|
@@ -1846,21 +1880,20 @@ var MezonApi = class {
|
|
1846
1880
|
)
|
1847
1881
|
]);
|
1848
1882
|
}
|
1849
|
-
/**
|
1850
|
-
|
1883
|
+
/** Update fields in a given channel. */
|
1884
|
+
updateChannelDesc(bearerToken, channelId, body, options = {}) {
|
1851
1885
|
if (channelId === null || channelId === void 0) {
|
1852
1886
|
throw new Error("'channelId' is a required parameter but is null or undefined.");
|
1853
1887
|
}
|
1854
|
-
|
1888
|
+
if (body === null || body === void 0) {
|
1889
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
1890
|
+
}
|
1891
|
+
const urlPath = "/v2/channeldesc/{channelId}".replace("{channelId}", encodeURIComponent(String(channelId)));
|
1855
1892
|
const queryParams = /* @__PURE__ */ new Map();
|
1856
|
-
queryParams.set("clan_id", clanId);
|
1857
|
-
queryParams.set("channel_type", channelType);
|
1858
|
-
queryParams.set("limit", limit);
|
1859
|
-
queryParams.set("state", state);
|
1860
|
-
queryParams.set("cursor", cursor);
|
1861
1893
|
let bodyJson = "";
|
1894
|
+
bodyJson = JSON.stringify(body || {});
|
1862
1895
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
1863
|
-
const fetchOptions = buildFetchOptions("
|
1896
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
1864
1897
|
if (bearerToken) {
|
1865
1898
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
1866
1899
|
}
|
@@ -4479,6 +4512,33 @@ var Client = class {
|
|
4479
4512
|
});
|
4480
4513
|
});
|
4481
4514
|
}
|
4515
|
+
/** List a channel's attachment. */
|
4516
|
+
listChannelAttachments(session, clanId, channelId, fileType, state, limit, cursor) {
|
4517
|
+
return __async(this, null, function* () {
|
4518
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
4519
|
+
yield this.sessionRefresh(session);
|
4520
|
+
}
|
4521
|
+
return this.apiClient.listChannelAttachment(session.token, clanId, channelId, fileType, limit, state, cursor).then((response) => {
|
4522
|
+
var result = {
|
4523
|
+
attachments: []
|
4524
|
+
};
|
4525
|
+
if (response.attachments == null) {
|
4526
|
+
return Promise.resolve(result);
|
4527
|
+
}
|
4528
|
+
response.attachments.forEach((at) => {
|
4529
|
+
result.attachments.push({
|
4530
|
+
filename: at.filename,
|
4531
|
+
filesize: at.filetype,
|
4532
|
+
filetype: at.filetype,
|
4533
|
+
id: at.id,
|
4534
|
+
uploader: at.uploader,
|
4535
|
+
url: at.uploader
|
4536
|
+
});
|
4537
|
+
});
|
4538
|
+
return Promise.resolve(result);
|
4539
|
+
});
|
4540
|
+
});
|
4541
|
+
}
|
4482
4542
|
/** List a channel's users. */
|
4483
4543
|
listClanUsers(session, clanId) {
|
4484
4544
|
return __async(this, null, function* () {
|