From e0ead9909b7144d074e1dddc57176ad7309a676a Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Mon, 21 Dec 2020 12:21:47 -0500 Subject: [PATCH] fix(Assistant): node dialog respose should have agent props --- Examples/ExamplePersonalityInsightsV3.cs | 2 +- Examples/GenericSerialization.cs | 2 +- .../Services/Assistant/V1/AssistantService.cs | 174 ++++++++--------- .../V1/Model/AgentAvailabilityMessage.cs | 33 ++++ .../V1/Model/AgentAvailabilityMessage.cs.meta | 11 ++ .../Assistant/V1/Model/DialogNodeOutput.cs | 2 +- .../V1/Model/DialogNodeOutputGeneric.cs | 4 +- ...logNodeOutputResponseTypeConnectToAgent.cs | 4 +- .../Assistant/V1/Model/MessageInput.cs | 4 +- .../Services/Assistant/V1/Model/OutputData.cs | 4 +- .../Assistant/V1/Model/RuntimeEntity.cs | 7 +- .../V1/Model/RuntimeResponseGeneric.cs | 4 +- ...enericRuntimeResponseTypeConnectToAgent.cs | 4 +- .../Services/Assistant/V2/AssistantService.cs | 176 +++++++++--------- .../V2/Model/AgentAvailabilityMessage.cs | 33 ++++ .../V2/Model/AgentAvailabilityMessage.cs.meta | 11 ++ .../V2/Model/MessageContextSkillSystem.cs | 2 +- .../V2/Model/RuntimeResponseGeneric.cs | 4 +- ...enericRuntimeResponseTypeConnectToAgent.cs | 4 +- .../V2/Model/SearchResultHighlight.cs | 4 +- .../PersonalityInsightsV3IntegrationTests.cs | 2 +- Tests/ToneAnalyzerV3IntegrationTests.cs | 2 +- 22 files changed, 290 insertions(+), 203 deletions(-) create mode 100644 Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs create mode 100644 Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs.meta create mode 100644 Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs create mode 100644 Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs.meta diff --git a/Examples/ExamplePersonalityInsightsV3.cs b/Examples/ExamplePersonalityInsightsV3.cs index 2bb00df5c..323fba8e9 100644 --- a/Examples/ExamplePersonalityInsightsV3.cs +++ b/Examples/ExamplePersonalityInsightsV3.cs @@ -1,5 +1,5 @@ /** -* Copyright 2019 IBM Corp. All Rights Reserved. +* (C) Copyright IBM Corp. 2019, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Examples/GenericSerialization.cs b/Examples/GenericSerialization.cs index 1bff9afd8..0fa5daa1d 100644 --- a/Examples/GenericSerialization.cs +++ b/Examples/GenericSerialization.cs @@ -1,5 +1,5 @@ /** -* Copyright 2019 IBM Corp. All Rights Reserved. +* (C) Copyright IBM Corp. 2019, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Scripts/Services/Assistant/V1/AssistantService.cs b/Scripts/Services/Assistant/V1/AssistantService.cs index 007b8f3e5..50ff2b2f6 100644 --- a/Scripts/Services/Assistant/V1/AssistantService.cs +++ b/Scripts/Services/Assistant/V1/AssistantService.cs @@ -16,7 +16,7 @@ */ /** -* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201209-153452 +* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201221-120002 */ using System.Collections.Generic; @@ -228,6 +228,92 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response ((RequestObject)req).Callback(response, resp.Error); } + /// + /// Identify intents and entities in multiple user utterances. + /// + /// Send multiple user inputs to a workspace in a single request and receive information about the intents and + /// entities recognized in each input. This method is useful for testing and comparing the performance of + /// different workspaces. + /// + /// This method is available only with Premium plans. + /// + /// The callback function that is invoked when the operation completes. + /// Unique identifier of the workspace. + /// An array of input utterances to classify. (optional) + /// BulkClassifyResponse + public bool BulkClassify(Callback callback, string workspaceId, List input = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `BulkClassify`"); + if (string.IsNullOrEmpty(workspaceId)) + throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`"); + if (string.IsNullOrEmpty(Version)) + throw new ArgumentNullException("`Version` is required"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("conversation", "V1", "BulkClassify")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + if (!string.IsNullOrEmpty(Version)) + { + req.Parameters["version"] = Version; + } + req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + + JObject bodyObject = new JObject(); + if (input != null && input.Count > 0) + bodyObject["input"] = JToken.FromObject(input); + req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); + + req.OnResponse = OnBulkClassifyResponse; + + Connector.URL = GetServiceUrl() + string.Format("/v1/workspaces/{0}/bulk_classify", workspaceId); + Authenticator.Authenticate(Connector); + + return Connector.Send(req); + } + + private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// /// List workspaces. /// @@ -4665,91 +4751,5 @@ private void OnDeleteUserDataResponse(RESTConnector.Request req, RESTConnector.R if (((RequestObject)req).Callback != null) ((RequestObject)req).Callback(response, resp.Error); } - - /// - /// Identify intents and entities in multiple user utterances. - /// - /// Send multiple user inputs to a workspace in a single request and receive information about the intents and - /// entities recognized in each input. This method is useful for testing and comparing the performance of - /// different workspaces. - /// - /// This method is available only with Premium plans. - /// - /// The callback function that is invoked when the operation completes. - /// Unique identifier of the workspace. - /// An array of input utterances to classify. (optional) - /// BulkClassifyResponse - public bool BulkClassify(Callback callback, string workspaceId, List input = null) - { - if (callback == null) - throw new ArgumentNullException("`callback` is required for `BulkClassify`"); - if (string.IsNullOrEmpty(workspaceId)) - throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`"); - if (string.IsNullOrEmpty(Version)) - throw new ArgumentNullException("`Version` is required"); - - RequestObject req = new RequestObject - { - Callback = callback, - HttpMethod = UnityWebRequest.kHttpVerbPOST, - DisableSslVerification = DisableSslVerification - }; - - foreach (KeyValuePair kvp in customRequestHeaders) - { - req.Headers.Add(kvp.Key, kvp.Value); - } - - ClearCustomRequestHeaders(); - - foreach (KeyValuePair kvp in Common.GetSdkHeaders("conversation", "V1", "BulkClassify")) - { - req.Headers.Add(kvp.Key, kvp.Value); - } - - if (!string.IsNullOrEmpty(Version)) - { - req.Parameters["version"] = Version; - } - req.Headers["Content-Type"] = "application/json"; - req.Headers["Accept"] = "application/json"; - - JObject bodyObject = new JObject(); - if (input != null && input.Count > 0) - bodyObject["input"] = JToken.FromObject(input); - req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); - - req.OnResponse = OnBulkClassifyResponse; - - Connector.URL = GetServiceUrl() + string.Format("/v1/workspaces/{0}/bulk_classify", workspaceId); - Authenticator.Authenticate(Connector); - - return Connector.Send(req); - } - - private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp) - { - DetailedResponse response = new DetailedResponse(); - foreach (KeyValuePair kvp in resp.Headers) - { - response.Headers.Add(kvp.Key, kvp.Value); - } - response.StatusCode = resp.HttpResponseCode; - - try - { - string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); - response.Response = json; - } - catch (Exception e) - { - Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString()); - resp.Success = false; - } - - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); - } } } \ No newline at end of file diff --git a/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs b/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs new file mode 100644 index 000000000..5d37683f0 --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs @@ -0,0 +1,33 @@ +/** +* (C) Copyright IBM Corp. 2020. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V1.Model +{ + /// + /// AgentAvailabilityMessage. + /// + public class AgentAvailabilityMessage + { + /// + /// The text of the message. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs.meta b/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs.meta new file mode 100644 index 000000000..226b35d77 --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ab0f5c4cab5448d0a82a4fba50395ed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs index 44487b137..20b821ced 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs @@ -25,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model /// The output of the dialog node. For more information about how to specify dialog node output, see the /// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). /// - public class DialogNodeOutput: DynamicModel + public class DialogNodeOutput : DynamicModel { /// /// An array of objects describing the output defined for the dialog node. diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs index 0e4069e9c..df6838c77 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs @@ -193,13 +193,13 @@ public class QueryTypeValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public string AgentAvailable { get; protected set; } + public AgentAvailabilityMessage AgentAvailable { get; protected set; } /// /// An optional message to be displayed to the user to indicate that no online agent is available to take over /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public string AgentUnavailable { get; protected set; } + public AgentAvailabilityMessage AgentUnavailable { get; protected set; } /// /// Routing or other contextual information to be used by target service desk systems. /// diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.cs index c2f395fb4..fd0f5ed6a 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.cs @@ -51,7 +51,7 @@ public class ResponseTypeValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentAvailable + public new AgentAvailabilityMessage AgentAvailable { get { return base.AgentAvailable; } set { base.AgentAvailable = value; } @@ -61,7 +61,7 @@ public class ResponseTypeValue /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentUnavailable + public new AgentAvailabilityMessage AgentUnavailable { get { return base.AgentUnavailable; } set { base.AgentUnavailable = value; } diff --git a/Scripts/Services/Assistant/V1/Model/MessageInput.cs b/Scripts/Services/Assistant/V1/Model/MessageInput.cs index c25a061eb..43d4760a7 100644 --- a/Scripts/Services/Assistant/V1/Model/MessageInput.cs +++ b/Scripts/Services/Assistant/V1/Model/MessageInput.cs @@ -1,5 +1,5 @@ /** -* (C) Copyright IBM Corp. 2018, 2020. +* (C) Copyright IBM Corp. 2019, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace IBM.Watson.Assistant.V1.Model /// /// An input object that includes the input text. /// - public class MessageInput: DynamicModel + public class MessageInput : DynamicModel { /// /// The text of the user input. This string cannot contain carriage return, newline, or tab characters. diff --git a/Scripts/Services/Assistant/V1/Model/OutputData.cs b/Scripts/Services/Assistant/V1/Model/OutputData.cs index fd47e085b..e700e5824 100644 --- a/Scripts/Services/Assistant/V1/Model/OutputData.cs +++ b/Scripts/Services/Assistant/V1/Model/OutputData.cs @@ -1,5 +1,5 @@ /** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* (C) Copyright IBM Corp. 2019, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model /// An output object that includes the response to the user, the dialog nodes that were triggered, and messages from /// the log. /// - public class OutputData: DynamicModel + public class OutputData : DynamicModel { /// /// An array of the nodes that were triggered to create the response, in the order in which they were visited. diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs b/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs index f065444eb..aedda88cd 100644 --- a/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs +++ b/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs @@ -57,11 +57,10 @@ public class RuntimeEntity [JsonProperty("groups", NullValueHandling = NullValueHandling.Ignore)] public List Groups { get; set; } /// - /// An object containing detailed information about the entity recognized in the user input. This property is - /// included only if the new system entities are enabled for the workspace. + /// An object containing detailed information about the entity recognized in the user input. /// - /// For more information about how the new system entities are interpreted, see the - /// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities). + /// For more information about how system entities are interpreted, see the + /// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities). /// [JsonProperty("interpretation", NullValueHandling = NullValueHandling.Ignore)] public RuntimeEntityInterpretation Interpretation { get; set; } diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs index cf988284d..b73848e2f 100644 --- a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs +++ b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs @@ -139,13 +139,13 @@ public class PreferenceValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public string AgentAvailable { get; protected set; } + public AgentAvailabilityMessage AgentAvailable { get; protected set; } /// /// An optional message to be displayed to the user to indicate that no online agent is available to take over /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public string AgentUnavailable { get; protected set; } + public AgentAvailabilityMessage AgentUnavailable { get; protected set; } /// /// Routing or other contextual information to be used by target service desk systems. /// diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs index 1a7a61416..8eccef768 100644 --- a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs +++ b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs @@ -51,7 +51,7 @@ public class ResponseTypeValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentAvailable + public new AgentAvailabilityMessage AgentAvailable { get { return base.AgentAvailable; } set { base.AgentAvailable = value; } @@ -61,7 +61,7 @@ public class ResponseTypeValue /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentUnavailable + public new AgentAvailabilityMessage AgentUnavailable { get { return base.AgentUnavailable; } set { base.AgentUnavailable = value; } diff --git a/Scripts/Services/Assistant/V2/AssistantService.cs b/Scripts/Services/Assistant/V2/AssistantService.cs index a1bb7a3bb..77c99ea96 100644 --- a/Scripts/Services/Assistant/V2/AssistantService.cs +++ b/Scripts/Services/Assistant/V2/AssistantService.cs @@ -16,7 +16,7 @@ */ /** -* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201209-153452 +* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201221-120002 */ using System.Collections.Generic; @@ -472,6 +472,93 @@ private void OnMessageStatelessResponse(RESTConnector.Request req, RESTConnector ((RequestObject)req).Callback(response, resp.Error); } + /// + /// Identify intents and entities in multiple user utterances. + /// + /// Send multiple user inputs to a dialog skill in a single request and receive information about the intents + /// and entities recognized in each input. This method is useful for testing and comparing the performance of + /// different skills or skill versions. + /// + /// This method is available only with Premium plans. + /// + /// The callback function that is invoked when the operation completes. + /// Unique identifier of the skill. To find the skill ID in the Watson Assistant user + /// interface, open the skill settings and click **API Details**. + /// An array of input utterances to classify. (optional) + /// BulkClassifyResponse + public bool BulkClassify(Callback callback, string skillId, List input = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `BulkClassify`"); + if (string.IsNullOrEmpty(skillId)) + throw new ArgumentNullException("`skillId` is required for `BulkClassify`"); + if (string.IsNullOrEmpty(Version)) + throw new ArgumentNullException("`Version` is required"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("conversation", "V2", "BulkClassify")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + if (!string.IsNullOrEmpty(Version)) + { + req.Parameters["version"] = Version; + } + req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + + JObject bodyObject = new JObject(); + if (input != null && input.Count > 0) + bodyObject["input"] = JToken.FromObject(input); + req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); + + req.OnResponse = OnBulkClassifyResponse; + + Connector.URL = GetServiceUrl() + string.Format("/v2/skills/{0}/workspace/bulk_classify", skillId); + Authenticator.Authenticate(Connector); + + return Connector.Send(req); + } + + private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// /// List log events for an assistant. /// @@ -661,92 +748,5 @@ private void OnDeleteUserDataResponse(RESTConnector.Request req, RESTConnector.R if (((RequestObject)req).Callback != null) ((RequestObject)req).Callback(response, resp.Error); } - - /// - /// Identify intents and entities in multiple user utterances. - /// - /// Send multiple user inputs to a dialog skill in a single request and receive information about the intents - /// and entities recognized in each input. This method is useful for testing and comparing the performance of - /// different skills or skill versions. - /// - /// This method is available only with Premium plans. - /// - /// The callback function that is invoked when the operation completes. - /// Unique identifier of the skill. To find the skill ID in the Watson Assistant user - /// interface, open the skill settings and click **API Details**. - /// An array of input utterances to classify. (optional) - /// BulkClassifyResponse - public bool BulkClassify(Callback callback, string skillId, List input = null) - { - if (callback == null) - throw new ArgumentNullException("`callback` is required for `BulkClassify`"); - if (string.IsNullOrEmpty(skillId)) - throw new ArgumentNullException("`skillId` is required for `BulkClassify`"); - if (string.IsNullOrEmpty(Version)) - throw new ArgumentNullException("`Version` is required"); - - RequestObject req = new RequestObject - { - Callback = callback, - HttpMethod = UnityWebRequest.kHttpVerbPOST, - DisableSslVerification = DisableSslVerification - }; - - foreach (KeyValuePair kvp in customRequestHeaders) - { - req.Headers.Add(kvp.Key, kvp.Value); - } - - ClearCustomRequestHeaders(); - - foreach (KeyValuePair kvp in Common.GetSdkHeaders("conversation", "V2", "BulkClassify")) - { - req.Headers.Add(kvp.Key, kvp.Value); - } - - if (!string.IsNullOrEmpty(Version)) - { - req.Parameters["version"] = Version; - } - req.Headers["Content-Type"] = "application/json"; - req.Headers["Accept"] = "application/json"; - - JObject bodyObject = new JObject(); - if (input != null && input.Count > 0) - bodyObject["input"] = JToken.FromObject(input); - req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); - - req.OnResponse = OnBulkClassifyResponse; - - Connector.URL = GetServiceUrl() + string.Format("/v2/skills/{0}/workspace/bulk_classify", skillId); - Authenticator.Authenticate(Connector); - - return Connector.Send(req); - } - - private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp) - { - DetailedResponse response = new DetailedResponse(); - foreach (KeyValuePair kvp in resp.Headers) - { - response.Headers.Add(kvp.Key, kvp.Value); - } - response.StatusCode = resp.HttpResponseCode; - - try - { - string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); - response.Response = json; - } - catch (Exception e) - { - Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString()); - resp.Success = false; - } - - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); - } } } \ No newline at end of file diff --git a/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs b/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs new file mode 100644 index 000000000..94bdd2078 --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs @@ -0,0 +1,33 @@ +/** +* (C) Copyright IBM Corp. 2020. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V2.Model +{ + /// + /// AgentAvailabilityMessage. + /// + public class AgentAvailabilityMessage + { + /// + /// The text of the message. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs.meta b/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs.meta new file mode 100644 index 000000000..19232dd2e --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/AgentAvailabilityMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b50e6b9b43e264c1887a49e45fd0fff5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V2/Model/MessageContextSkillSystem.cs b/Scripts/Services/Assistant/V2/Model/MessageContextSkillSystem.cs index e57164b5c..58f702d62 100644 --- a/Scripts/Services/Assistant/V2/Model/MessageContextSkillSystem.cs +++ b/Scripts/Services/Assistant/V2/Model/MessageContextSkillSystem.cs @@ -23,7 +23,7 @@ namespace IBM.Watson.Assistant.V2.Model /// /// System context data used by the skill. /// - public class MessageContextSkillSystem: DynamicModel + public class MessageContextSkillSystem : DynamicModel { /// /// An encoded string that represents the current conversation state. By saving this value and then sending it diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs index 6a88f9237..58d3a5221 100644 --- a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs +++ b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs @@ -142,13 +142,13 @@ public class PreferenceValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public string AgentAvailable { get; protected set; } + public AgentAvailabilityMessage AgentAvailable { get; protected set; } /// /// An optional message to be displayed to the user to indicate that no online agent is available to take over /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public string AgentUnavailable { get; protected set; } + public AgentAvailabilityMessage AgentUnavailable { get; protected set; } /// /// Routing or other contextual information to be used by target service desk systems. /// diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs index d80904c61..45aef5190 100644 --- a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs +++ b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.cs @@ -51,7 +51,7 @@ public class ResponseTypeValue /// next available agent. /// [JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentAvailable + public new AgentAvailabilityMessage AgentAvailable { get { return base.AgentAvailable; } set { base.AgentAvailable = value; } @@ -61,7 +61,7 @@ public class ResponseTypeValue /// the conversation. /// [JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)] - public new string AgentUnavailable + public new AgentAvailabilityMessage AgentUnavailable { get { return base.AgentUnavailable; } set { base.AgentUnavailable = value; } diff --git a/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs b/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs index 9c93634da..cb0265a82 100644 --- a/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs +++ b/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs @@ -1,5 +1,5 @@ /** -* (C) Copyright IBM Corp. 2018, 2020. +* (C) Copyright IBM Corp. 2019, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ namespace IBM.Watson.Assistant.V2.Model /// An object containing segments of text from search results with query-matching text highlighted using HTML `` /// tags. /// - public class SearchResultHighlight: DynamicModel> + public class SearchResultHighlight : DynamicModel> { /// /// An array of strings containing segments taken from body text in the search results, with query-matching diff --git a/Tests/PersonalityInsightsV3IntegrationTests.cs b/Tests/PersonalityInsightsV3IntegrationTests.cs index 7dc2a1233..10f15796b 100644 --- a/Tests/PersonalityInsightsV3IntegrationTests.cs +++ b/Tests/PersonalityInsightsV3IntegrationTests.cs @@ -1,5 +1,5 @@ /** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* (C) Copyright IBM Corp. 2018, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Tests/ToneAnalyzerV3IntegrationTests.cs b/Tests/ToneAnalyzerV3IntegrationTests.cs index d0275cce0..979244a93 100644 --- a/Tests/ToneAnalyzerV3IntegrationTests.cs +++ b/Tests/ToneAnalyzerV3IntegrationTests.cs @@ -1,5 +1,5 @@ /** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* (C) Copyright IBM Corp. 2018, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.