From f3771905ad92168187c48ddba5da568fcc3af029 Mon Sep 17 00:00:00 2001 From: andreyMalyshkin <87826990+andreyMalyshkin@users.noreply.github.com> Date: Thu, 16 Nov 2023 12:18:53 +0600 Subject: [PATCH] fix removeAdmin and leave and added new method getAuthorizationCode --- src/utils/GroupAPI.js | 8 +++----- src/utils/InstanceAPI.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/utils/GroupAPI.js b/src/utils/GroupAPI.js index 42674b1..e169c07 100644 --- a/src/utils/GroupAPI.js +++ b/src/utils/GroupAPI.js @@ -107,14 +107,13 @@ class GroupAPI { * @param {String} participantChatId * @param {Number} participantPhone */ - async setGroupAdmin(groupId, participantChatId, participantPhone) { + async setGroupAdmin(groupId, participantChatId, participantPhone = null) { CommonUtils.validateString('groupId', groupId); const method = 'setGroupAdmin'; const postData = { 'groupId': groupId, 'participantChatId': participantChatId, - 'participantPhone': participantPhone, } const response = await axios.post(CommonUtils.generateMethodURL(this._restAPI.params, method), postData); return response.data; @@ -126,14 +125,13 @@ class GroupAPI { * @param {String} participantChatId * @param {Number} participantPhone */ - async removeAdmin(groupId, participantChatId, participantPhone) { + async removeAdmin(groupId, participantChatId, participantPhone = null) { CommonUtils.validateString('groupId', groupId); const method = 'removeAdmin'; const postData = { 'groupId': groupId, 'participantChatId': participantChatId, - 'participantPhone': participantPhone, } const response = await axios.post(CommonUtils.generateMethodURL(this._restAPI.params, method), postData); return response.data; @@ -146,7 +144,7 @@ class GroupAPI { async leaveGroup(groupId) { CommonUtils.validateString('groupId', groupId); - const method = 'removeAdmin'; + const method = 'leaveGroup'; const postData = { 'groupId': groupId, } diff --git a/src/utils/InstanceAPI.js b/src/utils/InstanceAPI.js index 27ef611..9600e5b 100644 --- a/src/utils/InstanceAPI.js +++ b/src/utils/InstanceAPI.js @@ -53,6 +53,21 @@ class InstanceAPI { return response.data } + /** + * + * @param {Number} phoneNumber + */ + async getAuthorizationCode(phoneNumber) { + CommonUtils.validateInteger('phoneNumber', phoneNumber); + + const method = 'getAuthorizationCode'; + const postData = { + 'phoneNumber': phoneNumber, + } + const response = await axios.post(CommonUtils.generateMethodURL(this._restAPI.params, method), postData); + return response.data + } + /** * * @param {String} chatId