mirror of https://github.com/zulip/zulip.git
js_examples: Migrate and test update_message example.
This commit is contained in:
parent
8a00b1f1aa
commit
3b8ee2a30f
|
@ -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}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue