Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js_examples: Migrate and test remove_subscriptions example.
Kartik Srivastavacc4086e98aa6
diff --git a/templates/zerver/api/unsubscribe.md b/templates/zerver/api/unsubscribe.mdindex d19d1a2fcc9..dcb3180b616 100644--- a/templates/zerver/api/unsubscribe.md+++ b/templates/zerver/api/unsubscribe.md@@ -12,29 +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',-};--zulip(config).then((client) => {- // Unsubscribe from the stream "Denmark"- const meParams = {- subscriptions: JSON.stringify(['Denmark']),- };- client.users.me.subscriptions.remove(meParams).then(console.log);-- // Unsubscribe Zoe from the stream "Denmark"- const zoeParams = {- subscriptions: JSON.stringify(['Denmark']),- principals: JSON.stringify(['[email protected]']),- };- client.users.me.subscriptions.remove(zoeParams).then(console.log);-});-```++{generate_code_example(javascript)|/users/me/subscriptions:delete|example}{tab|curl}diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.jsindex 930c6cfb14a..904668e929c 100644--- a/zerver/openapi/javascript_examples.js+++ b/zerver/openapi/javascript_examples.js@@ -49,6 +49,7 @@ const ExamplesHandler = function () {await generate_validation_data(client, examples.render_message);await generate_validation_data(client, examples.set_typing_status);await generate_validation_data(client, examples.add_subscriptions);+ await generate_validation_data(client, examples.remove_subscriptions);console.log(JSON.stringify(response_data));return;@@ -257,4 +258,25 @@ add_example('add_subscriptions', '/users/me/subscriptions:post', 200, async (clireturn [result_1, result_2];});+add_example('remove_subscriptions', '/users/me/subscriptions:delete', 200, async (client) => {+ // {code_example|start}+ // Unsubscribe from the stream "Denmark"+ const meParams = {+ subscriptions: JSON.stringify(['Denmark']),+ };+ const result_1 = await client.users.me.subscriptions.remove(meParams);+ // {code_example|end}++ // {code_example|start}+ const user_id = 7;+ // Unsubscribe Zoe from the stream "Denmark"+ const zoeParams = {+ subscriptions: JSON.stringify(['Denmark']),+ principals: JSON.stringify([user_id]),+ };+ const result_2 = await client.users.me.subscriptions.remove(zoeParams);+ // {code_example|end}+ return [result_1, result_2];+});+main();