Skip to content

Commit fac02d7

Browse files
SDK-43: Требуется добавить метод QR в SDK MAX
2 parents 267ed70 + 144e663 commit fac02d7

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ onEvent - ваша функция, которая должен содержат
151151
| `account.getStatusInstance` | Метод предназначен для получения состояния сокета соединения инстанса аккаунта с MAX | [GetStatusInstance](https://green-api.com/v3/docs/api/account/GetStatusInstance/) |
152152
| `account.reboot` | Метод предназначен для перезапуска аккаунта | [Reboot](https://green-api.com/v3/docs/api/account/Reboot/) |
153153
| `account.logout` | Метод предназначен для разлогинивания аккаунта | [Logout](https://green-api.com/v3/docs/api/account/Logout/) |
154+
| `account.qr` | Метод предназначен для получения QR кода для авторизации | [QR](https://green-api.com/v3/docs/api/account/qr/) |
154155
| `account.setProfilePicture` | Метод предназначен для установки аватара аккаунта | [SetProfilePicture](https://green-api.com/v3/docs/api/account/SetProfilePicture/) |
155-
| `account.startAuthorization` | Метод предназначен для запроса кода для авторизации | [StartAuthorization](https://green-api.com/v3/docs/api/account/StartAuthorization/) |
156-
| `account.sendAuthorizationCode` | Метод предназначен для авторизации инстанса по номеру телефона | [SendAuthorizationCode](https://green-api.com/v3/docs/api/account/SendAuthorizationCode/) |
157156
| `groups.createGroup` | Метод предназначен для создания группового чата | [CreateGroup](https://green-api.com/v3/docs/api/groups/CreateGroup/) |
158157
| `groups.updateGroupName` | Метод изменяет наименование группового чата | [UpdateGroupName](https://green-api.com/v3/docs/api/groups/UpdateGroupName/) |
159158
| `groups.getGroupData` | Метод получает данные группового чата | [GetGroupData](https://green-api.com/v3/docs/api/groups/GetGroupData/) |
@@ -201,4 +200,4 @@ onEvent - ваша функция, которая должен содержат
201200
Лицензировано на условиях [
202201
Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)
203202
](https://creativecommons.org/licenses/by-nd/4.0/).
204-
[LICENSE](../LICENSE).
203+
[LICENSE](../LICENSE).

examples/qr.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from max_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"3100000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
10+
response = greenAPI.account.qr()
11+
print(response.data)
12+
13+
14+
if __name__ == '__main__':
15+
main()

max_api_client_python/tools/account.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ def logout(self) -> Response:
9494
)
9595
)
9696

97+
def qr(self) -> Response:
98+
"""
99+
The method is aimed for getting QR code.
100+
101+
https://green-api.com/en/docs/api/account/QR/
102+
"""
103+
104+
return self.api.request(
105+
"GET", (
106+
"{{host}}/waInstance{{idInstance}}/qr/{{apiTokenInstance}}"
107+
)
108+
)
109+
97110
def setProfilePicture(self, path: str) -> Response:
98111
"""
99112
The method is aimed for setting an account picture.
@@ -113,6 +126,8 @@ def setProfilePicture(self, path: str) -> Response:
113126

114127
def startAuthorization(self, phoneNumber: int) -> Response:
115128
"""
129+
The method is deprecated. Please use QR.
130+
116131
The method is designed to receive SMS for instance authorization.
117132
118133
https://green-api.com/v3/docs/api/account/StartAuthorization/
@@ -130,6 +145,8 @@ def startAuthorization(self, phoneNumber: int) -> Response:
130145

131146
def sendAuthorizationCode(self, code: str) -> Response:
132147
"""
148+
The method is deprecated. Please use QR.
149+
133150
The method is designed to authorize an instance by SMS.
134151
135152
https://green-api.com/v3/docs/api/account/SendAuthorizationCode/

setup.py

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

66
setup(
77
name="max-api-client-python",
8-
version="1.0.0",
8+
version="1.0.1",
99
description=(
1010
"This library helps you easily create"
1111
" a Python application with MAX API."

tests/test_methods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def account_methods(self) -> typing.List[Response]:
4343
api.account.getStateInstance(),
4444
api.account.reboot(),
4545
api.account.logout(),
46+
api.account.qr(),
4647
api.account.setProfilePicture(path)
4748
]
4849

0 commit comments

Comments
 (0)