Skip to content

Commit ff75333

Browse files
committed
Update docs for broadcasts and messages API endpoints
1 parent bb8dc00 commit ff75333

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

temba/api/v2/views.py

+40-8
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def get_context_data(self, **kwargs):
131131
LabelsEndpoint.get_write_explorer(),
132132
LabelsEndpoint.get_delete_explorer(),
133133
MessagesEndpoint.get_read_explorer(),
134+
MessagesEndpoint.get_write_explorer(),
134135
MessageActionsEndpoint.get_write_explorer(),
135136
ResthooksEndpoint.get_read_explorer(),
136137
ResthookEventsEndpoint.get_read_explorer(),
@@ -483,8 +484,14 @@ class BroadcastsEndpoint(ListAPIMixin, WriteAPIMixin, BaseEndpoint):
483484
{
484485
"urns": ["tel:+250788123123", "tel:+250788123124"],
485486
"contacts": ["09d23a05-47fe-11e4-bfe9-b8f6b119e9ab"],
486-
"text": {"eng": "Hello @contact.name!", "spa": "Hola @contact.name!"},
487-
"quick_replies": {"eng": [{"text": "Hey"}, {"text": "Hello!"}]}
487+
"text": {
488+
"eng": "Hello @contact.name! Burger or pizza?",
489+
"spa": "Hola @contact.name! Hamburguesa o pizza?"
490+
},
491+
"quick_replies": {
492+
"eng": [{"text": "Burger", "extra": "With cheese"}, {"text": "Pizza"}],
493+
"spa": [{"text": "Hamburguesa", "extra": "Con queso"}, {"text": "Pizza"}]
494+
},
488495
"base_language": "eng"
489496
}
490497
@@ -495,9 +502,15 @@ class BroadcastsEndpoint(ListAPIMixin, WriteAPIMixin, BaseEndpoint):
495502
"urns": ["tel:+250788123123", "tel:+250788123124"],
496503
"contacts": [{"uuid": "09d23a05-47fe-11e4-bfe9-b8f6b119e9ab", "name": "Joe"}]
497504
"groups": [],
498-
"text": {"eng": "Hello @contact.name!", "spa": "Hola @contact.name!"},
505+
"text": {
506+
"eng": "Hello @contact.name! Burger or pizza?",
507+
"spa": "Hola @contact.name! Hamburguesa o pizza?"
508+
},
499509
"attachments": {"eng": [], "spa": []},
500-
"quick_replies": {"eng": [{"text": "Hey"}, {"text": "Hello!"}], "spa": []},
510+
"quick_replies": {
511+
"eng": [{"text": "Burger", "extra": "With cheese"}, {"text": "Pizza"}],
512+
"spa": [{"text": "Hamburguesa", "extra": "Con queso"}, {"text": "Pizza"}]
513+
},
501514
"base_language": "eng",
502515
"created_on": "2013-03-02T17:28:12.123456Z"
503516
}
@@ -2309,9 +2322,9 @@ class MessagesEndpoint(ListAPIMixin, WriteAPIMixin, BaseEndpoint):
23092322
POST /api/v2/messages.json
23102323
{
23112324
"contact": "d33e9ad5-5c35-414c-abd4-e7451c69ff1d",
2312-
"text": "Hi Bob",
2325+
"text": "Burger or pizza?",
23132326
"attachments": [],
2314-
"quick_repies": [{"text": "Hey"}, {"text": "Hi"}]
2327+
"quick_repies": [{"text": "Burger", "extra": "With cheese"}, {"text": "Pizza"}]
23152328
23162329
}
23172330
@@ -2327,9 +2340,9 @@ class MessagesEndpoint(ListAPIMixin, WriteAPIMixin, BaseEndpoint):
23272340
"type": "text",
23282341
"status": "queued",
23292342
"visibility": "visible",
2330-
"text": "Hi Bob",
2343+
"text": "Burger or pizza?",
23312344
"attachments": [],
2332-
"quick_replies": [{"text": "Hey"}, {"text": "Hi"}],
2345+
"quick_replies": [{"text": "Burger", "extra": "With cheese"}, {"text": "Pizza"}],
23332346
"labels": [],
23342347
"flow": null,
23352348
"created_on": "2023-01-06T15:33:00.813162Z",
@@ -2471,6 +2484,25 @@ def get_read_explorer(cls):
24712484
"example": {"query": "folder=inbox&after=2014-01-01T00:00:00.000"},
24722485
}
24732486

2487+
@classmethod
2488+
def get_write_explorer(cls):
2489+
return {
2490+
"method": "POST",
2491+
"title": "Send Messages",
2492+
"url": reverse("api.v2.messages"),
2493+
"slug": "message-write",
2494+
"fields": [
2495+
{"name": "contact", "required": True, "help": "The UUID of the contact"},
2496+
{"name": "text", "required": False, "help": "The text of the message (string)"},
2497+
{"name": "attachments", "required": False, "help": "The attachments on the message (array of strings)"},
2498+
{
2499+
"name": "quick_replies",
2500+
"required": False,
2501+
"help": "The quick replies on the message (array of objects)",
2502+
},
2503+
],
2504+
}
2505+
24742506

24752507
class MessageActionsEndpoint(BulkWriteAPIMixin, BaseEndpoint):
24762508
"""

0 commit comments

Comments
 (0)