Skip to content

Commit ad05c24

Browse files
authored
Merge pull request #594 from watson-developer-cloud/feat/dynamic-model
Feat/dynamic model
2 parents 66fcbf0 + a499c63 commit ad05c24

File tree

77 files changed

+399
-696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+399
-696
lines changed

Examples/GenericSerialization.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,8 @@ void Start()
3333
LogSystem.InstallDefaultReactors();
3434

3535
MessageResponse messageResponse = JsonConvert.DeserializeObject<MessageResponse>(responseJson);
36-
//Dictionary<string, object> e = Json.Deserialize(responseJson) as Dictionary<string, object>;
37-
//Dictionary<string, object> context = e["context"] as Dictionary<string, object>;
38-
//Dictionary<string, object> skills = context["skills"] as Dictionary<string, object>;
39-
//Dictionary<string, object> main_skill = skills["main skill"] as Dictionary<string, object>;
40-
//Dictionary<string, object> user_defined = main_skill["user_defined"] as Dictionary<string, object>;
4136

42-
//string name = user_defined["name"] as string;
43-
44-
//var user_defined = messageResponse.Context.Skills["main skill"]["user_defined"].ToString();
45-
//var uDefinedObject = JsonConvert.DeserializeObject<Dictionary<string, object>>(user_defined);
46-
47-
//Log.Debug("GenericSerialization", "main skill: {0}", uDefinedObject["name"]);
48-
//Log.Debug("GenericSerialization", "test: {0}", messageResponse);
49-
50-
var name = messageResponse.Context.Skills["main skill"]["user_defined"]["name"].ToString();
37+
var name = messageResponse.Context.Skills.Get("main skill").UserDefined["name"].ToString();
5138
Log.Debug("GenericSerialization", "name: {0}", name);
5239

5340
}

Scripts/Services/Assistant/V1/AssistantService.cs

Lines changed: 52 additions & 51 deletions
Large diffs are not rendered by default.

Scripts/Services/Assistant/V1/Model/Context.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
*
1616
*/
1717

18+
using IBM.Cloud.SDK.Model;
1819
using Newtonsoft.Json;
19-
using Newtonsoft.Json.Linq;
2020

2121
namespace IBM.Watson.Assistant.V1.Model
2222
{
2323
/// <summary>
2424
/// State information for the conversation. To maintain state, include the context from the previous response.
2525
/// </summary>
26-
public class Context
26+
public class Context: DynamicModel<object>
2727
{
2828
/// <summary>
2929
/// The unique identifier of the conversation.
@@ -34,7 +34,7 @@ public class Context
3434
/// For internal use only.
3535
/// </summary>
3636
[JsonProperty("system", NullValueHandling = NullValueHandling.Ignore)]
37-
public JObject System { get; set; }
37+
public SystemResponse System { get; set; }
3838
/// <summary>
3939
/// Metadata related to the message.
4040
/// </summary>

Scripts/Services/Assistant/V1/Model/DialogNode.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using System.Collections.Generic;
1919
using Newtonsoft.Json;
20-
using Newtonsoft.Json.Linq;
2120
using System;
2221

2322
namespace IBM.Watson.Assistant.V1.Model
@@ -226,7 +225,7 @@ public class DigressOutSlotsValue
226225
/// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-overview#dialog-overview-responses).
227226
/// </summary>
228227
[JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)]
229-
public JObject Output { get; set; }
228+
public DialogNodeOutput Output { get; set; }
230229
/// <summary>
231230
/// The context for the dialog node.
232231
/// </summary>

Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
using System.Collections.Generic;
19+
using IBM.Cloud.SDK.Model;
1920
using Newtonsoft.Json;
2021

2122
namespace IBM.Watson.Assistant.V1.Model
@@ -24,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model
2425
/// The output of the dialog node. For more information about how to specify dialog node output, see the
2526
/// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-overview#dialog-overview-responses).
2627
/// </summary>
27-
public class DialogNodeOutput
28+
public class DialogNodeOutput: DynamicModel<object>
2829
{
2930
/// <summary>
3031
/// An array of objects describing the output defined for the dialog node.

Scripts/Services/Assistant/V1/Model/DialogNodeOutputOptionsElementValue.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using System.Collections.Generic;
1919
using Newtonsoft.Json;
20-
using Newtonsoft.Json.Linq;
2120

2221
namespace IBM.Watson.Assistant.V1.Model
2322
{
@@ -31,22 +30,22 @@ public class DialogNodeOutputOptionsElementValue
3130
/// An input object that includes the input text.
3231
/// </summary>
3332
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
34-
public JObject Input { get; set; }
33+
public MessageInput Input { get; set; }
3534
/// <summary>
3635
/// An array of intents to be used while processing the input.
3736
///
3837
/// **Note:** This property is supported for backward compatibility with applications that use the v1 **Get
3938
/// response to user input** method.
4039
/// </summary>
4140
[JsonProperty("intents", NullValueHandling = NullValueHandling.Ignore)]
42-
public List<JObject> Intents { get; set; }
41+
public List<RuntimeIntent> Intents { get; set; }
4342
/// <summary>
4443
/// An array of entities to be used while processing the user input.
4544
///
4645
/// **Note:** This property is supported for backward compatibility with applications that use the v1 **Get
4746
/// response to user input** method.
4847
/// </summary>
4948
[JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)]
50-
public List<JObject> Entities { get; set; }
49+
public List<RuntimeEntity> Entities { get; set; }
5150
}
5251
}

Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
using Newtonsoft.Json;
19-
using Newtonsoft.Json.Linq;
2019

2120
namespace IBM.Watson.Assistant.V1.Model
2221
{
@@ -42,7 +41,7 @@ public class DialogSuggestion
4241
/// corresponding option.
4342
/// </summary>
4443
[JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)]
45-
public JObject Output { get; set; }
44+
public DialogSuggestionOutput Output { get; set; }
4645
/// <summary>
4746
/// The ID of the dialog node that the **label** property is taken from. The **label** property is populated
4847
/// using the value of the dialog node's **user_label** property.

Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
using System.Collections.Generic;
19+
using IBM.Cloud.SDK.Model;
1920
using Newtonsoft.Json;
2021

2122
namespace IBM.Watson.Assistant.V1.Model
@@ -24,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model
2425
/// The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding
2526
/// option.
2627
/// </summary>
27-
public class DialogSuggestionOutput
28+
public class DialogSuggestionOutput: DynamicModel<object>
2829
{
2930
/// <summary>
3031
/// An array of the nodes that were triggered to create the response, in the order in which they were visited.

Scripts/Services/Assistant/V1/Model/DialogSuggestionValue.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using System.Collections.Generic;
1919
using Newtonsoft.Json;
20-
using Newtonsoft.Json.Linq;
2120

2221
namespace IBM.Watson.Assistant.V1.Model
2322
{
@@ -31,7 +30,7 @@ public class DialogSuggestionValue
3130
/// An input object that includes the input text.
3231
/// </summary>
3332
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
34-
public JObject Input { get; set; }
33+
public MessageInput Input { get; set; }
3534
/// <summary>
3635
/// An array of intents to be sent along with the user input.
3736
/// </summary>

Scripts/Services/Assistant/V1/Model/MessageInput.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*
1616
*/
1717

18+
using IBM.Cloud.SDK.Model;
1819
using Newtonsoft.Json;
1920

2021
namespace IBM.Watson.Assistant.V1.Model
2122
{
2223
/// <summary>
2324
/// An input object that includes the input text.
2425
/// </summary>
25-
public class MessageInput
26+
public class MessageInput: DynamicModel<object>
2627
{
2728
/// <summary>
2829
/// The text of the user input. This string cannot contain carriage return, newline, or tab characters.

0 commit comments

Comments
 (0)