api: Add example for managing alert words.
This example makes use of get_alert_words, add_alert_words and
remove_alert_words, three methods that interact with the
/users/me/alert_words REST API endpoint.
MODIFY
zulip/zulip/__init__.py
zulip/zulip/__init__.py
@@ -897,6 +897,9 @@ class Client(object):
def get_alert_words(self):
# type: () -> Dict[str, Any]
+ '''
+ See examples/alert-words for example usage.
+ '''
return self.call_endpoint(
url='users/me/alert_words',
method='GET'
@@ -904,6 +907,9 @@ class Client(object):
def add_alert_words(self, alert_words):
# type: (List[str]) -> Dict[str, Any]
+ '''
+ See examples/alert-words for example usage.
+ '''
return self.call_endpoint(
url='users/me/alert_words',
method='POST',
@@ -914,6 +920,9 @@ class Client(object):
def remove_alert_words(self, alert_words):
# type: (List[str]) -> Dict[str, Any]
+ '''
+ See examples/alert-words for example usage.
+ '''
return self.call_endpoint(
url='users/me/alert_words',
method='DELETE',

ADD
zulip/zulip/examples/alert-words
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import argparse
+
+import zulip
+
+usage = """alert-words (get | add | remove) [words] [options]
+
+
+Example: alert-words get
+Example: alert-words add foo bar
+Example: alert-words remove banana
+"""
+
+
+parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
+parser.add_argument('operation', choices=['get', 'add', 'remove'], type=str)
+parser.add_argument('words', type=str, nargs='*')
+options = parser.parse_args()
+
+client = zulip.init_from_options(options)
+
+if options.operation == 'get':
+ result = client.get_alert_words()
+elif options.operation == 'add':
+ result = client.add_alert_words(options.words)
+elif options.operation == 'remove':
+ result = client.remove_alert_words(options.words)
+
+print(result)

api: Add example for managing alert words.

This example makes use of get_alert_words, add_alert_words and
remove_alert_words, three methods that interact with the
/users/me/alert_words REST API endpoint.