Rename bot storage endpoint from state to storage.
MODIFY
zulip/zulip/__init__.py
zulip/zulip/__init__.py
@@ -878,12 +878,12 @@ class Client(object):
'''
Example usage:
- >>> client.update_storage({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}})
+ >>> client.update_storage({'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}})
>>> client.get_storage({'keys': ["entry 1", "entry 3"]})
- {'result': 'success', 'state': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''}
+ {'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''}
'''
return self.call_endpoint(
- url='user_state',
+ url='bot_storage',
method='PUT',
request=request,
)
@@ -893,14 +893,14 @@ class Client(object):
'''
Example usage:
- >>> client.update_storage({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}})
+ >>> client.update_storage({'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}})
>>> client.get_storage()
- {'result': 'success', 'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}, 'msg': ''}
+ {'result': 'success', 'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}, 'msg': ''}
>>> client.get_storage(keys=('entry 1', 'entry 3'))
- {'result': 'success', 'state': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''}
+ {'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''}
'''
return self.call_endpoint(
- url='user_state',
+ url='bot_storage',
method='GET',
request=request,
)

MODIFY
zulip_bots/zulip_bots/lib.py
zulip_bots/zulip_bots/lib.py
@@ -66,14 +66,14 @@ class StateHandler(object):
self.demarshal = lambda obj: json.loads(obj)
response = self._client.get_storage()
if response['result'] == 'success':
- self.state_ = response['state']
+ self.state_ = response['storage']
else:
raise StateHandlerError("Error initializing state: {}".format(str(response)))
def put(self, key, value):
# type: (Text, Text) -> None
self.state_[key] = self.marshal(value)
- response = self._client.update_storage({'state': {key: self.state_[key]}})
+ response = self._client.update_storage({'storage': {key: self.state_[key]}})
if response['result'] != 'success':
raise StateHandlerError("Error updating state: {}".format(str(response)))

MODIFY
zulip_bots/zulip_bots/test_lib.py
zulip_bots/zulip_bots/test_lib.py
@@ -46,7 +46,7 @@ class BotTestCaseBase(TestCase):
self.MockClass = self.patcher.start()
self.mock_bot_handler = self.MockClass(None, None, None, None)
self.mock_client = MagicMock()
- self.mock_client.get_storage.return_value = {'result': 'success', 'state': {}}
+ self.mock_client.get_storage.return_value = {'result': 'success', 'storage': {}}
self.mock_client.update_storage.return_value = {'result': 'success'}
self.mock_bot_handler.storage = StateHandler(self.mock_client)
self.mock_bot_handler.send_message.return_value = {'id': 42}

Rename bot storage endpoint from state to storage.