Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js_examples: Migrate and test set_typing_status example.

Kartik Srivastavacf6e1de0de33
diff --git a/templates/zerver/api/set-typing-status.md b/templates/zerver/api/set-typing-status.md
index 6d9e2c08e1c..b4278e3facf 100644
--- a/templates/zerver/api/set-typing-status.md
+++ b/templates/zerver/api/set-typing-status.md
@@ -12,27 +12,8 @@
{tab|js}
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
-```js
-const zulip = require('zulip-js');
-
-// Pass the path to your zuliprc file here.
-const config = {
- zuliprc: 'zuliprc',
-};
-
-const user_id1 = 9;
-const user_id2 = 10;
-
-const typingParams = {
- op: 'start',
- to: [user_id1, user_id2],
-};
-
-zulip(config).then((client) => {
- // The user has started to type in the group PM with Iago and Polonius
- return client.typing.send(typingParams);
-}).then(console.log);
-```
+
+{generate_code_example(javascript)|/typing:post|example}
{tab|curl}
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index 964dc3559dd..15ffc2c2814 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -47,6 +47,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_users);
await generate_validation_data(client, examples.register_queue);
await generate_validation_data(client, examples.render_message);
+ await generate_validation_data(client, examples.set_typing_status);
console.log(JSON.stringify(response_data));
return;
@@ -212,4 +213,19 @@ add_example('render_message', '/messages/render:post', 200, async (client) => {
// {code_example|end}
});
+add_example('set_typing_status', '/typing:post', 200, async (client) => {
+ // {code_example|start}
+ const user_id1 = 9;
+ const user_id2 = 10;
+
+ const typingParams = {
+ op: 'start',
+ to: [user_id1, user_id2],
+ };
+
+ // The user has started to type in the group PM with Iago and Polonius
+ return await client.typing.send(typingParams);
+ // {code_example|end}
+});
+
main();