mezon-js 2.7.43 → 2.7.45

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
@@ -478,6 +478,16 @@ export interface ApiCreateRoleRequest {
478
478
  title?: string;
479
479
  }
480
480
 
481
+ /** */
482
+ export interface ApiCreateWebhookRequest {
483
+ //
484
+ channel_id?: string;
485
+ //
486
+ clan_id?: string;
487
+ //
488
+ hook_name?: string;
489
+ }
490
+
481
491
  /** */
482
492
  export interface ApiDeleteEventRequest {
483
493
  //The id of a event.
@@ -1217,6 +1227,16 @@ export interface ApiVoiceChannelUserList {
1217
1227
  voice_channel_users?: Array<ApiVoiceChannelUser>;
1218
1228
  }
1219
1229
 
1230
+ /** */
1231
+ export interface ApiWebhookResponse {
1232
+ //
1233
+ channel_id?: string;
1234
+ //
1235
+ hook_name?: string;
1236
+ //
1237
+ hook_url?: string;
1238
+ }
1239
+
1220
1240
  /** The object to store. */
1221
1241
  export interface ApiWriteStorageObject {
1222
1242
  //The collection to store the object.
@@ -5493,6 +5513,42 @@ export class MezonApi {
5493
5513
  ]);
5494
5514
  }
5495
5515
 
5516
+ /** Create webhook */
5517
+ createWebhookLink(bearerToken: string,
5518
+ body:ApiCreateWebhookRequest,
5519
+ options: any = {}): Promise<ApiWebhookResponse> {
5520
+
5521
+ if (body === null || body === undefined) {
5522
+ throw new Error("'body' is a required parameter but is null or undefined.");
5523
+ }
5524
+ const urlPath = "/v2/webhook/create";
5525
+ const queryParams = new Map<string, any>();
5526
+
5527
+ let bodyJson : string = "";
5528
+ bodyJson = JSON.stringify(body || {});
5529
+
5530
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
5531
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
5532
+ if (bearerToken) {
5533
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
5534
+ }
5535
+
5536
+ return Promise.race([
5537
+ fetch(fullUrl, fetchOptions).then((response) => {
5538
+ if (response.status == 204) {
5539
+ return response;
5540
+ } else if (response.status >= 200 && response.status < 300) {
5541
+ return response.json();
5542
+ } else {
5543
+ throw response;
5544
+ }
5545
+ }),
5546
+ new Promise((_, reject) =>
5547
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
5548
+ ),
5549
+ ]);
5550
+ }
5551
+
5496
5552
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>) {
5497
5553
  let fullPath = basePath + fragment + "?";
5498
5554
 
package/client.ts CHANGED
@@ -90,6 +90,8 @@ import {
90
90
  ApiSearchMessageResponse,
91
91
  ApiPinMessageRequest,
92
92
  ApiPinMessagesList,
93
+ ApiCreateWebhookRequest,
94
+ ApiWebhookResponse,
93
95
  } from "./api.gen";
94
96
 
95
97
  import { Session } from "./session";
@@ -768,6 +770,18 @@ export class Client {
768
770
  });
769
771
  }
770
772
 
773
+ /** Create a new event for clan. */
774
+ async createWebhook(session: Session, request: ApiCreateWebhookRequest): Promise<ApiWebhookResponse> {
775
+ if (this.autoRefreshSession && session.refresh_token &&
776
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
777
+ await this.sessionRefresh(session);
778
+ }
779
+
780
+ return this.apiClient.createWebhookLink(session.token, request).then((response: ApiWebhookResponse) => {
781
+ return Promise.resolve(response);
782
+ });
783
+ }
784
+
771
785
  /** add role for channel. */
772
786
  async addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean> {
773
787
  if (this.autoRefreshSession && session.refresh_token &&
package/dist/api.gen.d.ts CHANGED
@@ -129,6 +129,7 @@ export interface ApiChannelDescription {
129
129
  channel_label?: string;
130
130
  channel_private?: number;
131
131
  clan_id?: string;
132
+ count_mess_unread?: number;
132
133
  creator_id?: string;
133
134
  last_seen_message?: ApiChannelMessageHeader;
134
135
  last_sent_message?: ApiChannelMessageHeader;
@@ -271,6 +272,12 @@ export interface ApiCreateRoleRequest {
271
272
  title?: string;
272
273
  }
273
274
  /** */
275
+ export interface ApiCreateWebhookRequest {
276
+ channel_id?: string;
277
+ clan_id?: string;
278
+ hook_name?: string;
279
+ }
280
+ /** */
274
281
  export interface ApiDeleteEventRequest {
275
282
  event_id?: string;
276
283
  }
@@ -701,6 +708,12 @@ export interface ApiVoiceChannelUser {
701
708
  export interface ApiVoiceChannelUserList {
702
709
  voice_channel_users?: Array<ApiVoiceChannelUser>;
703
710
  }
711
+ /** */
712
+ export interface ApiWebhookResponse {
713
+ channel_id?: string;
714
+ hook_name?: string;
715
+ hook_url?: string;
716
+ }
704
717
  /** The object to store. */
705
718
  export interface ApiWriteStorageObject {
706
719
  collection?: string;
@@ -958,5 +971,7 @@ export declare class MezonApi {
958
971
  getUsers(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, facebookIds?: Array<string>, options?: any): Promise<ApiUsers>;
959
972
  /** */
960
973
  updateUser(bearerToken: string, body: ApiUpdateUsersRequest, options?: any): Promise<any>;
974
+ /** Create webhook */
975
+ createWebhookLink(bearerToken: string, body: ApiCreateWebhookRequest, options?: any): Promise<ApiWebhookResponse>;
961
976
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
962
977
  }
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, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList } 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, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiCreateWebhookRequest, ApiWebhookResponse } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -396,6 +396,8 @@ export declare class Client {
396
396
  createRole(session: Session, request: ApiCreateRoleRequest): Promise<ApiRole>;
397
397
  /** Create a new event for clan. */
398
398
  createEvent(session: Session, request: ApiCreateEventRequest): Promise<ApiEventManagement>;
399
+ /** Create a new event for clan. */
400
+ createWebhook(session: Session, request: ApiCreateWebhookRequest): Promise<ApiWebhookResponse>;
399
401
  /** add role for channel. */
400
402
  addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean>;
401
403
  /** Update action role when delete role */
@@ -3978,6 +3978,35 @@ var MezonApi = class {
3978
3978
  )
3979
3979
  ]);
3980
3980
  }
3981
+ /** Create webhook */
3982
+ createWebhookLink(bearerToken, body, options = {}) {
3983
+ if (body === null || body === void 0) {
3984
+ throw new Error("'body' is a required parameter but is null or undefined.");
3985
+ }
3986
+ const urlPath = "/v2/webhook/create";
3987
+ const queryParams = /* @__PURE__ */ new Map();
3988
+ let bodyJson = "";
3989
+ bodyJson = JSON.stringify(body || {});
3990
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3991
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3992
+ if (bearerToken) {
3993
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3994
+ }
3995
+ return Promise.race([
3996
+ fetch(fullUrl, fetchOptions).then((response) => {
3997
+ if (response.status == 204) {
3998
+ return response;
3999
+ } else if (response.status >= 200 && response.status < 300) {
4000
+ return response.json();
4001
+ } else {
4002
+ throw response;
4003
+ }
4004
+ }),
4005
+ new Promise(
4006
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4007
+ )
4008
+ ]);
4009
+ }
3981
4010
  buildFullUrl(basePath, fragment, queryParams) {
3982
4011
  let fullPath = basePath + fragment + "?";
3983
4012
  for (let [k, v] of queryParams) {
@@ -4912,6 +4941,17 @@ var Client = class {
4912
4941
  });
4913
4942
  });
4914
4943
  }
4944
+ /** Create a new event for clan. */
4945
+ createWebhook(session, request) {
4946
+ return __async(this, null, function* () {
4947
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
4948
+ yield this.sessionRefresh(session);
4949
+ }
4950
+ return this.apiClient.createWebhookLink(session.token, request).then((response) => {
4951
+ return Promise.resolve(response);
4952
+ });
4953
+ });
4954
+ }
4915
4955
  /** add role for channel. */
4916
4956
  addRolesChannelDesc(session, request) {
4917
4957
  return __async(this, null, function* () {