Skip to content

Commit 7ab03e3

Browse files
committed
Rename class
1 parent 806c37d commit 7ab03e3

20 files changed

Lines changed: 107 additions & 107 deletions

README.md

Lines changed: 8 additions & 8 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 greenAPI
21+
from whatsapp_api_client_python import API
2222
```
2323
## Authorization
2424

@@ -29,13 +29,13 @@ To send a message or to exacute some other Green-API method, you have to have th
2929
### How to initialize an object
3030

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

3535
### Sending a text message to a WhatsApp number
3636

3737
```
38-
result = restApi.sending.sendMessage('79001234567@g.us', 'Message text')
38+
result = greenApi.sending.sendMessage('79001234567@g.us', 'Message text')
3939
```
4040

4141
Example url: [sendTextMessage.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sendTextMessage.py)
@@ -51,7 +51,7 @@ API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
5151
### Sending an image via URL
5252

5353
```
54-
result = restApi.sending.sendFileByUrl('120363025955348359@g.us',
54+
result = greenApi.sending.sendFileByUrl('120363025955348359@g.us',
5555
'https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
5656
'googlelogo_color_272x92dp.png', 'Google logo')
5757
```
@@ -61,7 +61,7 @@ Example url: [sendPictureByLink.py](https://github.com/green-api/whatsapp-api-cl
6161
### Sending an image by uploading from the disk
6262

6363
```
64-
result = restApi.sending.sendFileByUpload('120363025955348359@g.us',
64+
result = greenApi.sending.sendFileByUpload('120363025955348359@g.us',
6565
'C:\Games\PicFromDisk.png',
6666
'PicFromDisk.png', 'Picture from disk')
6767
```
@@ -74,11 +74,11 @@ Example url: [sendPictureByUpload.py](https://github.com/green-api/whatsapp-api-
7474
chatIds = [
7575
"79001234567@c.us"
7676
]
77-
resultCreate = restApi.groups.createGroup('GroupName',
77+
resultCreate = greenApi.groups.createGroup('GroupName',
7878
chatIds)
7979
8080
if resultCreate.code == 200:
81-
resultSend = restApi.sending.sendMessage(resultCreate.data['chatId'],
81+
resultSend = greenApi.sending.sendMessage(resultCreate.data['chatId'],
8282
'Message text')
8383
```
8484

@@ -90,7 +90,7 @@ Example url: [createGroupAndSendMessage.py](https://github.com/green-api/whatsap
9090
### Receiving incoming webhooks
9191

9292
```
93-
resultReceive = restApi.receiving.receiveNotification()
93+
resultReceive = greenApi.receiving.receiveNotification()
9494
```
9595

9696
## Examples list

README_RUS.md

Lines changed: 8 additions & 8 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 greenAPI
21+
from whatsapp_api_client_python import API
2222
```
2323
## Авторизация
2424

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

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

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

3737
```
38-
result = restApi.sending.sendMessage('79001234567@g.us', 'Message text')
38+
result = greenApi.sending.sendMessage('79001234567@g.us', 'Message text')
3939
```
4040

4141
Ссылка на пример: [sendTextMessage.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sendTextMessage.py)
@@ -51,7 +51,7 @@ API_TOKEN_INSTANCE = environ['API_TOKEN_INSTANCE']
5151
### Отправка картинки по URL
5252

5353
```
54-
result = restApi.sending.sendFileByUrl('120363025955348359@g.us',
54+
result = greenApi.sending.sendFileByUrl('120363025955348359@g.us',
5555
'https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
5656
'googlelogo_color_272x92dp.png', 'Google logo')
5757
```
@@ -61,7 +61,7 @@ result = restApi.sending.sendFileByUrl('120363025955348359@g.us',
6161
### Отправка картинки загрузкой с диска
6262

6363
```
64-
result = restApi.sending.sendFileByUpload('120363025955348359@g.us',
64+
result = greenApi.sending.sendFileByUpload('120363025955348359@g.us',
6565
'C:\Games\PicFromDisk.png',
6666
'PicFromDisk.png', 'Picture from disk')
6767
```
@@ -74,11 +74,11 @@ result = restApi.sending.sendFileByUpload('120363025955348359@g.us',
7474
chatIds = [
7575
"79001234567@c.us"
7676
]
77-
resultCreate = restApi.groups.createGroup('GroupName',
77+
resultCreate = greenApi.groups.createGroup('GroupName',
7878
chatIds)
7979
8080
if resultCreate.code == 200:
81-
resultSend = restApi.sending.sendMessage(resultCreate.data['chatId'],
81+
resultSend = greenApi.sending.sendMessage(resultCreate.data['chatId'],
8282
'Message text')
8383
```
8484

@@ -90,7 +90,7 @@ if resultCreate.code == 200:
9090
### Получить входящие уведомления
9191

9292
```
93-
resultReceive = restApi.receiving.receiveNotification()
93+
resultReceive = greenApi.receiving.receiveNotification()
9494
```
9595

9696
## Список примеров

examples/createGroupAndSendMessage.py

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

3-
from whatsapp_api_client_python import greenAPI as greenAPI
3+
from whatsapp_api_client_python import API as API
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-
restApi = greenAPI.RestApi(ID_INSTANCE, API_TOKEN_INSTANCE)
9+
greenApi = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
1010

1111
def main():
1212
chatIds = [
1313
"79001234567@c.us"
1414
]
15-
resultCreate = restApi.groups.createGroup('GroupName',
15+
resultCreate = greenApi.groups.createGroup('GroupName',
1616
chatIds)
1717

1818
if resultCreate.code == 200:
1919
print(resultCreate.data)
20-
resultSend = restApi.sending.sendMessage(resultCreate.data['chatId'],
20+
resultSend = greenApi.sending.sendMessage(resultCreate.data['chatId'],
2121
'Message text')
2222
if resultSend.code == 200:
2323
print(resultSend.data)

examples/receiveNotification.py

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

66

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

10-
restApi = greenAPI.RestApi(ID_INSTANCE, API_TOKEN_INSTANCE)
10+
greenApi = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
1111

1212
def main():
13-
restApi.webhooks.startReceivingNotifications(onEvent)
13+
greenApi.webhooks.startReceivingNotifications(onEvent)
1414

1515
def onEvent(typeWebhook, body):
1616
if typeWebhook == 'incomingMessageReceived':

examples/sendPictureByLink.py

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

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

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

8-
restApi = greenAPI.RestApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenApi = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
11-
result = restApi.sending.sendFileByUrl('79001234567@c.us',
11+
result = greenApi.sending.sendFileByUrl('79001234567@c.us',
1212
'https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
1313
'googlelogo_color_272x92dp.png', 'Google logo')
1414
print(result.data)

examples/sendPictureByUpload.py

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

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

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

8-
restApi = greenAPI.RestApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenApi = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
11-
result = restApi.sending.sendFileByUpload('79001234567@c.us',
11+
result = greenApi.sending.sendFileByUpload('79001234567@c.us',
1212
'C:\Games\PicFromDisk.png',
1313
'PicFromDisk.png', 'Picture from disk')
1414
print(result.data)

examples/sendTextMessage.py

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

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

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

8-
restApi = greenAPI.RestApi(ID_INSTANCE, API_TOKEN_INSTANCE)
8+
greenApi = API.GreenApi(ID_INSTANCE, API_TOKEN_INSTANCE)
99

1010
def main():
11-
result = restApi.sending.sendMessage('79001234567@c.us', 'Message text')
11+
result = greenApi.sending.sendMessage('79001234567@c.us', 'Message text')
1212
print(result.data)
1313

1414
if __name__ == "__main__":

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="whatsapp-api-client-python",
8-
version="0.0.21",
8+
version="0.0.22",
99
install_requires=['requests'],
1010
author="Ivan Sadovy",
1111
author_email="sadiv@bk.ru",

tests/test_main.py

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

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

55

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

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

1111
class TestClass:
1212
def test_getSettings(self):
13-
result = RestApi.account.getSettings()
13+
result = greenApi.account.getSettings()
1414
if result.code != 200:
1515
print(result.error)
16-
assert isinstance(result, greenAPI.Response) and result.code == 200
16+
assert isinstance(result, API.Response) and result.code == 200
1717

1818
def test_getStateInstance(self):
19-
result = RestApi.account.getStateInstance()
19+
result = greenApi.account.getStateInstance()
2020
if result.code != 200:
2121
print(result.error)
22-
assert isinstance(result, greenAPI.Response) and result.code == 200
22+
assert isinstance(result, API.Response) and result.code == 200
2323

2424
def main():
2525
TestClass.test_getSettings(TestClass)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from whatsapp_api_client_python.tools.webhooks import Webhooks
1616

1717

18-
class RestApi:
18+
class GreenApi:
1919
'REST API class'
2020

2121
host: str

0 commit comments

Comments
 (0)