Skip to content

Commit 75d129e

Browse files
committed
fixing profile setting
1 parent 981c922 commit 75d129e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

examples/dialog_v1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@
3434
# client_id=initial_response['client_id']), indent=2))
3535

3636
# print(json.dumps(dialog.delete_dialog(dialog_id='63b0489c-cd97-45ef-8800-4e7c310eeb19'), indent=2))
37+
38+
# print(json.dumps(dialog.update_profile(
39+
# dialog_id='6250d170-41d6-468a-a697-5675578c8012', client_id=123, name_values=[{'name': 'test', 'value': 'v1'}]),
40+
# indent=2))
41+
#
42+
# print(json.dumps(dialog.get_profile(
43+
# dialog_id='6250d170-41d6-468a-a697-5675578c8012', client_id=123), indent=2))

watson_developer_cloud/dialog_v1.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,23 @@ def get_conversation(self, dialog_id, date_from, date_to):
7474
return self.request(method='GET', url='/v1/dialogs/{}/conversation'.format(dialog_id), params=params,
7575
accept_json=True)
7676

77-
def get_profile(self, dialog_id, client_id):
77+
def get_profile(self, dialog_id, client_id, name=None):
7878
dialog_id = self.unpack_id(dialog_id, 'dialog_id')
7979
client_id = self.unpack_id(client_id, 'client_id')
80-
params = {'client_id': client_id}
80+
params = {'client_id': client_id, 'name': name}
8181
return self.request(method='GET', url='/v1/dialogs/{}/profile'.format(dialog_id), params=params,
8282
accept_json=True)
8383

84-
def update_profile(self, dialog_id, client_id, name_values):
84+
def update_profile(self, dialog_id, name_values, client_id=None):
8585
dialog_id = self.unpack_id(dialog_id, 'dialog_id')
8686
client_id = self.unpack_id(client_id, 'client_id')
87-
params = {'client_id': client_id}
88-
return self.request(method='PUT', url='/v1/dialogs/{}/profile'.format(dialog_id), params=params,
89-
json=name_values, accept_json=True)
87+
if isinstance(name_values, dict):
88+
name_values = list({'name': item[0], 'value': item[1]} for item in name_values.items())
89+
params = {
90+
'client_id': client_id,
91+
'name_values': name_values
92+
}
93+
return self.request(method='PUT', url='/v1/dialogs/{}/profile'.format(dialog_id), json=params, accept_json=True)
9094

9195
def delete_dialog(self, dialog_id):
9296
dialog_id = self.unpack_id(dialog_id, 'dialog_id')

0 commit comments

Comments
 (0)