Skip to content

Commit 7fb1a52

Browse files
authored
Merge pull request #598 from watson-developer-cloud/4.0.0-rc2
4.0.0 rc2
2 parents 66fcbf0 + ad05c24 commit 7fb1a52

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.

Scripts/Services/Assistant/V1/Model/MessageRequest.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
{
@@ -30,7 +29,7 @@ public class MessageRequest
3029
/// An input object that includes the input text.
3130
/// </summary>
3231
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
33-
public JObject Input { get; set; }
32+
public MessageInput Input { get; set; }
3433
/// <summary>
3534
/// Intents to use when evaluating the user input. Include intents from the previous response to continue using
3635
/// those intents rather than trying to recognize intents in the new input.
@@ -52,13 +51,13 @@ public class MessageRequest
5251
/// State information for the conversation. To maintain state, include the context from the previous response.
5352
/// </summary>
5453
[JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)]
55-
public JObject Context { get; set; }
54+
public Context Context { get; set; }
5655
/// <summary>
5756
/// An output object that includes the response to the user, the dialog nodes that were triggered, and messages
5857
/// from the log.
5958
/// </summary>
6059
[JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)]
61-
public JObject Output { get; set; }
60+
public OutputData Output { get; set; }
6261
/// <summary>
6362
/// An array of objects describing any actions requested by the dialog node.
6463
/// </summary>

Scripts/Services/Assistant/V1/Model/MessageResponse.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
{
@@ -30,7 +29,7 @@ public class MessageResponse
3029
/// An input object that includes the input text.
3130
/// </summary>
3231
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
33-
public JObject Input { get; set; }
32+
public MessageInput Input { get; set; }
3433
/// <summary>
3534
/// An array of intents recognized in the user input, sorted in descending order of confidence.
3635
/// </summary>
@@ -50,13 +49,13 @@ public class MessageResponse
5049
/// State information for the conversation. To maintain state, include the context from the previous response.
5150
/// </summary>
5251
[JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)]
53-
public JObject Context { get; set; }
52+
public Context Context { get; set; }
5453
/// <summary>
5554
/// An output object that includes the response to the user, the dialog nodes that were triggered, and messages
5655
/// from the log.
5756
/// </summary>
5857
[JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)]
59-
public JObject Output { get; set; }
58+
public OutputData Output { get; set; }
6059
/// <summary>
6160
/// An array of objects describing any actions requested by the dialog node.
6261
/// </summary>

Scripts/Services/Assistant/V1/Model/OutputData.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
/// An output object that includes the response to the user, the dialog nodes that were triggered, and messages from
2526
/// the log.
2627
/// </summary>
27-
public class OutputData
28+
public class OutputData: 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/SystemResponse.cs

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

18+
using IBM.Cloud.SDK.Model;
19+
1820
namespace IBM.Watson.Assistant.V1.Model
1921
{
2022
/// <summary>
2123
/// For internal use only.
2224
/// </summary>
23-
public class SystemResponse
25+
public class SystemResponse: DynamicModel<object>
2426
{
2527
}
2628
}

Scripts/Services/Assistant/V2/AssistantService.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace IBM.Watson.Assistant.V2
3232
public partial class AssistantService : BaseService
3333
{
3434
private const string serviceId = "assistant";
35-
private const string defaultUrl = "https://gateway.watsonplatform.net/assistant/api";
35+
private const string defaultServiceUrl = "https://gateway.watsonplatform.net/assistant/api";
3636

3737
#region VersionDate
3838
private string versionDate;
@@ -81,9 +81,10 @@ public AssistantService(string versionDate, Authenticator authenticator) : base(
8181
VersionDate = versionDate;
8282
}
8383

84-
if (string.IsNullOrEmpty(serviceUrl))
84+
85+
if (string.IsNullOrEmpty(GetServiceUrl()))
8586
{
86-
serviceUrl = defaultUrl;
87+
SetServiceUrl(defaultServiceUrl);
8788
}
8889
}
8990

@@ -131,7 +132,7 @@ public bool CreateSession(Callback<SessionResponse> callback, string assistantId
131132

132133
req.OnResponse = OnCreateSessionResponse;
133134

134-
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions", assistantId), serviceUrl);
135+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions", assistantId), GetServiceUrl());
135136
if (connector == null)
136137
{
137138
return false;
@@ -210,7 +211,7 @@ public bool DeleteSession(Callback<object> callback, string assistantId, string
210211

211212
req.OnResponse = OnDeleteSessionResponse;
212213

213-
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId), serviceUrl);
214+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId), GetServiceUrl());
214215
if (connector == null)
215216
{
216217
return false;
@@ -304,7 +305,7 @@ public bool Message(Callback<MessageResponse> callback, string assistantId, stri
304305

305306
req.OnResponse = OnMessageResponse;
306307

307-
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId), serviceUrl);
308+
RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId), GetServiceUrl());
308309
if (connector == null)
309310
{
310311
return false;

Scripts/Services/Assistant/V2/Model/MessageContext.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.V2.Model
2221
{
@@ -37,6 +36,6 @@ public class MessageContext
3736
/// that apply to the dialog skill used by the assistant.
3837
/// </summary>
3938
[JsonProperty("skills", NullValueHandling = NullValueHandling.Ignore)]
40-
public JObject Skills { get; set; }
39+
public MessageContextSkills Skills { get; set; }
4140
}
4241
}

Scripts/Services/Assistant/V2/Model/MessageContextSkills.cs

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

18+
using IBM.Cloud.SDK.Model;
19+
1820
namespace IBM.Watson.Assistant.V2.Model
1921
{
2022
/// <summary>
@@ -23,7 +25,7 @@ namespace IBM.Watson.Assistant.V2.Model
2325
/// **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that
2426
/// apply to the dialog skill used by the assistant.
2527
/// </summary>
26-
public class MessageContextSkills
28+
public class MessageContextSkills: DynamicModel<MessageContextSkill>
2729
{
2830
}
2931
}

Scripts/Services/Assistant/V2/Model/SearchResult.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.V2.Model
2221
{
@@ -60,6 +59,6 @@ public class SearchResult
6059
/// <em> tags.
6160
/// </summary>
6261
[JsonProperty("highlight", NullValueHandling = NullValueHandling.Ignore)]
63-
public JObject Highlight { get; set; }
62+
public SearchResultHighlight Highlight { get; set; }
6463
}
6564
}

0 commit comments

Comments
 (0)