Skip to content

Commit 0854633

Browse files
feat(wa-v2): add dtmf and end_session response types
1 parent 42efff7 commit 0854633

File tree

2 files changed

+381
-4
lines changed

2 files changed

+381
-4
lines changed

ibm_watson/assistant_v2.py

Lines changed: 277 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2019, 2025.
3+
# (C) Copyright IBM Corp. 2019, 2026.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -4677,6 +4677,88 @@ def __ne__(self, other: 'DialogSuggestionValue') -> bool:
46774677
return not self == other
46784678

46794679

4680+
class DtmfCommandInfo:
4681+
"""
4682+
DtmfCommandInfo.
4683+
4684+
:param str type: Specifies the type of DTMF command for the phone integration.
4685+
:param dict parameters: (optional) Parameters specified by the command type.
4686+
"""
4687+
4688+
def __init__(
4689+
self,
4690+
type: str,
4691+
*,
4692+
parameters: Optional[dict] = None,
4693+
) -> None:
4694+
"""
4695+
Initialize a DtmfCommandInfo object.
4696+
4697+
:param str type: Specifies the type of DTMF command for the phone
4698+
integration.
4699+
:param dict parameters: (optional) Parameters specified by the command
4700+
type.
4701+
"""
4702+
self.type = type
4703+
self.parameters = parameters
4704+
4705+
@classmethod
4706+
def from_dict(cls, _dict: Dict) -> 'DtmfCommandInfo':
4707+
"""Initialize a DtmfCommandInfo object from a json dictionary."""
4708+
args = {}
4709+
if (type := _dict.get('type')) is not None:
4710+
args['type'] = type
4711+
else:
4712+
raise ValueError(
4713+
'Required property \'type\' not present in DtmfCommandInfo JSON'
4714+
)
4715+
if (parameters := _dict.get('parameters')) is not None:
4716+
args['parameters'] = parameters
4717+
return cls(**args)
4718+
4719+
@classmethod
4720+
def _from_dict(cls, _dict):
4721+
"""Initialize a DtmfCommandInfo object from a json dictionary."""
4722+
return cls.from_dict(_dict)
4723+
4724+
def to_dict(self) -> Dict:
4725+
"""Return a json dictionary representing this model."""
4726+
_dict = {}
4727+
if hasattr(self, 'type') and self.type is not None:
4728+
_dict['type'] = self.type
4729+
if hasattr(self, 'parameters') and self.parameters is not None:
4730+
_dict['parameters'] = self.parameters
4731+
return _dict
4732+
4733+
def _to_dict(self):
4734+
"""Return a json dictionary representing this model."""
4735+
return self.to_dict()
4736+
4737+
def __str__(self) -> str:
4738+
"""Return a `str` version of this DtmfCommandInfo object."""
4739+
return json.dumps(self.to_dict(), indent=2)
4740+
4741+
def __eq__(self, other: 'DtmfCommandInfo') -> bool:
4742+
"""Return `true` when self and other are equal, false otherwise."""
4743+
if not isinstance(other, self.__class__):
4744+
return False
4745+
return self.__dict__ == other.__dict__
4746+
4747+
def __ne__(self, other: 'DtmfCommandInfo') -> bool:
4748+
"""Return `true` when self and other are not equal, false otherwise."""
4749+
return not self == other
4750+
4751+
class TypeEnum(str, Enum):
4752+
"""
4753+
Specifies the type of DTMF command for the phone integration.
4754+
"""
4755+
4756+
COLLECT = 'collect'
4757+
DISABLE_BARGE_IN = 'disable_barge_in'
4758+
ENABLE_BARGE_IN = 'enable_barge_in'
4759+
SEND = 'send'
4760+
4761+
46804762
class Environment:
46814763
"""
46824764
Environment.
@@ -12107,7 +12189,9 @@ def __init__(self,) -> None:
1210712189
'RuntimeResponseGenericRuntimeResponseTypeVideo',
1210812190
'RuntimeResponseGenericRuntimeResponseTypeAudio',
1210912191
'RuntimeResponseGenericRuntimeResponseTypeIframe',
12110-
'RuntimeResponseGenericRuntimeResponseTypeDate'
12192+
'RuntimeResponseGenericRuntimeResponseTypeDate',
12193+
'RuntimeResponseGenericRuntimeResponseTypeDtmf',
12194+
'RuntimeResponseGenericRuntimeResponseTypeEndSession'
1211112195
]))
1211212196
raise Exception(msg)
1211312197

@@ -12132,7 +12216,9 @@ def from_dict(cls, _dict: Dict) -> 'RuntimeResponseGeneric':
1213212216
'RuntimeResponseGenericRuntimeResponseTypeVideo',
1213312217
'RuntimeResponseGenericRuntimeResponseTypeAudio',
1213412218
'RuntimeResponseGenericRuntimeResponseTypeIframe',
12135-
'RuntimeResponseGenericRuntimeResponseTypeDate'
12219+
'RuntimeResponseGenericRuntimeResponseTypeDate',
12220+
'RuntimeResponseGenericRuntimeResponseTypeDtmf',
12221+
'RuntimeResponseGenericRuntimeResponseTypeEndSession'
1213612222
]))
1213712223
raise Exception(msg)
1213812224

@@ -12163,6 +12249,9 @@ def _get_class_by_discriminator(cls, _dict: Dict) -> object:
1216312249
mapping[
1216412250
'user_defined'] = 'RuntimeResponseGenericRuntimeResponseTypeUserDefined'
1216512251
mapping['video'] = 'RuntimeResponseGenericRuntimeResponseTypeVideo'
12252+
mapping['dtmf'] = 'RuntimeResponseGenericRuntimeResponseTypeDtmf'
12253+
mapping[
12254+
'end_session'] = 'RuntimeResponseGenericRuntimeResponseTypeEndSession'
1216612255
disc_value = _dict.get('response_type')
1216712256
if disc_value is None:
1216812257
raise ValueError(
@@ -21888,6 +21977,191 @@ def __ne__(self,
2188821977
return not self == other
2188921978

2189021979

21980+
class RuntimeResponseGenericRuntimeResponseTypeDtmf(RuntimeResponseGeneric):
21981+
"""
21982+
RuntimeResponseGenericRuntimeResponseTypeDtmf.
21983+
21984+
:param str response_type: The type of response returned by the dialog node. The
21985+
specified response type must be supported by the client application or channel.
21986+
:param DtmfCommandInfo command_info: (optional)
21987+
:param List[ResponseGenericChannel] channels: (optional) An array of objects
21988+
specifying channels for which the response is intended. If **channels** is
21989+
present, the response is intended for a built-in integration and should not be
21990+
handled by an API client.
21991+
"""
21992+
21993+
def __init__(
21994+
self,
21995+
response_type: str,
21996+
*,
21997+
command_info: Optional['DtmfCommandInfo'] = None,
21998+
channels: Optional[List['ResponseGenericChannel']] = None,
21999+
) -> None:
22000+
"""
22001+
Initialize a RuntimeResponseGenericRuntimeResponseTypeDtmf object.
22002+
22003+
:param str response_type: The type of response returned by the dialog node.
22004+
The specified response type must be supported by the client application or
22005+
channel.
22006+
:param DtmfCommandInfo command_info: (optional)
22007+
:param List[ResponseGenericChannel] channels: (optional) An array of
22008+
objects specifying channels for which the response is intended. If
22009+
**channels** is present, the response is intended for a built-in
22010+
integration and should not be handled by an API client.
22011+
"""
22012+
# pylint: disable=super-init-not-called
22013+
self.response_type = response_type
22014+
self.command_info = command_info
22015+
self.channels = channels
22016+
22017+
@classmethod
22018+
def from_dict(
22019+
cls,
22020+
_dict: Dict) -> 'RuntimeResponseGenericRuntimeResponseTypeDtmf':
22021+
"""Initialize a RuntimeResponseGenericRuntimeResponseTypeDtmf object from a json dictionary."""
22022+
args = {}
22023+
if (response_type := _dict.get('response_type')) is not None:
22024+
args['response_type'] = response_type
22025+
else:
22026+
raise ValueError(
22027+
'Required property \'response_type\' not present in RuntimeResponseGenericRuntimeResponseTypeDtmf JSON'
22028+
)
22029+
if (command_info := _dict.get('command_info')) is not None:
22030+
args['command_info'] = DtmfCommandInfo.from_dict(command_info)
22031+
if (channels := _dict.get('channels')) is not None:
22032+
args['channels'] = [
22033+
ResponseGenericChannel.from_dict(v) for v in channels
22034+
]
22035+
return cls(**args)
22036+
22037+
@classmethod
22038+
def _from_dict(cls, _dict):
22039+
"""Initialize a RuntimeResponseGenericRuntimeResponseTypeDtmf object from a json dictionary."""
22040+
return cls.from_dict(_dict)
22041+
22042+
def to_dict(self) -> Dict:
22043+
"""Return a json dictionary representing this model."""
22044+
_dict = {}
22045+
if hasattr(self, 'response_type') and self.response_type is not None:
22046+
_dict['response_type'] = self.response_type
22047+
if hasattr(self, 'command_info') and self.command_info is not None:
22048+
if isinstance(self.command_info, dict):
22049+
_dict['command_info'] = self.command_info
22050+
else:
22051+
_dict['command_info'] = self.command_info.to_dict()
22052+
if hasattr(self, 'channels') and self.channels is not None:
22053+
channels_list = []
22054+
for v in self.channels:
22055+
if isinstance(v, dict):
22056+
channels_list.append(v)
22057+
else:
22058+
channels_list.append(v.to_dict())
22059+
_dict['channels'] = channels_list
22060+
return _dict
22061+
22062+
def _to_dict(self):
22063+
"""Return a json dictionary representing this model."""
22064+
return self.to_dict()
22065+
22066+
def __str__(self) -> str:
22067+
"""Return a `str` version of this RuntimeResponseGenericRuntimeResponseTypeDtmf object."""
22068+
return json.dumps(self.to_dict(), indent=2)
22069+
22070+
def __eq__(self,
22071+
other: 'RuntimeResponseGenericRuntimeResponseTypeDtmf') -> bool:
22072+
"""Return `true` when self and other are equal, false otherwise."""
22073+
if not isinstance(other, self.__class__):
22074+
return False
22075+
return self.__dict__ == other.__dict__
22076+
22077+
def __ne__(self,
22078+
other: 'RuntimeResponseGenericRuntimeResponseTypeDtmf') -> bool:
22079+
"""Return `true` when self and other are not equal, false otherwise."""
22080+
return not self == other
22081+
22082+
22083+
class RuntimeResponseGenericRuntimeResponseTypeEndSession(
22084+
RuntimeResponseGeneric):
22085+
"""
22086+
RuntimeResponseGenericRuntimeResponseTypeEndSession.
22087+
22088+
:param str response_type: The type of response returned by the dialog node. The
22089+
specified response type must be supported by the client application or channel.
22090+
:param dict channel_options: (optional) For internal use only.
22091+
"""
22092+
22093+
def __init__(
22094+
self,
22095+
response_type: str,
22096+
*,
22097+
channel_options: Optional[dict] = None,
22098+
) -> None:
22099+
"""
22100+
Initialize a RuntimeResponseGenericRuntimeResponseTypeEndSession object.
22101+
22102+
:param str response_type: The type of response returned by the dialog node.
22103+
The specified response type must be supported by the client application or
22104+
channel.
22105+
:param dict channel_options: (optional) For internal use only.
22106+
"""
22107+
# pylint: disable=super-init-not-called
22108+
self.response_type = response_type
22109+
self.channel_options = channel_options
22110+
22111+
@classmethod
22112+
def from_dict(
22113+
cls, _dict: Dict
22114+
) -> 'RuntimeResponseGenericRuntimeResponseTypeEndSession':
22115+
"""Initialize a RuntimeResponseGenericRuntimeResponseTypeEndSession object from a json dictionary."""
22116+
args = {}
22117+
if (response_type := _dict.get('response_type')) is not None:
22118+
args['response_type'] = response_type
22119+
else:
22120+
raise ValueError(
22121+
'Required property \'response_type\' not present in RuntimeResponseGenericRuntimeResponseTypeEndSession JSON'
22122+
)
22123+
if (channel_options := _dict.get('channel_options')) is not None:
22124+
args['channel_options'] = channel_options
22125+
return cls(**args)
22126+
22127+
@classmethod
22128+
def _from_dict(cls, _dict):
22129+
"""Initialize a RuntimeResponseGenericRuntimeResponseTypeEndSession object from a json dictionary."""
22130+
return cls.from_dict(_dict)
22131+
22132+
def to_dict(self) -> Dict:
22133+
"""Return a json dictionary representing this model."""
22134+
_dict = {}
22135+
if hasattr(self, 'response_type') and self.response_type is not None:
22136+
_dict['response_type'] = self.response_type
22137+
if hasattr(self,
22138+
'channel_options') and self.channel_options is not None:
22139+
_dict['channel_options'] = self.channel_options
22140+
return _dict
22141+
22142+
def _to_dict(self):
22143+
"""Return a json dictionary representing this model."""
22144+
return self.to_dict()
22145+
22146+
def __str__(self) -> str:
22147+
"""Return a `str` version of this RuntimeResponseGenericRuntimeResponseTypeEndSession object."""
22148+
return json.dumps(self.to_dict(), indent=2)
22149+
22150+
def __eq__(
22151+
self, other: 'RuntimeResponseGenericRuntimeResponseTypeEndSession'
22152+
) -> bool:
22153+
"""Return `true` when self and other are equal, false otherwise."""
22154+
if not isinstance(other, self.__class__):
22155+
return False
22156+
return self.__dict__ == other.__dict__
22157+
22158+
def __ne__(
22159+
self, other: 'RuntimeResponseGenericRuntimeResponseTypeEndSession'
22160+
) -> bool:
22161+
"""Return `true` when self and other are not equal, false otherwise."""
22162+
return not self == other
22163+
22164+
2189122165
class RuntimeResponseGenericRuntimeResponseTypeIframe(RuntimeResponseGeneric):
2189222166
"""
2189322167
RuntimeResponseGenericRuntimeResponseTypeIframe.

0 commit comments

Comments
 (0)