Skip to content

Commit 0cde800

Browse files
committed
add RCS support, revoke RCS message, mark WhatsApp as read
1 parent 1bff284 commit 0cde800

File tree

7 files changed

+48
-10
lines changed

7 files changed

+48
-10
lines changed

messages/README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This message can now be sent with
2626
vonage_client.messages.send(message)
2727
```
2828

29-
All possible message types from every message channel have their own message model. They are named following this rule: {Channel}{MessageType}, e.g. `Sms`, `MmsImage`, `MessengerAudio`, `WhatsappSticker`, `ViberVideo`, etc.
29+
All possible message types from every message channel have their own message model. They are named following this rule: {Channel}{MessageType}, e.g. `Sms`, `MmsImage`, `RcsFile`, `MessengerAudio`, `WhatsappSticker`, `ViberVideo`, etc.
3030

3131
The different message models are listed at the bottom of the page.
3232

@@ -64,14 +64,47 @@ message = Sms(
6464
vonage_client.messages.send(message)
6565
```
6666

67+
### Mark a WhatsApp Message as Read
68+
69+
Note: to use this method, update the `api_host` attribute of the `vonage_http_client.HttpClientOptions` object to the API endpoint corresponding to the region where the WhatsApp number is hosted.
70+
71+
For example, to use the EU API endpoint, set the `api_host` attribute to 'api-eu.vonage.com'.
72+
73+
```python
74+
from vonage import Vonage, Auth, HttpClientOptions
75+
76+
auth = Auth(application_id='MY-APP-ID', private_key='MY-PRIVATE-KEY')
77+
options = HttpClientOptions(api_host='api-eu.vonage.com')
78+
79+
vonage_client = Vonage(auth, options)
80+
vonage_client.messages.mark_whatsapp_message_read('MESSAGE_UUID')
81+
```
82+
83+
### Revoke an RCS Message
84+
85+
Note: as above, to use this method you need to update the `api_host` attribute of the `vonage_http_client.HttpClientOptions` object to the API endpoint corresponding to the region where the WhatsApp number is hosted.
86+
87+
For example, to use the EU API endpoint, set the `api_host` attribute to 'api-eu.vonage.com'.
88+
89+
```python
90+
from vonage import Vonage, Auth, HttpClientOptions
91+
92+
auth = Auth(application_id='MY-APP-ID', private_key='MY-PRIVATE-KEY')
93+
options = HttpClientOptions(api_host='api-eu.vonage.com')
94+
95+
vonage_client = Vonage(auth, options)
96+
vonage_client.messages.revoke_rcs_message('MESSAGE_UUID')
97+
```
98+
6799
## Message Models
68100

69101
To send a message, instantiate a message model of the correct type as described above. This is a list of message models that can be used:
70102

71103
```
72104
Sms
73105
MmsImage, MmsVcard, MmsAudio, MmsVideo
106+
RcsText, RcsImage, RcsVideo, RcsFile, RcsCustom
74107
WhatsappText, WhatsappImage, WhatsappAudio, WhatsappVideo, WhatsappFile, WhatsappTemplate, WhatsappSticker, WhatsappCustom
75108
MessengerText, MessengerImage, MessengerAudio, MessengerVideo, MessengerFile
76109
ViberText, ViberImage, ViberVideo, ViberFile
77-
```
110+
```

messages/pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = 'vonage-messages'
3-
version = '1.1.1'
3+
version = '1.2.0'
44
description = 'Vonage messages package'
55
readme = "README.md"
66
authors = [{ name = "Vonage", email = "devrel@vonage.com" }]
77
requires-python = ">=3.8"
88
dependencies = [
9-
"vonage-http-client>=1.3.1",
9+
"vonage-http-client>=1.4.0",
1010
"vonage-utils>=1.1.1",
1111
"pydantic>=2.7.1",
1212
]

messages/src/vonage_messages/messages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def mark_whatsapp_message_read(self, message_uuid: str) -> None:
5454
corresponding to the region where the WhatsApp number is hosted.
5555
5656
For example, to use the EU API endpoint, set the `api_host`
57-
attribute to 'https://api-eu.vonage.com'.
57+
attribute to 'api-eu.vonage.com'.
5858
5959
Args:
6060
message_uuid (str): The unique identifier of the WhatsApp message to mark as read.
@@ -74,7 +74,7 @@ def revoke_rcs_message(self, message_uuid: str) -> None:
7474
corresponding to the region where the RCS number is hosted.
7575
7676
For example, to use the EU API endpoint, set the `api_host`
77-
attribute to 'https://api-eu.vonage.com'.
77+
attribute to 'api-eu.vonage.com'.
7878
7979
Args:
8080
message_uuid (str): The unique identifier of the RCS message to revoke.

messages/tests/test_messages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def test_http_client_property():
8787
def test_mark_whatsapp_message_read():
8888
responses.add(
8989
responses.PATCH,
90-
'https://api-eu.vonage.com/v1/messages/1234567890',
90+
'https://api-eu.vonage.com/v1/messages/asdf',
9191
)
9292
messages = Messages(
9393
HttpClient(get_mock_jwt_auth(), HttpClientOptions(api_host='api-eu.vonage.com'))
9494
)
9595
messages.http_client.http_client_options.api_host = 'api-eu.vonage.com'
96-
messages.mark_whatsapp_message_read('1234567890')
96+
messages.mark_whatsapp_message_read('asdf')
9797

9898

9999
@responses.activate

vonage/CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 3.99.2a0
2+
- Add support for the [RCS messaging channel](https://developer.vonage.com/en/messages/concepts/rcs) of the Vonage Messages API
3+
- Add method to revoke an RCS message
4+
- Add method to mark a WhatsApp message as read
5+
16
# 3.99.0a12
27
- Add support for the [Vonage Account API](https://developer.vonage.com/en/account/overview).
38
- Update package metadata for the `vonage-application` package.

vonage/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies = [
1010
"vonage-http-client>=1.4.0",
1111
"vonage-account>=1.0.0",
1212
"vonage-application>=1.0.0",
13-
"vonage-messages>=1.1.1",
13+
"vonage-messages>=1.2.0",
1414
"vonage-number-insight>=1.0.0",
1515
"vonage-sms>=1.1.1",
1616
"vonage-users>=1.1.2",

vonage/src/vonage/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.99.0a12'
1+
__version__ = '3.99.2a0'

0 commit comments

Comments
 (0)