js_examples: Migrate and test update_message example.

This commit is contained in:
Kartik Srivastava 2020-06-22 04:01:56 +05:30 committed by Tim Abbott
parent 8a00b1f1aa
commit 3b8ee2a30f
2 changed files with 23 additions and 17 deletions

View File

@ -12,24 +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) => {
// Update a message
const params = {
message_id: 131,
content: 'New Content',
}
client.messages.update(params).then(console.log);
});
```
{generate_code_example(javascript)|/messages/{message_id}:patch|example}
{tab|curl}

View File

@ -51,6 +51,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.add_subscriptions);
await generate_validation_data(client, examples.remove_subscriptions);
await generate_validation_data(client, examples.update_message_flags);
await generate_validation_data(client, examples.update_message);
console.log(JSON.stringify(response_data));
return;
@ -302,4 +303,25 @@ add_example('update_message_flags', '/messages/flags:post', 200, async (client)
return [result_1, result_2];
});
add_example('update_message', '/messages/{message_id}:patch', 200, async (client) => {
const request = {
to: 'Denmark',
type: 'stream',
topic: 'Castle',
content: 'I come not, friends, to steal away your hearts.',
};
const result = await client.messages.send(request);
const message_id = result.id;
// {code_example|start}
// Update a message with the given "message_id"
const params = {
message_id: message_id,
content: 'New Content',
};
return await client.messages.update(params);
// {code_example|end}
});
main();