Skip to content

Commit 95fe2d0

Browse files
authored
Merge pull request #1 from Amele9/master
The GreenAPI class has been updated
2 parents c52c896 + 49e50d8 commit 95fe2d0

13 files changed

Lines changed: 152 additions & 124 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pip install whatsapp-api-client-python
2121
## Import
2222

2323
```
24-
from whatsapp_api_client_python import API
24+
from whatsapp_api_client_python import GreenAPI
2525
```
2626
## Authorization
2727

@@ -32,7 +32,7 @@ To send a message or to exacute some other Green-API method, you have to have th
3232
### How to initialize an object
3333

3434
```
35-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
35+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
3636
```
3737

3838
### Sending a text message to a WhatsApp number

README_RUS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pip install whatsapp-api-client-python
1818
## Import
1919

2020
```
21-
from whatsapp_api_client_python import API
21+
from whatsapp_api_client_python import GreenAPI
2222
```
2323
## Авторизация
2424

@@ -29,7 +29,7 @@ from whatsapp_api_client_python import API
2929
### Как инициализировать объект
3030

3131
```
32-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
32+
greenAPI = API.GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
3333
```
3434

3535
### Отправка текстового сообщения на номер WhatsApp

examples/createGroupAndSendMessage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from os import environ
22

3-
from whatsapp_api_client_python import API as API
3+
from whatsapp_api_client_python import GreenAPI
44

55
# First you need to set the environment variables
66
ID_INSTANCE = environ['ID_INSTANCE']
77
API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
88

9-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
9+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
1010

1111
def main():
1212
chatIds = [

examples/receiveNotification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from os import environ
22
from datetime import datetime
33
import json
4-
from whatsapp_api_client_python import API as API
4+
from whatsapp_api_client_python import GreenAPI
55

66

77
ID_INSTANCE = environ['ID_INSTANCE']
88
API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
99

10-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
10+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
1111

1212
def main():
1313
greenAPI.webhooks.startReceivingNotifications(onEvent)

examples/sendPictureByLink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from os import environ
22

3-
from whatsapp_api_client_python import API as API
3+
from whatsapp_api_client_python import GreenAPI
44

55
ID_INSTANCE = environ['ID_INSTANCE']
66
API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
77

8-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
1111
result = greenAPI.sending.sendFileByUrl('79001234567@c.us',

examples/sendPictureByUpload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from os import environ
22

3-
from whatsapp_api_client_python import API as API
3+
from whatsapp_api_client_python import GreenAPI
44

55
ID_INSTANCE = environ['ID_INSTANCE']
66
API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
77

8-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
1111
result = greenAPI.sending.sendFileByUpload('79001234567@c.us',

examples/sendTextMessage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from os import environ
22

3-
from whatsapp_api_client_python import API as API
3+
from whatsapp_api_client_python import GreenAPI
44

55
ID_INSTANCE = environ['ID_INSTANCE']
66
API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
77

8-
greenAPI = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
1111
result = greenAPI.sending.sendMessage('79001234567@c.us', 'Message text')

tests/test_library.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
from os import environ
3+
4+
from whatsapp_api_client_python import GreenAPI
5+
6+
ID_INSTANCE = environ["ID_INSTANCE"]
7+
API_TOKEN_INSTANCE = environ["API_TOKEN_INSTANCE"]
8+
9+
greenAPI = GreenAPI(ID_INSTANCE, API_TOKEN_INSTANCE)
10+
11+
12+
class GreenAPITestCase(unittest.TestCase):
13+
def test_getSettings(self):
14+
response = greenAPI.account.getSettings()
15+
16+
self.assertEqual(response.status_code, 200, response.error)
17+
18+
def test_getStateInstance(self):
19+
response = greenAPI.account.getSettings()
20+
21+
self.assertEqual(response.status_code, 200, response.error)
22+
23+
24+
if __name__ == '__main__':
25+
unittest.main()

tests/test_main.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

whatsapp_api_client_python/API.py

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)