diff --git a/README.md b/README.md index 6fda20e..e91c5b6 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ greenAPI = API.GreenAPI( ### Sending a text message to a WhatsApp number -Link to example: [sendTextMessage.py](./examples/sync/sendTextMessage.py). +Link to example: [sendTextMessage.py](./examples/sync/sending/sendTextMessage.py). ``` response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text") @@ -82,7 +82,7 @@ asyncio.run(main()) ### Sending an image via URL -Link to example: [sendPictureByLink.py](./examples/sync/sendPictureByLink.py). +Link to example: [sendPictureByLink.py](./examples/sync/sending/sendPictureByLink.py). ``` response = greenAPI.sending.sendFileByUrl( @@ -97,7 +97,7 @@ print(response.data) ### Sending an image by uploading from the disk -Link to example: [sendPictureByUpload.py](./examples/sync/sendPictureByUpload.py). +Link to example: [sendPictureByUpload.py](./examples/sync/sending/sendPictureByUpload.py). ``` response = greenAPI.sending.sendFileByUpload( @@ -185,7 +185,7 @@ asyncio.run(main()) ### Sending a polling message -Link to example: [sendPoll.py](./examples/sync/sendPoll.py). +Link to example: [sendPoll.py](./examples/sync/sending/sendPoll.py). ``` response = greenAPI.sending.sendPoll( @@ -215,26 +215,87 @@ response = greenAPI.statuses.sendTextStatus( print(response.data) ``` +### Sending interactive buttons + +Link to example: [sendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py). + +``` +response = greenAPI.sending.sendInteractiveButtons( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" +) + +print(response.data) +``` + +### Sending interactive buttons async + +Link to example: [sendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py). + +``` +import asyncio + +async def main(): + response = await greenAPI.sending.sendInteractiveButtonsAsync( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" + ) + print(response.data) +asyncio.run(main()) +``` + ## Examples list | Description | Module | |----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------| -| Example of sending text | [sendTextMessage.py](./examples/sync/sendTextMessage.pyy) | +| Example of sending text | [sendTextMessage.py](./examples/sync/sending/sendTextMessage.pyy) | | Example of sending text asynchronously | [sendTextMessageAsync.py](./examples/async/sendMessageAsync.py) | -| Example of sending a picture by URL | [sendPictureByLink.py](./examples/sync/sendPictureByLink.py) | +| Example of sending a picture by URL | [sendPictureByLink.py](./examples/sync/sending/sendPictureByLink.py) | | Example of sending a file by URL asynchronously | [sendFileByUrlAsync.py](./examples/async/sending/sendFileByUrlAsync.py) | -| Example of sending a picture by uploading from the disk | [sendPictureByUpload.py](./examples/sync/sendPictureByUpload.py) | +| Example of sending a picture by uploading from the disk | [sendPictureByUpload.py](./examples/sync/sending/sendPictureByUpload.py) | | Example of sending file by uploading from the disk asynchronously | [sendFileByUploadAsync.py](./examples/async/sending/sendFileByUploadAsync.py) | -| Example of a group creation and sending a message to the group | [createGroupAndSendMessage.py](./examples/sync/createGroupAndSendMessage.py) | +| Example of a group creation and sending a message to the group | [createGroupAndSendMessage.py](./examples/sync/sending/createGroupAndSendMessage.py) | | Example of a group creation and sending a message to the group asynchronously | [createGroupAndSendMessageAsync.py](./examples/async/createGroupAndSendMessageAsync.py) | | Example of incoming webhooks receiving | [receiveNotification.py](./examples/sync/receiveNotification.py) | | Example of incoming webhooks receiving asynchronously | [receiveNotificationAsync.py](./examples/async/receiveNotificationAsync.py) | -| Example of sending a polling message | [sendPoll.py](./examples/sync/sendPoll.py) | +| Example of sending a polling message | [sendPoll.py](./examples/sync/sending/sendPoll.py) | | Example of sending a polling message asynchronously | [sendPollAsync.py](./examples/async/sending/sendPollasync.py) | | Example of sending a text status | [sendTextStatus.py](./examples/sync/statusesMethods/sendTextStatus.py) | | Example of sending a text status asynchronously | [sendTextStatusAsync.py](./examples/async/statusesMethods/sendTextStatusAsync.py) | | Example of creating instance | [CreateInstance.py](./examples/sync/partherMethods/CreateInstance.py) | | Example of creating instance asynchronously | [CreateInstanceAsync.py](./examples/async/partherMethods/CreateInstanceAsync.py) | +| Example of sending interactive buttons | [SendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py) | +| Example of sending interactive buttons asynchronously | [SendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py) | +| Example of sending interactive buttons with a reply | [SendInteractiveButtonsReply.py](../examples/sync/sending/sendInteractiveButtonsReply.py) | +| Example of sending interactive buttons asynchronously with a reply | [SendInteractiveButtonsReplyAsync.py](../examples/async/sending/sendInteractiveButtonsReplyAsync.py) | ## The full list of the library methods @@ -278,17 +339,15 @@ print(response.data) | `receiving.deleteNotification` | The method is designed to remove an incoming notification from the notification queue | [DeleteNotification](https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotification/) | | `receiving.downloadFile` | The method is for downloading received and sent files | [DownloadFile](https://green-api.com/en/docs/api/receiving/files/DownloadFile/) | | `sending.sendMessage` | The method is designed to send a text message to a personal or group chat | [SendMessage](https://green-api.com/en/docs/api/sending/SendMessage/) | -| `sending.sendButtons` | The method is designed to send a message with buttons to a personal or group chat | [SendButtons](https://green-api.com/en/docs/api/sending/SendButtons/) | -| `sending.sendTemplateButtons` | The method is designed to send a message with interactive buttons from the list of templates in a personal or group chat | [SendTemplateButtons](https://green-api.com/en/docs/api/sending/SendTemplateButtons/) | -| `sending.sendListMessage` | The method is designed to send a message with a selection button from a list of values to a personal or group chat | [SendListMessage](https://green-api.com/en/docs/api/sending/SendListMessage/) | | `sending.sendFileByUpload` | The method is designed to send a file loaded through a form (form-data) | [SendFileByUpload](https://green-api.com/en/docs/api/sending/SendFileByUpload/) | | `sending.sendFileByUrl` | The method is designed to send a file downloaded via a link | [SendFileByUrl](https://green-api.com/en/docs/api/sending/SendFileByUrl/) | | `sending.uploadFile` | The method is designed to upload a file to the cloud storage, which can be sent using the sendFileByUrl method | [UploadFile](https://green-api.com/en/docs/api/sending/UploadFile/) | | `sending.sendLocation` | The method is designed to send a geolocation message | [SendLocation](https://green-api.com/en/docs/api/sending/SendLocation/) | | `sending.sendContact` | The method is for sending a message with a contact | [SendContact](https://green-api.com/en/docs/api/sending/SendContact/) | -| `sending.sendLink` | The method is designed to send a message with a link that will add an image preview, title and description | [SendLink](https://green-api.com/en/docs/api/sending/SendLink/) | | `sending.forwardMessages` | The method is designed for forwarding messages to a personal or group chat | [ForwardMessages](https://green-api.com/en/docs/api/sending/ForwardMessages/) | | `sending.sendPoll` | The method is designed for sending messages with a poll to a private or group chat | [SendPoll](https://green-api.com/en/docs/api/sending/SendPoll/) | +| `sending.sendInteractiveButtons` | This method is used to send messages with interactive buttons | [sendInteractiveButtons](https://green-api.com/en/docs/api/sending/SendInteractiveButtons/) | +| `sending.sendInteractiveButtonsReply` | This method is used to send messages with interactive buttons with a reply | [sendInteractiveButtonsReply](https://green-api.com/en/docs/api/sending/SendInteractiveButtonsReply/) | | `serviceMethods.checkWhatsapp` | The method checks if there is a WhatsApp account on the phone number | [CheckWhatsapp](https://green-api.com/en/docs/api/service/CheckWhatsapp/) | | `serviceMethods.getAvatar` | The method returns the avatar of the correspondent or group chat | [GetAvatar](https://green-api.com/en/docs/api/service/GetAvatar/) | | `serviceMethods.getContacts` | The method is designed to get a list of contacts of the current account | [GetContacts](https://green-api.com/en/docs/api/service/GetContacts/) | diff --git a/docs/README.md b/docs/README.md index 827ad4c..b2e35b7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,7 +57,7 @@ greenAPI = API.GreenAPI( ### Отправка текстового сообщения на номер WhatsApp -Ссылка на пример: [sendTextMessage.py](../examples/sync/sendTextMessage.py). +Ссылка на пример: [sendTextMessage.py](../examples/sync/sending/sendTextMessage.py). ``` response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text") @@ -68,7 +68,7 @@ print(response.data) ### Отправка текстового сообщения асинхронно -Ссылка на пример: [sendMessageAsync.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/async/sending/sendMessageAsync.py). +Ссылка на пример: [sendMessageAsync.py](../examples/async/sending/sendMessageAsync.py). ``` import asyncio @@ -82,7 +82,7 @@ asyncio.run(main()) ### Отправка картинки по URL -Ссылка на пример: [sendPictureByLink.py](../examples/sync/sendPictureByLink.py). +Ссылка на пример: [sendPictureByLink.py](../examples/sync/sending/sendPictureByLink.py). ``` response = greenAPI.sending.sendFileByUrl( @@ -97,7 +97,7 @@ print(response.data) ### Отправка картинки загрузкой с диска -Ссылка на пример: [sendPictureByUpload.py](../examples/sync/sendPictureByUpload.py). +Ссылка на пример: [sendPictureByUpload.py](../examples/sync/sending/sendPictureByUpload.py). ``` response = greenAPI.sending.sendFileByUpload( @@ -186,7 +186,7 @@ asyncio.run(main()) ### Отправка сообщения с опросом -Ссылка на пример: [sendPoll.py](../examples/sync/sendPoll.py). +Ссылка на пример: [sendPoll.py](../examples/sync/sending/sendPoll.py). ``` response = greenAPI.sending.sendPoll( @@ -202,9 +202,9 @@ response = greenAPI.sending.sendPoll( print(response.data) ``` -## Отправка текстового статуса +### Отправка текстового статуса -Ссылка на пример: [sendPoll.py](../examples/sync/statusesMethods/sendTextStatus.py). +Ссылка на пример: [sendTextStatus.py](../examples/sync/statusesMethods/sendTextStatus.py). ``` response = greenAPI.statuses.sendTextStatus( @@ -216,26 +216,87 @@ response = greenAPI.statuses.sendTextStatus( print(response.data) ``` +### Отправка интерактивных кнопок + +Ссылка на пример: [sendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py). + +``` +response = greenAPI.sending.sendInteractiveButtons( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" +) + +print(response.data) +``` + +### Асинхронная отправка интерактивных кнопок + +Ссылка на пример: [sendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py). + +``` +import asyncio + +async def main(): + response = await greenAPI.sending.sendInteractiveButtonsAsync( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" + ) + print(response.data) +asyncio.run(main()) +``` + ## Список примеров | Описание | Модуль | |--------------------------------------------------------|-----------------------------------------------------------------------------------| -| Пример отправки текста | [sendTextMessage.py](../examples/sync/sendTextMessage.py) | +| Пример отправки текста | [sendTextMessage.py](../examples/sync/sending/sendTextMessage.py) | | Пример асинхронной отправки текста | [sendTextMessageAsync.py](../examples/async/sending/sendMessageAsync.py) | -| Пример отправки картинки по URL | [sendPictureByLink.py](../examples/sync/sendPictureByLink.py) | +| Пример отправки картинки по URL | [sendPictureByLink.py](../examples/sync/sending/sendPictureByLink.py) | | Пример асинхронной отправки файла по URL | [sendFileByUrlAsync.py](../examples/async/sending/sendFileByUrlAsync.py) | -| Пример отправки картинки загрузкой с диска | [sendPictureByUpload.py](../examples/sync/sendPictureByUpload.py) | +| Пример отправки картинки загрузкой с диска | [sendPictureByUpload.py](../examples/sync/sending/sendPictureByUpload.py) | | Пример асинхронной отправки картинки загрузкой с диска | [sendFileByUploadAsync.py](../examples/async/sending/sendFileByUploadAsync.py) | | Пример создания группы и отправки сообщения в группу | [createGroupAndSendMessage.py](../examples/sync/createGroupAndSendMessage.py) | | Пример асинхронных создания группы и отправки сообщения в группу | [createGroupAndSendMessageAsync.py](../examples/async/createGroupAndSendMessageAsync.py) | | Пример получения входящих уведомлений | [receiveNotification.py](../examples/sync/receiveNotification.py) | | Пример асинхронного получения входящих уведомлений | [receiveNotificationФынтс.py](../examples/async/receiveNotificationAsync.py) | -| Пример отправки сообщения с опросом | [sendPoll.py](../examples/sync/sendPoll.py) | +| Пример отправки сообщения с опросом | [sendPoll.py](../examples/sync/sending/sendPoll.py) | | Пример асинхронной отправки сообщения с опросом | [sendPollAsync.py](../examples/async/sending/sendPollAsync.py) | | Пример отправки текстового статуса | [sendTextStatus.py](../examples/sync/statusesMethods/sendTextStatus.py) | | Пример асинхронной отправки текстового статуса | [sendTextStatusAsync.py](../examples/async/statusesMethods/sendTextStatusAsync.py) | | Пример создания инстанса | [CreateInstance.py](../examples/sync/partherMethods/CreateInstance.py) | -| Пример асинхронного создания инстанса | [CreateInstanceAsync.py](../examples/async/partnerMethods/CreateInstanceAsync.py) | +| Пример асинхронного создания инстанса | [CreateInstanceAsync.py](../examples/async/partnerMethods/CreateInstanceAsync.py) | +| Пример отправки интерактивных кнопок | [SendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py) | +| Пример асинхронной отправки интерактивных кнопок | [SendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py) | +| Пример отправки интерактивных кнопок с ответом | [SendInteractiveButtonsReply.py](../examples/sync/sending/sendInteractiveButtonsReply.py) | +| Пример асинхронной отправки интерактивных кнопок с ответом | [SendInteractiveButtonsReplyAsync.py](../examples/async/sending/sendInteractiveButtonsReplyAsync.py) | ## Полный список методов библиотеки @@ -272,17 +333,15 @@ print(response.data) | `receiving.deleteNotification` | Метод предназначен для удаления входящего уведомления из очереди уведомлений | [DeleteNotification](https://green-api.com/docs/api/receiving/technology-http-api/DeleteNotification/) | | `receiving.downloadFile` | Метод предназначен для скачивания принятых и отправленных файлов | [DownloadFile](https://green-api.com/docs/api/receiving/files/DownloadFile/) | | `sending.sendMessage` | Метод предназначен для отправки текстового сообщения в личный или групповой чат | [SendMessage](https://green-api.com/docs/api/sending/SendMessage/) | -| `sending.sendButtons` | Метод предназначен для отправки сообщения с кнопками в личный или групповой чат | [SendButtons](https://green-api.com/docs/api/sending/SendButtons/) | -| `sending.sendTemplateButtons` | Метод предназначен для отправки сообщения с интерактивными кнопками из перечня шаблонов в личный или групповой чат | [SendTemplateButtons](https://green-api.com/docs/api/sending/SendTemplateButtons/) | -| `sending.sendListMessage` | Метод предназначен для отправки сообщения с кнопкой выбора из списка значений в личный или групповой чат | [SendListMessage](https://green-api.com/docs/api/sending/SendListMessage/) | | `sending.sendFileByUpload` | Метод предназначен для отправки файла, загружаемого через форму (form-data) | [SendFileByUpload](https://green-api.com/docs/api/sending/SendFileByUpload/) | | `sending.sendFileByUrl` | Метод предназначен для отправки файла, загружаемого по ссылке | [SendFileByUrl](https://green-api.com/docs/api/sending/SendFileByUrl/) | | `sending.uploadFile` | Метод предназначен для загрузки файла в облачное хранилище, который можно отправить методом sendFileByUrl | [UploadFile](https://green-api.com/docs/api/sending/UploadFile/) | | `sending.sendLocation` | Метод предназначен для отправки сообщения геолокации | [SendLocation](https://green-api.com/docs/api/sending/SendLocation/) | | `sending.sendContact` | Метод предназначен для отправки сообщения с контактом | [SendContact](https://green-api.com/docs/api/sending/SendContact/) | -| `sending.sendLink` | Метод предназначен для отправки сообщения со ссылкой, по которой будут добавлены превью изображения, заголовок и описание | [SendLink](https://green-api.com/docs/api/sending/SendLink/) | | `sending.forwardMessages` | Метод предназначен для пересылки сообщений в личный или групповой чат | [ForwardMessages](https://green-api.com/docs/api/sending/ForwardMessages/) | | `sending.sendPoll` | Метод предназначен для отправки сообщения с опросом в личный или групповой чат | [SendPoll](https://green-api.com/docs/api/sending/SendPoll/) | +| `sending.sendInteractiveButtons` | Метод предназначен для отправки сообщений с интерактивными кнопками | [sendInteractiveButtons](https://green-api.com/docs/api/sending/SendInteractiveButtons/) | +| `sending.sendInteractiveButtonsReply` | Метод предназначен для отправки сообщений с интерактивными кнопками с ответом | [sendInteractiveButtonsReply](https://green-api.com/docs/api/sending/SendInteractiveButtonsReply/) | | `serviceMethods.checkWhatsapp` | Метод проверяет наличие аккаунта WhatsApp на номере телефона | [CheckWhatsapp](https://green-api.com/docs/api/service/CheckWhatsapp/) | | `serviceMethods.getAvatar` | Метод возвращает аватар корреспондента или группового чата | [GetAvatar](https://green-api.com/docs/api/service/GetAvatar/) | | `serviceMethods.getContacts` | Метод предназначен для получения списка контактов текущего аккаунта | [GetContacts](https://green-api.com/docs/api/service/GetContacts/) | diff --git a/examples/async/sending/sendInteractiveButtonsAsync.py b/examples/async/sending/sendInteractiveButtonsAsync.py new file mode 100644 index 0000000..c05400b --- /dev/null +++ b/examples/async/sending/sendInteractiveButtonsAsync.py @@ -0,0 +1,31 @@ +import asyncio +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI( + "1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" +) + +async def main(): + response = await greenAPI.sending.sendInteractiveButtonsAsync( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" + ) + if response.code == 200: + print(response.data) + +if __name__ == '__main__': + asyncio.run(main()) \ No newline at end of file diff --git a/examples/async/sending/sendInteractiveButtonsReplyAsync.py b/examples/async/sending/sendInteractiveButtonsReplyAsync.py new file mode 100644 index 0000000..5d40fe7 --- /dev/null +++ b/examples/async/sending/sendInteractiveButtonsReplyAsync.py @@ -0,0 +1,27 @@ +import asyncio +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI( + "1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" +) + +async def main(): + response = await greenAPI.sending.sendInteractiveButtonsReplyAsync( + "79001234567@c.us", + "This is message with buttons!", + [{ + "buttonId": "1", + "buttonText": "First Button" + }, + { + "buttonId": "2", + "buttonText": "Second Button" + }], + "Check this out", + "Hope you like it" + ) + if response.code == 200: + print(response.data) + +if __name__ == '__main__': + asyncio.run(main()) \ No newline at end of file diff --git a/examples/sync/sending/sendInteractiveButtons.py b/examples/sync/sending/sendInteractiveButtons.py new file mode 100644 index 0000000..8f4c7cb --- /dev/null +++ b/examples/sync/sending/sendInteractiveButtons.py @@ -0,0 +1,29 @@ +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI( + "1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" +) + +def main(): + response = greenAPI.sending.sendInteractiveButtons( + "79001234567@c.us", + "This is message with buttons!", + [{ + "type": "call", + "buttonId": "1", + "buttonText": "Call me", + "phoneNumber": "79001234567" + }, + { + "type": "url", + "buttonId": "2", + "buttonText": "Green-api", + "url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/" + }], + "Check this out", + "Hope you like it" + ) + print(response.data) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/examples/sync/sending/sendInteractiveButtonsReply.py b/examples/sync/sending/sendInteractiveButtonsReply.py new file mode 100644 index 0000000..fb712dc --- /dev/null +++ b/examples/sync/sending/sendInteractiveButtonsReply.py @@ -0,0 +1,25 @@ +from whatsapp_api_client_python import API + +greenAPI = API.GreenAPI( + "1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345" +) + +def main(): + response = greenAPI.sending.sendInteractiveButtonsReply( + "79001234567@c.us", + "This is message with buttons!", + [{ + "buttonId": "1", + "buttonText": "First Button" + }, + { + "buttonId": "2", + "buttonText": "Second Button" + }], + "Check this out", + "Hope you like it" + ) + print(response.data) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/examples/sync/sendPictureByLink.py b/examples/sync/sending/sendPictureByLink.py similarity index 100% rename from examples/sync/sendPictureByLink.py rename to examples/sync/sending/sendPictureByLink.py diff --git a/examples/sync/sendPictureByUpload.py b/examples/sync/sending/sendPictureByUpload.py similarity index 100% rename from examples/sync/sendPictureByUpload.py rename to examples/sync/sending/sendPictureByUpload.py diff --git a/examples/sync/sendPoll.py b/examples/sync/sending/sendPoll.py similarity index 100% rename from examples/sync/sendPoll.py rename to examples/sync/sending/sendPoll.py diff --git a/examples/sync/sendTextMessage.py b/examples/sync/sending/sendTextMessage.py similarity index 100% rename from examples/sync/sendTextMessage.py rename to examples/sync/sending/sendTextMessage.py diff --git a/examples/sync/uploadFileAndSendFileByUrl.py b/examples/sync/sending/uploadFileAndSendFileByUrl.py similarity index 100% rename from examples/sync/uploadFileAndSendFileByUrl.py rename to examples/sync/sending/uploadFileAndSendFileByUrl.py diff --git a/setup.py b/setup.py index 2624f07..c807611 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="whatsapp-api-client-python", - version="0.0.51", + version="0.0.52", description=( "This library helps you easily create" " a Python application with WhatsApp API." @@ -45,4 +45,4 @@ ), install_requires=["requests>=2.31.0", "aiofiles>=24.1.0", "aiogram>=3.21.0", "aiohttp>=3.9.0"], python_requires=">=3.7" -) \ No newline at end of file +) diff --git a/whatsapp_api_client_python/tools/sending.py b/whatsapp_api_client_python/tools/sending.py index 49e7922..3372d81 100644 --- a/whatsapp_api_client_python/tools/sending.py +++ b/whatsapp_api_client_python/tools/sending.py @@ -64,7 +64,7 @@ def sendButtons( archiveChat: Optional[bool] = None ) -> Response: """ - The method is deprecated. + The method is deprecated. Please use SendInteractiveButtons. The method is aimed for sending a button message to a personal or a group chat. @@ -91,6 +91,8 @@ def sendTemplateButtons( archiveChat: Optional[bool] = None ) -> Response: """ + The method is deprecated. Please use SendInteractiveButtonsReply. + The method is aimed for sending a message with template list interactive buttons to a personal or a group chat. @@ -118,6 +120,8 @@ def sendListMessage( archiveChat: Optional[bool] = None ) -> Response: """ + The method is deprecated. Please use SendMessage. + The method is aimed for sending a message with a select button from a list of values to a personal or a group chat. @@ -445,6 +449,86 @@ async def sendPollAsync( "{{host}}/waInstance{{idInstance}}/sendPoll/{{apiTokenInstance}}", request_body ) + + def sendInteractiveButtons( + self, + chatId: str, + body: str, + buttons: List[Dict[str, Union[str, Dict[str, str]]]], + header: Optional[str] = None, + footer: Optional[str] = None, + ) -> Response: + """ + The method is used to send a message with buttons to personal chats. + + https://green-api.com/en/docs/api/sending/SendInteractiveButtons/ + """ + + request_body = self.__handle_parameters(locals()) + + return self.api.request( + "POST", ( + "{{host}}/waInstance{{idInstance}}/" + "sendInteractiveButtons/{{apiTokenInstance}}" + ), request_body + ) + + async def sendInteractiveButtonsAsync( + self, + chatId: str, + body: str, + buttons: List[Dict[str, Union[str, Dict[str, str]]]], + header: Optional[str] = None, + footer: Optional[str] = None, + ) -> Response: + request_body = self.__handle_parameters(locals()) + + return await self.api.requestAsync( + "POST", ( + "{{host}}/waInstance{{idInstance}}/" + "sendInteractiveButtons/{{apiTokenInstance}}" + ), request_body + ) + + def sendInteractiveButtonsReply( + self, + chatId: str, + body: str, + buttons: List[Dict[str, str]], + header: Optional[str] = None, + footer: Optional[str] = None, + ) -> Response: + """ + The method is used to send a message with buttons to personal chats. + + https://green-api.com/en/docs/api/sending/SendInteractiveButtonsReply/ + """ + + request_body = self.__handle_parameters(locals()) + + return self.api.request( + "POST", ( + "{{host}}/waInstance{{idInstance}}/" + "sendInteractiveButtonsReply/{{apiTokenInstance}}" + ), request_body + ) + + async def sendInteractiveButtonsReplyAsync( + self, + chatId: str, + body: str, + buttons: List[Dict[str, str]], + header: Optional[str] = None, + footer: Optional[str] = None, + ) -> Response: + request_body = self.__handle_parameters(locals()) + + return await self.api.requestAsync( + "POST", ( + "{{host}}/waInstance{{idInstance}}/" + "sendInteractiveButtonsReply/{{apiTokenInstance}}" + ), request_body + ) @classmethod def __handle_parameters(cls, parameters: dict) -> dict: