mezon-js 2.12.60 → 2.12.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.gen.ts CHANGED
@@ -6531,6 +6531,41 @@ export class MezonApi {
6531
6531
  ]);
6532
6532
  }
6533
6533
 
6534
+ /** Block one or more users by ID or username. */
6535
+ unblockFriends(bearerToken: string,
6536
+ ids?:Array<string>,
6537
+ usernames?:Array<string>,
6538
+ options: any = {}): Promise<any> {
6539
+
6540
+ const urlPath = "/v2/friend/unblock";
6541
+ const queryParams = new Map<string, any>();
6542
+ queryParams.set("ids", ids);
6543
+ queryParams.set("usernames", usernames);
6544
+
6545
+ let bodyJson : string = "";
6546
+
6547
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6548
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
6549
+ if (bearerToken) {
6550
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6551
+ }
6552
+
6553
+ return Promise.race([
6554
+ fetch(fullUrl, fetchOptions).then((response) => {
6555
+ if (response.status == 204) {
6556
+ return response;
6557
+ } else if (response.status >= 200 && response.status < 300) {
6558
+ return response.json();
6559
+ } else {
6560
+ throw response;
6561
+ }
6562
+ }),
6563
+ new Promise((_, reject) =>
6564
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6565
+ ),
6566
+ ]);
6567
+ }
6568
+
6534
6569
  /** List GetChannelCategoryNotiSettingsList */
6535
6570
  getChannelCategoryNotiSettingsList(
6536
6571
  bearerToken: string,
@@ -6890,7 +6925,8 @@ export class MezonApi {
6890
6925
 
6891
6926
  /** Add users to a channel. */
6892
6927
  getLinkInvite(
6893
- bearerToken: string,
6928
+ basicAuthUsername: string,
6929
+ basicAuthPassword: string,
6894
6930
  inviteId: string,
6895
6931
  options: any = {}
6896
6932
  ): Promise<ApiInviteUserRes> {
@@ -6909,8 +6945,9 @@ export class MezonApi {
6909
6945
 
6910
6946
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6911
6947
  const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6912
- if (bearerToken) {
6913
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6948
+ if (basicAuthUsername) {
6949
+ fetchOptions.headers["Authorization"] =
6950
+ "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
6914
6951
  }
6915
6952
 
6916
6953
  return Promise.race([
package/client.ts CHANGED
@@ -722,6 +722,27 @@ export class Client {
722
722
  });
723
723
  }
724
724
 
725
+ /** Block one or more users by ID or username. */
726
+ async unblockFriends(
727
+ session: Session,
728
+ ids?: Array<string>,
729
+ usernames?: Array<string>
730
+ ): Promise<boolean> {
731
+ if (
732
+ this.autoRefreshSession &&
733
+ session.refresh_token &&
734
+ session.isexpired(Date.now() / 1000)
735
+ ) {
736
+ await this.sessionRefresh(session);
737
+ }
738
+
739
+ return this.apiClient
740
+ .unblockFriends(session.token, ids, usernames)
741
+ .then((response: any) => {
742
+ return Promise.resolve(response != undefined);
743
+ });
744
+ }
745
+
725
746
  /** Create a new group with the current user as the creator and superadmin. */
726
747
  async uploadAttachmentFile(
727
748
  session: Session,
@@ -2335,19 +2356,10 @@ export class Client {
2335
2356
 
2336
2357
  /** Get link invite user */
2337
2358
  async getLinkInvite(
2338
- session: Session,
2339
2359
  inviteId: string
2340
2360
  ): Promise<ApiInviteUserRes> {
2341
- if (
2342
- this.autoRefreshSession &&
2343
- session.refresh_token &&
2344
- session.isexpired(Date.now() / 1000)
2345
- ) {
2346
- await this.sessionRefresh(session);
2347
- }
2348
-
2349
2361
  return this.apiClient
2350
- .getLinkInvite(session.token, inviteId)
2362
+ .getLinkInvite( this.serverkey, "", inviteId)
2351
2363
  .then((response: ApiInviteUserRes) => {
2352
2364
  return Promise.resolve(response);
2353
2365
  });
package/dist/api.gen.d.ts CHANGED
@@ -2064,6 +2064,8 @@ export declare class MezonApi {
2064
2064
  addFriends(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
2065
2065
  /** Block one or more users by ID or username. */
2066
2066
  blockFriends(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
2067
+ /** Block one or more users by ID or username. */
2068
+ unblockFriends(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
2067
2069
  /** List GetChannelCategoryNotiSettingsList */
2068
2070
  getChannelCategoryNotiSettingsList(bearerToken: string, clanId?: string, options?: any): Promise<ApiNotificationChannelCategorySettingList>;
2069
2071
  /** */
@@ -2085,7 +2087,7 @@ export declare class MezonApi {
2085
2087
  /** Add users to a channel. */
2086
2088
  createLinkInviteUser(bearerToken: string, body: ApiLinkInviteUserRequest, options?: any): Promise<ApiLinkInviteUser>;
2087
2089
  /** Add users to a channel. */
2088
- getLinkInvite(bearerToken: string, inviteId: string, options?: any): Promise<ApiInviteUserRes>;
2090
+ getLinkInvite(basicAuthUsername: string, basicAuthPassword: string, inviteId: string, options?: any): Promise<ApiInviteUserRes>;
2089
2091
  /** Add users to a channel. */
2090
2092
  inviteUser(bearerToken: string, inviteId: string, options?: any): Promise<ApiInviteUserRes>;
2091
2093
  /** List HashtagDMList */
package/dist/client.d.ts CHANGED
@@ -355,6 +355,8 @@ export declare class Client {
355
355
  addFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;
356
356
  /** Block one or more users by ID or username. */
357
357
  blockFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;
358
+ /** Block one or more users by ID or username. */
359
+ unblockFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;
358
360
  /** Create a new group with the current user as the creator and superadmin. */
359
361
  uploadAttachmentFile(session: Session, request: ApiUploadAttachmentRequest): Promise<ApiUploadAttachment>;
360
362
  /** Create a channel within clan */
@@ -470,7 +472,7 @@ export declare class Client {
470
472
  /** Update fields in a given clan profile. */
471
473
  createLinkInviteUser(session: Session, request: ApiLinkInviteUserRequest): Promise<ApiLinkInviteUser>;
472
474
  /** Get link invite user */
473
- getLinkInvite(session: Session, inviteId: string): Promise<ApiInviteUserRes>;
475
+ getLinkInvite(inviteId: string): Promise<ApiInviteUserRes>;
474
476
  /** Get permission of user in the clan */
475
477
  GetRoleOfUserInTheClan(session: Session, clanId: string): Promise<ApiRoleList>;
476
478
  /** invite user */
@@ -3242,6 +3242,33 @@ var MezonApi = class {
3242
3242
  )
3243
3243
  ]);
3244
3244
  }
3245
+ /** Block one or more users by ID or username. */
3246
+ unblockFriends(bearerToken, ids, usernames, options = {}) {
3247
+ const urlPath = "/v2/friend/unblock";
3248
+ const queryParams = /* @__PURE__ */ new Map();
3249
+ queryParams.set("ids", ids);
3250
+ queryParams.set("usernames", usernames);
3251
+ let bodyJson = "";
3252
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3253
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3254
+ if (bearerToken) {
3255
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3256
+ }
3257
+ return Promise.race([
3258
+ fetch(fullUrl, fetchOptions).then((response) => {
3259
+ if (response.status == 204) {
3260
+ return response;
3261
+ } else if (response.status >= 200 && response.status < 300) {
3262
+ return response.json();
3263
+ } else {
3264
+ throw response;
3265
+ }
3266
+ }),
3267
+ new Promise(
3268
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3269
+ )
3270
+ ]);
3271
+ }
3245
3272
  /** List GetChannelCategoryNotiSettingsList */
3246
3273
  getChannelCategoryNotiSettingsList(bearerToken, clanId, options = {}) {
3247
3274
  const urlPath = "/v2/getchannelcategorynotisettingslist";
@@ -3520,7 +3547,7 @@ var MezonApi = class {
3520
3547
  ]);
3521
3548
  }
3522
3549
  /** Add users to a channel. */
3523
- getLinkInvite(bearerToken, inviteId, options = {}) {
3550
+ getLinkInvite(basicAuthUsername, basicAuthPassword, inviteId, options = {}) {
3524
3551
  if (inviteId === null || inviteId === void 0) {
3525
3552
  throw new Error(
3526
3553
  "'inviteId' is a required parameter but is null or undefined."
@@ -3534,8 +3561,8 @@ var MezonApi = class {
3534
3561
  let bodyJson = "";
3535
3562
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3536
3563
  const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3537
- if (bearerToken) {
3538
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3564
+ if (basicAuthUsername) {
3565
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
3539
3566
  }
3540
3567
  return Promise.race([
3541
3568
  fetch(fullUrl, fetchOptions).then((response) => {
@@ -8258,6 +8285,17 @@ var Client = class {
8258
8285
  });
8259
8286
  });
8260
8287
  }
8288
+ /** Block one or more users by ID or username. */
8289
+ unblockFriends(session, ids, usernames) {
8290
+ return __async(this, null, function* () {
8291
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
8292
+ yield this.sessionRefresh(session);
8293
+ }
8294
+ return this.apiClient.unblockFriends(session.token, ids, usernames).then((response) => {
8295
+ return Promise.resolve(response != void 0);
8296
+ });
8297
+ });
8298
+ }
8261
8299
  /** Create a new group with the current user as the creator and superadmin. */
8262
8300
  uploadAttachmentFile(session, request) {
8263
8301
  return __async(this, null, function* () {
@@ -9264,12 +9302,9 @@ var Client = class {
9264
9302
  });
9265
9303
  }
9266
9304
  /** Get link invite user */
9267
- getLinkInvite(session, inviteId) {
9305
+ getLinkInvite(inviteId) {
9268
9306
  return __async(this, null, function* () {
9269
- if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9270
- yield this.sessionRefresh(session);
9271
- }
9272
- return this.apiClient.getLinkInvite(session.token, inviteId).then((response) => {
9307
+ return this.apiClient.getLinkInvite(this.serverkey, "", inviteId).then((response) => {
9273
9308
  return Promise.resolve(response);
9274
9309
  });
9275
9310
  });
@@ -3208,6 +3208,33 @@ var MezonApi = class {
3208
3208
  )
3209
3209
  ]);
3210
3210
  }
3211
+ /** Block one or more users by ID or username. */
3212
+ unblockFriends(bearerToken, ids, usernames, options = {}) {
3213
+ const urlPath = "/v2/friend/unblock";
3214
+ const queryParams = /* @__PURE__ */ new Map();
3215
+ queryParams.set("ids", ids);
3216
+ queryParams.set("usernames", usernames);
3217
+ let bodyJson = "";
3218
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3219
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3220
+ if (bearerToken) {
3221
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3222
+ }
3223
+ return Promise.race([
3224
+ fetch(fullUrl, fetchOptions).then((response) => {
3225
+ if (response.status == 204) {
3226
+ return response;
3227
+ } else if (response.status >= 200 && response.status < 300) {
3228
+ return response.json();
3229
+ } else {
3230
+ throw response;
3231
+ }
3232
+ }),
3233
+ new Promise(
3234
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3235
+ )
3236
+ ]);
3237
+ }
3211
3238
  /** List GetChannelCategoryNotiSettingsList */
3212
3239
  getChannelCategoryNotiSettingsList(bearerToken, clanId, options = {}) {
3213
3240
  const urlPath = "/v2/getchannelcategorynotisettingslist";
@@ -3486,7 +3513,7 @@ var MezonApi = class {
3486
3513
  ]);
3487
3514
  }
3488
3515
  /** Add users to a channel. */
3489
- getLinkInvite(bearerToken, inviteId, options = {}) {
3516
+ getLinkInvite(basicAuthUsername, basicAuthPassword, inviteId, options = {}) {
3490
3517
  if (inviteId === null || inviteId === void 0) {
3491
3518
  throw new Error(
3492
3519
  "'inviteId' is a required parameter but is null or undefined."
@@ -3500,8 +3527,8 @@ var MezonApi = class {
3500
3527
  let bodyJson = "";
3501
3528
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3502
3529
  const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3503
- if (bearerToken) {
3504
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3530
+ if (basicAuthUsername) {
3531
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
3505
3532
  }
3506
3533
  return Promise.race([
3507
3534
  fetch(fullUrl, fetchOptions).then((response) => {
@@ -8224,6 +8251,17 @@ var Client = class {
8224
8251
  });
8225
8252
  });
8226
8253
  }
8254
+ /** Block one or more users by ID or username. */
8255
+ unblockFriends(session, ids, usernames) {
8256
+ return __async(this, null, function* () {
8257
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
8258
+ yield this.sessionRefresh(session);
8259
+ }
8260
+ return this.apiClient.unblockFriends(session.token, ids, usernames).then((response) => {
8261
+ return Promise.resolve(response != void 0);
8262
+ });
8263
+ });
8264
+ }
8227
8265
  /** Create a new group with the current user as the creator and superadmin. */
8228
8266
  uploadAttachmentFile(session, request) {
8229
8267
  return __async(this, null, function* () {
@@ -9230,12 +9268,9 @@ var Client = class {
9230
9268
  });
9231
9269
  }
9232
9270
  /** Get link invite user */
9233
- getLinkInvite(session, inviteId) {
9271
+ getLinkInvite(inviteId) {
9234
9272
  return __async(this, null, function* () {
9235
- if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9236
- yield this.sessionRefresh(session);
9237
- }
9238
- return this.apiClient.getLinkInvite(session.token, inviteId).then((response) => {
9273
+ return this.apiClient.getLinkInvite(this.serverkey, "", inviteId).then((response) => {
9239
9274
  return Promise.resolve(response);
9240
9275
  });
9241
9276
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.12.60",
3
+ "version": "2.12.62",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },