Skip to content

Commit ab6460a

Browse files
authored
Merge pull request #52 from green-api/SW-3437
SW-3437 Status methods
2 parents a8134b1 + 5821c4c commit ab6460a

File tree

12 files changed

+311
-10
lines changed

12 files changed

+311
-10
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ response = greenAPI.sending.sendPoll(
169169
print(response.data)
170170
```
171171

172+
### Sending a text status
173+
174+
Link to example: [sendTextStatus.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/statusesMethods/sendTextStatus.py).
175+
176+
```
177+
response = greenAPI.statuses.sendTextStatus(
178+
"I sent this status using Green Api Python SDK!",
179+
"#54c774",
180+
"NORICAN_REGULAR"
181+
)
182+
183+
print(response.data)
184+
```
185+
172186
## Examples list
173187

174188
| Description | Module |
@@ -179,6 +193,7 @@ print(response.data)
179193
| Example of a group creation and sending a message to the group | [createGroupAndSendMessage.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/createGroupAndSendMessage.py) |
180194
| Example of incoming webhooks receiving | [receiveNotification.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/receiveNotification.py) |
181195
| Example of sending a polling message | [sendPoll.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sendPoll.py) |
196+
| Example of sending a text status | [sendTextStatus.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/sendTextStatus.py) |
182197

183198
## The full list of the library methods
184199

@@ -204,6 +219,13 @@ print(response.data)
204219
| `groups.removeAdmin` | The method deprives the participant of group chat administration rights | [RemoveAdmin](https://green-api.com/en/docs/api/groups/RemoveAdmin/) |
205220
| `groups.setGroupPicture` | The method sets the avatar of the group | [SetGroupPicture](https://green-api.com/en/docs/api/groups/SetGroupPicture/) |
206221
| `groups.leaveGroup` | The method logs the user of the current account out of the group chat | [LeaveGroup](https://green-api.com/en/docs/api/groups/LeaveGroup/) |
222+
| `statuses.sendTextStatus` | The method is aimed for sending a text status | [SendTextStatus](https://green-api.com/en/docs/api/statuses/SendTextStatus/) |
223+
| `statuses.sendVoiceStatus` | The method is aimed for sending a voice status | [SendVoiceStatus](https://green-api.com/en/docs/api/statuses/SendVoiceStatus/) |
224+
| `statuses.sendMediaStatus` | The method is aimed for sending a pictures or video status | [SendMediaStatus](https://green-api.com/en/docs/api/statuses/SendMediaStatus/) |
225+
| `statuses.deleteStatus` | The method is aimed for deleting a certain status | [DeleteStatus](https://green-api.com/en/docs/api/statuses/DeleteStatus/) |
226+
| `statuses.getStatusStatistic` | The method returns an array of recipients marked sent/delivered/read for a given status | [GetStatusStatistic](https://green-api.com/en/docs/api/statuses/GetStatusStatistic/) |
227+
| `statuses.getOutgoingStatuses` | The method returns the outgoing statuses of the account | [GetOutgoingStatuses](https://green-api.com/en/docs/api/statuses/GetOutgoingStatuses/) |
228+
| `statuses.getIncomingStatuses` | The method returns the incoming statuses of the account | [GetIncomingStatuses](https://green-api.com/en/docs/api/statuses/GetIncomingStatuses/) |
207229
| `journals.getChatHistory` | The method returns the chat message history | [GetChatHistory](https://green-api.com/en/docs/api/journals/GetChatHistory/) |
208230
| `journals.getMessage` | The method returns a chat message | [GetMessage](https://green-api.com/en/docs/api/journals/GetMessage/) |
209231
| `journals.lastIncomingMessages` | The method returns the most recent incoming messages of the account | [LastIncomingMessages](https://green-api.com/en/docs/api/journals/LastIncomingMessages/) |

docs/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ response = greenAPI.sending.sendPoll(
153153
print(response.data)
154154
```
155155

156+
## Отправка текстового статуса
157+
158+
Ссылка на пример: [sendPoll.py](https://github.com/green-api/whatsapp-api-client-python/blob/master/examples/statusesMethods/sendTextStatus.py).
159+
160+
```
161+
response = greenAPI.statuses.sendTextStatus(
162+
"I sent this status using Green Api Python SDK!",
163+
"#54c774",
164+
"NORICAN_REGULAR"
165+
)
166+
167+
print(response.data)
168+
```
169+
156170
## Список примеров
157171

158172
| Описание | Модуль |

examples/partherMethods/DeleteInstanceAccount.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ def main():
99
response = greenAPI.partner.deleteInstanceAccount(1103123456)
1010
print(response.data)
1111

12-
1312
if __name__ == '__main__':
1413
main()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from whatsapp_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
response = greenAPI.statuses.deleteStatus('BAE54F518532FCB1')
10+
print(response.data)
11+
12+
if __name__ == '__main__':
13+
main()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from whatsapp_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
response = greenAPI.statuses.getIncomingStatuses(1400) # minutes argument is Optional
10+
print(response.data)
11+
12+
response = greenAPI.statuses.getOutgoingStatuses(1400) # minutes argument is Optional
13+
print(response.data)
14+
15+
response = greenAPI.statuses.getStatusStatistic('BAE54F518532FCB1')
16+
print(response.data)
17+
18+
if __name__ == '__main__':
19+
main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from whatsapp_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
response = greenAPI.statuses.sendMediaStatus(
10+
"https://example.com/file.mp4",
11+
"test.mp4"
12+
"#54c774")
13+
14+
print(response.data)
15+
16+
if __name__ == '__main__':
17+
main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from whatsapp_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
response = greenAPI.statuses.sendTextStatus(
10+
"I sent this status using Green Api Python SDK!",
11+
"#54c774",
12+
"NORICAN_REGULAR")
13+
14+
print(response.data)
15+
16+
if __name__ == '__main__':
17+
main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from whatsapp_api_client_python import API
2+
3+
greenAPI = API.GreenAPI(
4+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
5+
)
6+
7+
8+
def main():
9+
response = greenAPI.statuses.sendVoiceStatus(
10+
"https://example.com/file.mp3",
11+
"test.mp3"
12+
"#54c774")
13+
14+
print(response.data)
15+
16+
if __name__ == '__main__':
17+
main()

tests/test_methods.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_methods(self, mock_request):
2121
*self.account_methods,
2222
*self.device_methods,
2323
*self.group_methods,
24+
*self.status_methods,
2425
*self.log_methods,
2526
*self.queue_methods,
2627
*self.read_mark_methods,
@@ -68,6 +69,18 @@ def group_methods(self) -> typing.List[Response]:
6869
api.groups.leaveGroup("")
6970
]
7071

72+
@property
73+
def status_methods(self) -> typing.List[Response]:
74+
return [
75+
api.statuses.sendTextStatus(""),
76+
api.statuses.sendVoiceStatus("", ""),
77+
api.statuses.sendMediaStatus("", ""),
78+
api.statuses.deleteStatus(""),
79+
api.statuses.getStatusStatistic(""),
80+
api.statuses.getIncomingStatuses(),
81+
api.statuses.getOutgoingStatuses()
82+
]
83+
7184
@property
7285
def log_methods(self) -> typing.List[Response]:
7386
return [

whatsapp_api_client_python/API.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
sending,
1818
serviceMethods,
1919
webhooks,
20-
partner
20+
partner,
21+
statuses
2122
)
2223

2324

@@ -63,6 +64,7 @@ def __init__(
6364
self.sending = sending.Sending(self)
6465
self.serviceMethods = serviceMethods.ServiceMethods(self)
6566
self.webhooks = webhooks.Webhooks(self)
67+
self.statuses = statuses.Statuses(self)
6668

6769
self.logger = logging.getLogger("whatsapp-api-client-python")
6870
self.__prepare_logger()
@@ -176,7 +178,6 @@ def __prepare_session(self) -> None:
176178
self.session.mount("http://", HTTPAdapter(max_retries=retry))
177179
self.session.mount("https://", HTTPAdapter(max_retries=retry))
178180

179-
180181
class GreenAPI(GreenApi):
181182
pass
182183

0 commit comments

Comments
 (0)