From f6646f9cba8cb84822764c4f0cb462e292326b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Mon, 9 Jul 2018 16:21:24 +0530 Subject: [PATCH] api: Implement PATCH /users/me/subscriptions/muted_topics. --- zulip/zulip/__init__.py | 11 +++++++++++ zulip/zulip/examples/mute-topic | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 zulip/zulip/examples/mute-topic diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index c31a268..327c70b 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -939,6 +939,17 @@ class Client(object): request=request, ) + def mute_topic(self, request): + # type: (Dict[str, Any]) -> Dict[str, Any] + ''' + See examples/mute-topic for example usage. + ''' + return self.call_endpoint( + url='users/me/subscriptions/muted_topics', + method='PATCH', + request=request + ) + def get_stream_id(self, stream): # type: (str) -> Dict[str, Any] ''' diff --git a/zulip/zulip/examples/mute-topic b/zulip/zulip/examples/mute-topic new file mode 100755 index 0000000..acddcb5 --- /dev/null +++ b/zulip/zulip/examples/mute-topic @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import argparse + +import zulip + +usage = """mute-topic (mute | unmute) [options] + +Example: mute-topic mute Verona dinner +Example: mute-topic unmute Denmark party +""" + +parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) +parser.add_argument('op', choices=['mute', 'unmute']) +parser.add_argument('stream') +parser.add_argument('topic') +options = parser.parse_args() + +client = zulip.init_from_options(options) + +OPERATIONS = { + 'mute': 'add', + 'unmute': 'remove' +} + +print(client.mute_topic({ + 'op': OPERATIONS[options.op], + 'stream': options.stream, + 'topic': options.topic +}))