Skip to content

Commit 45dcf96

Browse files
committed
Added method getAuthorizationCode
1 parent 9fc973c commit 45dcf96

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ print(response.data)
181181
| `account.logout` | The method is designed to unlogin the account | [Logout](https://green-api.com/en/docs/api/account/Logout/) |
182182
| `account.qr` | The method is designed to get a QR code | [QR](https://green-api.com/en/docs/api/account/QR/) |
183183
| `account.setProfilePicture` | The method is designed to set the avatar of the account | [SetProfilePicture](https://green-api.com/en/docs/api/account/SetProfilePicture/) |
184+
| `account.getAuthorizationCode` | The method is designed to authorize instance by phone number | [GetAuthorizationCode](https://green-api.com/en/docs/api/account/GetAuthorizationCode/) |
184185
| `device.getDeviceInfo` | The method is designed to get information about the device (phone) on which the WhatsApp Business application is running | [GetDeviceInfo](https://green-api.com/en/docs/api/phone/GetDeviceInfo/) |
185186
| `groups.createGroup` | The method is designed to create a group chat | [CreateGroup](https://green-api.com/en/docs/api/groups/CreateGroup/) |
186187
| `groups.updateGroupName` | The method changes the name of the group chat | [UpdateGroupName](https://green-api.com/en/docs/api/groups/UpdateGroupName/) |

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ print(response.data)
165165
| `account.logout` | Метод предназначен для разлогинивания аккаунта | [Logout](https://green-api.com/docs/api/account/Logout/) |
166166
| `account.qr` | Метод предназначен для получения QR-кода | [QR](https://green-api.com/docs/api/account/QR/) |
167167
| `account.setProfilePicture` | Метод предназначен для установки аватара аккаунта | [SetProfilePicture](https://green-api.com/docs/api/account/SetProfilePicture/) |
168+
| `account.getAuthorizationCode` | Метод предназначен для для авторизации инстанса по номеру телефона | [GetAuthorizationCode](https://green-api.com/docs/api/account/GetAuthorizationCode/) |
168169
| `device.getDeviceInfo` | Метод предназначен для получения информации об устройстве (телефоне), на котором запущено приложение WhatsApp Business | [GetDeviceInfo](https://green-api.com/docs/api/phone/GetDeviceInfo/) |
169170
| `groups.createGroup` | Метод предназначен для создания группового чата | [CreateGroup](https://green-api.com/docs/api/groups/CreateGroup/) |
170171
| `groups.updateGroupName` | Метод изменяет наименование группового чата | [UpdateGroupName](https://green-api.com/docs/api/groups/UpdateGroupName/) |

tests/test_methods.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def account_methods(self) -> typing.List[Response]:
4646
api.account.reboot(),
4747
api.account.logout(),
4848
api.account.qr(),
49-
api.account.setProfilePicture(path)
49+
api.account.setProfilePicture(path),
50+
api.account.getAuthorizationCode(0)
5051
]
5152

5253
@property

whatsapp_api_client_python/tools/account.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,19 @@ def setProfilePicture(self, path: str) -> Response:
106106
"setProfilePicture/{{apiTokenInstance}}"
107107
), files=files
108108
)
109+
110+
def getAuthorizationCode(self, phoneNumber: int) -> Response:
111+
"""
112+
The method is designed to authorize instance by phone
113+
number.
114+
"""
115+
116+
request_body = locals()
117+
request_body.pop("self")
118+
119+
return self.api.request(
120+
"POST", (
121+
"{{host}}/waInstance{{idInstance}}/"
122+
"GetAuthorizationCode/{{apiTokenInstance}}"
123+
), request_body
124+
)

0 commit comments

Comments
 (0)