Skip to content

Commit d6876ed

Browse files
authored
Merge pull request #149 from green-api/SW-4489
Support DeleteMessage, EditMessage, new webhook types
2 parents 92bbdb0 + f73c1f3 commit d6876ed

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/utils/InstanceAPI.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,45 @@ class InstanceAPI {
5353
return response.data
5454
}
5555

56+
/**
57+
*
58+
* @param {String} chatId
59+
* @param {String} idMessage
60+
*/
61+
async deleteMessage(chatId, idMessage) {
62+
CommonUtils.validateString('chatId', chatId)
63+
CommonUtils.validateString('idMessage', idMessage)
64+
65+
const method = 'deleteMessage';
66+
const postData = {
67+
'chatId': chatId,
68+
'idMessage': idMessage,
69+
}
70+
const response = await axios.post(CommonUtils.generateMethodURL(this._restAPI.params, method), postData);
71+
return response.data
72+
}
73+
74+
/**
75+
*
76+
* @param {String} chatId
77+
* @param {String} idMessage
78+
* @param {String} message
79+
*/
80+
async editMessage(chatId, idMessage, message) {
81+
CommonUtils.validateString('chatId', chatId)
82+
CommonUtils.validateString('idMessage', idMessage)
83+
CommonUtils.validateString('message', message)
84+
85+
const method = 'editMessage';
86+
const postData = {
87+
'chatId': chatId,
88+
'idMessage': idMessage,
89+
'message': message,
90+
}
91+
const response = await axios.post(CommonUtils.generateMethodURL(this._restAPI.params, method), postData);
92+
return response.data
93+
}
94+
5695
/**
5796
*
5897
* @param {Number} phoneNumber

src/utils/WebhookServiceAPI.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class WebhookServiceAPI {
2727
onReceivingMessageTextURL: 'onReceivingMessageTextURL',
2828
onReceivingMessageContact: 'onReceivingMessageContact',
2929
onReceivingMessageLocation: 'onReceivingMessageLocation',
30+
onReceivingEditedMessage: 'onReceivingEditedMessage',
31+
onReceivingDeletedMessage: 'onReceivingDeletedMessage',
3032
}
3133
this._callbacks = new Map()
3234
}
@@ -102,6 +104,14 @@ class WebhookServiceAPI {
102104
{
103105
this._callbacks.set(this.callbackTypes.onReceivingMessageLocation, callback)
104106
}
107+
onReceivingEditedMessage(callback)
108+
{
109+
this._callbacks.set(this.callbackTypes.onReceivingEditedMessage, callback)
110+
}
111+
onReceivingDeletedMessage(callback)
112+
{
113+
this._callbacks.set(this.callbackTypes.onReceivingDeletedMessage, callback)
114+
}
105115
}
106116

107117
export default WebhookServiceAPI;

0 commit comments

Comments
 (0)