Skip to content

Commit ae1f14b

Browse files
authored
Merge pull request #42 from green-api/dev
Added GetAuthorizationCode method
2 parents ce2db51 + 2eca54d commit ae1f14b

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

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 an 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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,20 @@ def setProfilePicture(self, path: str) -> Response:
136136
"setProfilePicture/{{apiTokenInstance}}"
137137
), files=files
138138
)
139+
140+
def getAuthorizationCode(self, phoneNumber: int) -> Response:
141+
"""
142+
The method is designed to authorize an instance by phone number.
143+
144+
https://green-api.com/en/docs/api/account/GetAuthorizationCode/
145+
"""
146+
147+
request_body = locals()
148+
request_body.pop("self")
149+
150+
return self.api.request(
151+
"POST", (
152+
"{{host}}/waInstance{{idInstance}}/"
153+
"getAuthorizationCode/{{apiTokenInstance}}"
154+
), request_body
155+
)

0 commit comments

Comments
 (0)