Skip to content

Commit bf2e9cf

Browse files
author
Aubruz
committed
Implement delete_subscription
1 parent dc7685e commit bf2e9cf

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

Setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="mainframe-bot-api",
7-
version="1.1.13",
7+
version="1.2.0",
88
author="aubruz",
99
author_email="[email protected]",
1010
packages=find_packages(),
@@ -21,9 +21,6 @@
2121
'Intended Audience :: Developers',
2222
'Topic :: Software Development :: Build Tools',
2323
'License :: OSI Approved :: MIT License',
24-
25-
# Specify the Python versions you support here. In particular, ensure
26-
# that you indicate whether you support Python 2, Python 3 or both.
2724
'Programming Language :: Python :: 2',
2825
'Programming Language :: Python :: 2.6',
2926
'Programming Language :: Python :: 2.7',

mainframe/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ def send_message(self, conversation_id, message='', subscription_id=None, messag
2525
"""
2626
data = {'conversation_id': conversation_id, "message": message}
2727

28-
# if ($message instanceof UIPayload){
29-
# $json["data"] = $message->toArray();
30-
# }else{
31-
# }
28+
# if message instanceof UIPayload){
29+
# self.json["data"] = message.get();
3230

3331
if subscription_id is not None:
3432
data['subscription_id'] = subscription_id
@@ -56,11 +54,11 @@ def edit_subscription(self, subscription_token, label):
5654

5755
return self._make_call('edit_subscription', data)
5856

59-
def delete_subscription(self, subscription_token, label, message=None):
57+
def delete_subscription(self, conversation_id, subscription_id, message=None):
6058
"""Delete a subscription"""
6159
data = {
62-
'subscription_token': subscription_token,
63-
'label': label,
60+
'conversation_id': conversation_id,
61+
'subscription_id': subscription_id,
6462
}
6563

6664
if message is not None:

mainframe/component.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def __init__(self):
77
super().__init__()
88
self.can_have_children = False
99
self.must_have_children = False
10-
self.type = ''
11-
self.props = {}
10+
self.json['type'] = ''
11+
self.json['props'] = {}
1212

1313
def _can_have_children(self):
1414
self.can_have_children = True
15-
self.props['children'] = []
15+
self.json['props']['children'] = []
1616

1717
return self
1818

@@ -23,13 +23,10 @@ def _must_have_children(self):
2323
return self
2424

2525
def _set_type(self, component_type):
26-
self.type = component_type
27-
26+
self.json['type'] = component_type
2827
return self
2928

3029
def _add_props(self, props: dict, append=False):
31-
if self.json.get('props') is None:
32-
self.json['props'] = {}
3330
for property_key, property_value in props.items():
3431
if append:
3532
self.json['props'][property_key].append(property_value)
@@ -42,13 +39,13 @@ def _add_props(self, props: dict, append=False):
4239
return self
4340

4441
def _get_prop(self, prop):
45-
return self.json.get(prop)
42+
return self.json['props'].get(prop)
4643

4744
def add_children(self, component):
4845
if self.can_have_children:
4946
if isinstance(component, Component):
50-
self._add_props({'children': component.get()})
47+
self._add_props({'children': component.get()}, True)
5148
else:
52-
self._add_props({'children': component})
49+
self._add_props({'children': component}, True)
5350

5451
return self

mainframe/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def add_button(self, button):
1414
return self
1515

1616
def set_render(self, component):
17-
self.json['render'].append(component.get())
17+
self.json['render'] = component.get()
1818

1919
return self
2020

@@ -27,7 +27,7 @@ def __init__(self, url):
2727
self.json['type'] = 'authentication'
2828

2929
def add_payload(self, payload):
30-
self.json['payload'] = payload.get()
30+
self.json['payload'] = payload
3131

3232
return self
3333

0 commit comments

Comments
 (0)