From 1c4d441b4eada4ee455d446bd05ccfefbd1dd24a Mon Sep 17 00:00:00 2001 From: repjarms Date: Wed, 20 May 2020 12:50:37 -0400 Subject: [PATCH 01/13] feat(generated code): updates based on new api definitions --- Source/AssistantV1/Assistant.swift | 9 +- .../Models/DialogNodeOutputGeneric.swift | 14 +-- Source/AssistantV1/Models/MessageInput.swift | 62 +++++++++- .../Models/WorkspaceSystemSettings.swift | 26 +++- Source/AssistantV2/Assistant.swift | 99 +++++++++++++-- .../AssistantV2/Models/MessageContext.swift | 18 +-- .../Models/MessageContextGlobal.swift | 15 ++- .../MessageContextGlobalStateless.swift | 57 +++++++++ .../Models/MessageContextSkill.swift | 9 +- .../Models/MessageContextSkillSystem.swift | 75 ++++++++++++ .../Models/MessageContextSkills.swift | 44 +------ .../Models/MessageContextStateless.swift | 59 +++++++++ Source/AssistantV2/Models/MessageInput.swift | 22 ++-- .../Models/MessageInputOptions.swift | 39 +++--- .../Models/MessageInputOptionsSpelling.swift | 71 +++++++++++ .../Models/MessageInputOptionsStateless.swift | 82 +++++++++++++ .../Models/MessageInputStateless.swift | 105 ++++++++++++++++ Source/AssistantV2/Models/MessageOutput.swift | 8 +- .../Models/MessageOutputSpelling.swift | 49 ++++++++ .../AssistantV2/Models/MessageRequest.swift | 16 +-- .../Models/MessageRequestStateless.swift | 63 ++++++++++ .../AssistantV2/Models/MessageResponse.swift | 6 +- .../Models/MessageResponseStateless.swift | 41 +++++++ Source/AssistantV2/Models/SearchResult.swift | 4 +- .../Models/SearchResultHighlight.swift | 39 +----- Source/CompareComplyV1/CompareComply.swift | 9 +- Source/DiscoveryV1/Discovery.swift | 8 +- .../Models/AggregationResult.swift | 10 +- .../DiscoveryV1/Models/QueryAggregation.swift | 114 +++++------------- Source/DiscoveryV2/Discovery.swift | 13 +- .../DiscoveryV2/Models/QueryAggregation.swift | 93 ++------------ .../LanguageTranslator.swift | 9 +- .../NaturalLanguageClassifier.swift | 8 +- .../Models/CategoriesOptions.swift | 12 +- .../Models/MetadataOptions.swift | 6 +- .../Models/Model.swift | 8 +- .../NaturalLanguageUnderstanding.swift | 9 +- .../PersonalityInsights.swift | 18 ++- .../Models/SpeechRecognitionAlternative.swift | 6 +- Source/SpeechToTextV1/SpeechToText.swift | 16 +-- Source/TextToSpeechV1/TextToSpeech.swift | 58 +++------ Source/ToneAnalyzerV3/ToneAnalyzer.swift | 19 ++- .../VisualRecognition.swift | 48 ++++---- .../Models/ImageDetails.swift | 5 +- .../Models/ObjectTrainingStatus.swift | 11 +- .../VisualRecognition.swift | 90 ++++++++++++-- .../project.pbxproj | 36 ++++++ 47 files changed, 1176 insertions(+), 462 deletions(-) create mode 100644 Source/AssistantV2/Models/MessageContextGlobalStateless.swift create mode 100644 Source/AssistantV2/Models/MessageContextSkillSystem.swift create mode 100644 Source/AssistantV2/Models/MessageContextStateless.swift create mode 100644 Source/AssistantV2/Models/MessageInputOptionsSpelling.swift create mode 100644 Source/AssistantV2/Models/MessageInputOptionsStateless.swift create mode 100644 Source/AssistantV2/Models/MessageInputStateless.swift create mode 100644 Source/AssistantV2/Models/MessageOutputSpelling.swift create mode 100644 Source/AssistantV2/Models/MessageRequestStateless.swift create mode 100644 Source/AssistantV2/Models/MessageResponseStateless.swift diff --git a/Source/AssistantV1/Assistant.swift b/Source/AssistantV1/Assistant.swift index 14a6367ca..1ac8f0e25 100644 --- a/Source/AssistantV1/Assistant.swift +++ b/Source/AssistantV1/Assistant.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -54,10 +54,11 @@ public class Assistant { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift b/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift index 2e8ee6554..56202ae4c 100644 --- a/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift +++ b/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -131,8 +131,8 @@ public struct DialogNodeOutputGeneric: Codable, Equatable { /** The text of the search query. This can be either a natural-language query or a query that uses the Discovery query language syntax, depending on the value of the **query_type** property. For more information, see the [Discovery - service documentation](https://cloud.ibm.com/docs/discovery/query-operators.html#query-operators). Required when - **response_type**=`search_skill`. + service documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators). + Required when **response_type**=`search_skill`. */ public var query: String? @@ -144,7 +144,7 @@ public struct DialogNodeOutputGeneric: Codable, Equatable { /** An optional filter that narrows the set of documents to be searched. For more information, see the [Discovery service documentation]([Discovery service - documentation](https://cloud.ibm.com/docs/discovery/query-parameters.html#filter). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-parameters#filter). */ public var filter: String? @@ -204,12 +204,12 @@ public struct DialogNodeOutputGeneric: Codable, Equatable { - parameter query: The text of the search query. This can be either a natural-language query or a query that uses the Discovery query language syntax, depending on the value of the **query_type** property. For more information, see the [Discovery service - documentation](https://cloud.ibm.com/docs/discovery/query-operators.html#query-operators). Required when - **response_type**=`search_skill`. + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators). Required + when **response_type**=`search_skill`. - parameter queryType: The type of the search query. Required when **response_type**=`search_skill`. - parameter filter: An optional filter that narrows the set of documents to be searched. For more information, see the [Discovery service documentation]([Discovery service - documentation](https://cloud.ibm.com/docs/discovery/query-parameters.html#filter). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-parameters#filter). - parameter discoveryVersion: The version of the Discovery service API to use for the query. - returns: An initialized `DialogNodeOutputGeneric`. diff --git a/Source/AssistantV1/Models/MessageInput.swift b/Source/AssistantV1/Models/MessageInput.swift index 1ec174745..1b60c5985 100644 --- a/Source/AssistantV1/Models/MessageInput.swift +++ b/Source/AssistantV1/Models/MessageInput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2017, 2019. + * (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. @@ -27,13 +27,44 @@ public struct MessageInput: Codable, Equatable { */ public var text: String? + /** + Whether to use spelling correction when processing the input. This property overrides the value of the + **spelling_suggestions** property in the workspace settings. + */ + public var spellingSuggestions: Bool? + + /** + Whether to use autocorrection when processing the input. If spelling correction is used and this property is + `false`, any suggested corrections are returned in the **suggested_text** property of the message response. If this + property is `true`, any corrections are automatically applied to the user input, and the original text is returned + in the **original_text** property of the message response. This property overrides the value of the + **spelling_auto_correct** property in the workspace settings. + */ + public var spellingAutoCorrect: Bool? + + /** + Any suggested corrections of the input text. This property is returned only if spelling correction is enabled and + autocorrection is disabled. + */ + public var suggestedText: String? + + /** + The original user input text. This property is returned only if autocorrection is enabled and the user input was + corrected. + */ + public var originalText: String? + /// Additional properties associated with this model. public var additionalProperties: [String: JSON] // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case text = "text" - static let allValues = [text] + case spellingSuggestions = "spelling_suggestions" + case spellingAutoCorrect = "spelling_auto_correct" + case suggestedText = "suggested_text" + case originalText = "original_text" + static let allValues = [text, spellingSuggestions, spellingAutoCorrect, suggestedText, originalText] } /** @@ -41,21 +72,44 @@ public struct MessageInput: Codable, Equatable { - parameter text: The text of the user input. This string cannot contain carriage return, newline, or tab characters. + - parameter spellingSuggestions: Whether to use spelling correction when processing the input. This property + overrides the value of the **spelling_suggestions** property in the workspace settings. + - parameter spellingAutoCorrect: Whether to use autocorrection when processing the input. If spelling correction + is used and this property is `false`, any suggested corrections are returned in the **suggested_text** property + of the message response. If this property is `true`, any corrections are automatically applied to the user input, + and the original text is returned in the **original_text** property of the message response. This property + overrides the value of the **spelling_auto_correct** property in the workspace settings. + - parameter suggestedText: Any suggested corrections of the input text. This property is returned only if + spelling correction is enabled and autocorrection is disabled. + - parameter originalText: The original user input text. This property is returned only if autocorrection is + enabled and the user input was corrected. - returns: An initialized `MessageInput`. */ public init( text: String? = nil, + spellingSuggestions: Bool? = nil, + spellingAutoCorrect: Bool? = nil, + suggestedText: String? = nil, + originalText: String? = nil, additionalProperties: [String: JSON] = [:] ) { self.text = text + self.spellingSuggestions = spellingSuggestions + self.spellingAutoCorrect = spellingAutoCorrect + self.suggestedText = suggestedText + self.originalText = originalText self.additionalProperties = additionalProperties } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) text = try container.decodeIfPresent(String.self, forKey: .text) + spellingSuggestions = try container.decodeIfPresent(Bool.self, forKey: .spellingSuggestions) + spellingAutoCorrect = try container.decodeIfPresent(Bool.self, forKey: .spellingAutoCorrect) + suggestedText = try container.decodeIfPresent(String.self, forKey: .suggestedText) + originalText = try container.decodeIfPresent(String.self, forKey: .originalText) let dynamicContainer = try decoder.container(keyedBy: DynamicKeys.self) additionalProperties = try dynamicContainer.decode([String: JSON].self, excluding: CodingKeys.allValues) } @@ -63,6 +117,10 @@ public struct MessageInput: Codable, Equatable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(text, forKey: .text) + try container.encodeIfPresent(spellingSuggestions, forKey: .spellingSuggestions) + try container.encodeIfPresent(spellingAutoCorrect, forKey: .spellingAutoCorrect) + try container.encodeIfPresent(suggestedText, forKey: .suggestedText) + try container.encodeIfPresent(originalText, forKey: .originalText) var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self) try dynamicContainer.encodeIfPresent(additionalProperties) } diff --git a/Source/AssistantV1/Models/WorkspaceSystemSettings.swift b/Source/AssistantV1/Models/WorkspaceSystemSettings.swift index 0ad624045..65e375c58 100644 --- a/Source/AssistantV1/Models/WorkspaceSystemSettings.swift +++ b/Source/AssistantV1/Models/WorkspaceSystemSettings.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -38,6 +38,19 @@ public struct WorkspaceSystemSettings: Codable, Equatable { */ public var humanAgentAssist: [String: JSON]? + /** + Whether spelling correction is enabled for the workspace. + */ + public var spellingSuggestions: Bool? + + /** + Whether autocorrection is enabled for the workspace. If spelling correction is enabled and this property is + `false`, any suggested corrections are returned in the **suggested_text** property of the message response. If this + property is `true`, any corrections are automatically applied to the user input, and the original text is returned + in the **original_text** property of the message response. + */ + public var spellingAutoCorrect: Bool? + /** Workspace settings related to the behavior of system entities. */ @@ -53,6 +66,8 @@ public struct WorkspaceSystemSettings: Codable, Equatable { case tooling = "tooling" case disambiguation = "disambiguation" case humanAgentAssist = "human_agent_assist" + case spellingSuggestions = "spelling_suggestions" + case spellingAutoCorrect = "spelling_auto_correct" case systemEntities = "system_entities" case offTopic = "off_topic" } @@ -64,6 +79,11 @@ public struct WorkspaceSystemSettings: Codable, Equatable { - parameter disambiguation: Workspace settings related to the disambiguation feature. **Note:** This feature is available only to Plus and Premium users. - parameter humanAgentAssist: For internal use only. + - parameter spellingSuggestions: Whether spelling correction is enabled for the workspace. + - parameter spellingAutoCorrect: Whether autocorrection is enabled for the workspace. If spelling correction is + enabled and this property is `false`, any suggested corrections are returned in the **suggested_text** property + of the message response. If this property is `true`, any corrections are automatically applied to the user input, + and the original text is returned in the **original_text** property of the message response. - parameter systemEntities: Workspace settings related to the behavior of system entities. - parameter offTopic: Workspace settings related to detection of irrelevant input. @@ -73,6 +93,8 @@ public struct WorkspaceSystemSettings: Codable, Equatable { tooling: WorkspaceSystemSettingsTooling? = nil, disambiguation: WorkspaceSystemSettingsDisambiguation? = nil, humanAgentAssist: [String: JSON]? = nil, + spellingSuggestions: Bool? = nil, + spellingAutoCorrect: Bool? = nil, systemEntities: WorkspaceSystemSettingsSystemEntities? = nil, offTopic: WorkspaceSystemSettingsOffTopic? = nil ) @@ -80,6 +102,8 @@ public struct WorkspaceSystemSettings: Codable, Equatable { self.tooling = tooling self.disambiguation = disambiguation self.humanAgentAssist = humanAgentAssist + self.spellingSuggestions = spellingSuggestions + self.spellingAutoCorrect = spellingAutoCorrect self.systemEntities = systemEntities self.offTopic = offTopic } diff --git a/Source/AssistantV2/Assistant.swift b/Source/AssistantV2/Assistant.swift index 332afd12b..4b7e45c3e 100644 --- a/Source/AssistantV2/Assistant.swift +++ b/Source/AssistantV2/Assistant.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -55,10 +55,11 @@ public class Assistant { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -155,7 +156,6 @@ public class Assistant { let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "createSession") headerParameters.merge(sdkHeaders) { (_, new) in new } headerParameters["Accept"] = "application/json" - headerParameters["Content-Type"] = "application/json" // construct query parameters var queryParameters = [URLQueryItem]() @@ -249,9 +249,10 @@ public class Assistant { } /** - Send user input to assistant. + Send user input to assistant (stateful). - Send user input to an assistant and receive a response. + Send user input to an assistant and receive a response, with conversation state (including context data) stored by + Watson Assistant for the duration of the session. There is no rate limit for this operation. - parameter assistantID: Unique identifier of the assistant. To find the assistant ID in the Watson Assistant @@ -260,9 +261,10 @@ public class Assistant { **Note:** Currently, the v2 API does not support creating assistants. - parameter sessionID: Unique identifier of the session. - parameter input: An input object that includes the input text. - - parameter context: State information for the conversation. The context is stored by the assistant on a - per-session basis. You can use this property to set or modify context variables, which can also be accessed by - dialog nodes. + - parameter context: Context data for the conversation. You can use this property to set or modify context + variables, which can also be accessed by dialog nodes. The context is stored by the assistant on a per-session + basis. + **Note:** The total size of the context data stored for a stateful session cannot exceed 100KB. - parameter headers: A dictionary of request headers to be sent with this request. - parameter completionHandler: A function executed when the request completes with a successful result or error */ @@ -325,4 +327,81 @@ public class Assistant { request.responseObject(completionHandler: completionHandler) } + /** + Send user input to assistant (stateless). + + Send user input to an assistant and receive a response, with conversation state (including context data) managed by + your application. + There is no rate limit for this operation. + + - parameter assistantID: Unique identifier of the assistant. To find the assistant ID in the Watson Assistant + user interface, open the assistant settings and click **API Details**. For information about creating assistants, + see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). + **Note:** Currently, the v2 API does not support creating assistants. + - parameter input: An input object that includes the input text. + - parameter context: Context data for the conversation. You can use this property to set or modify context + variables, which can also be accessed by dialog nodes. The context is not stored by the assistant. To maintain + session state, include the context from the previous response. + **Note:** The total size of the context data for a stateless session cannot exceed 250KB. + - parameter headers: A dictionary of request headers to be sent with this request. + - parameter completionHandler: A function executed when the request completes with a successful result or error + */ + public func messageStateless( + assistantID: String, + input: MessageInputStateless? = nil, + context: MessageContextStateless? = nil, + headers: [String: String]? = nil, + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + { + // construct body + let messageStatelessRequest = MessageRequestStateless( + input: input, + context: context) + guard let body = try? JSON.encoder.encodeIfPresent(messageStatelessRequest) else { + completionHandler(nil, WatsonError.serialization(values: "request body")) + return + } + + // construct header parameters + var headerParameters = defaultHeaders + if let headers = headers { + headerParameters.merge(headers) { (_, new) in new } + } + let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "messageStateless") + headerParameters.merge(sdkHeaders) { (_, new) in new } + headerParameters["Accept"] = "application/json" + headerParameters["Content-Type"] = "application/json" + + // construct query parameters + var queryParameters = [URLQueryItem]() + queryParameters.append(URLQueryItem(name: "version", value: version)) + + // construct REST request + let path = "/v2/assistants/\(assistantID)/message" + guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { + completionHandler(nil, WatsonError.urlEncoding(path: path)) + return + } + + // ensure that serviceURL is set + guard let serviceEndpoint = serviceURL else { + completionHandler(nil, WatsonError.noEndpoint) + return + } + + let request = RestRequest( + session: session, + authenticator: authenticator, + errorResponseDecoder: errorResponseDecoder, + method: "POST", + url: serviceEndpoint + encodedPath, + headerParameters: headerParameters, + queryItems: queryParameters, + messageBody: body + ) + + // execute REST request + request.responseObject(completionHandler: completionHandler) + } + } diff --git a/Source/AssistantV2/Models/MessageContext.swift b/Source/AssistantV2/Models/MessageContext.swift index e187735c6..62af7fa0b 100644 --- a/Source/AssistantV2/Models/MessageContext.swift +++ b/Source/AssistantV2/Models/MessageContext.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -20,14 +20,14 @@ import Foundation public struct MessageContext: Codable, Equatable { /** - Information that is shared by all skills used by the Assistant. + Session context data that is shared by all skills used by the Assistant. */ public var global: MessageContextGlobal? /** - Information specific to particular skills used by the Assistant. - **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that - apply to the dialog skill used by the assistant. + Information specific to particular skills used by the assistant. + **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog skill + used by the assistant. */ public var skills: MessageContextSkills? @@ -40,10 +40,10 @@ public struct MessageContext: Codable, Equatable { /** Initialize a `MessageContext` with member variables. - - parameter global: Information that is shared by all skills used by the Assistant. - - parameter skills: Information specific to particular skills used by the Assistant. - **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that - apply to the dialog skill used by the assistant. + - parameter global: Session context data that is shared by all skills used by the Assistant. + - parameter skills: Information specific to particular skills used by the assistant. + **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog + skill used by the assistant. - returns: An initialized `MessageContext`. */ diff --git a/Source/AssistantV2/Models/MessageContextGlobal.swift b/Source/AssistantV2/Models/MessageContextGlobal.swift index 27f0a2782..ad2c5c0d3 100644 --- a/Source/AssistantV2/Models/MessageContextGlobal.swift +++ b/Source/AssistantV2/Models/MessageContextGlobal.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -17,7 +17,7 @@ import Foundation /** - Information that is shared by all skills used by the Assistant. + Session context data that is shared by all skills used by the Assistant. */ public struct MessageContextGlobal: Codable, Equatable { @@ -26,23 +26,32 @@ public struct MessageContextGlobal: Codable, Equatable { */ public var system: MessageContextGlobalSystem? + /** + The session ID. + */ + public var sessionID: String? + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case system = "system" + case sessionID = "session_id" } /** Initialize a `MessageContextGlobal` with member variables. - parameter system: Built-in system properties that apply to all skills used by the assistant. + - parameter sessionID: The session ID. - returns: An initialized `MessageContextGlobal`. */ public init( - system: MessageContextGlobalSystem? = nil + system: MessageContextGlobalSystem? = nil, + sessionID: String? = nil ) { self.system = system + self.sessionID = sessionID } } diff --git a/Source/AssistantV2/Models/MessageContextGlobalStateless.swift b/Source/AssistantV2/Models/MessageContextGlobalStateless.swift new file mode 100644 index 000000000..82ca3084d --- /dev/null +++ b/Source/AssistantV2/Models/MessageContextGlobalStateless.swift @@ -0,0 +1,57 @@ +/** + * (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. + **/ + +import Foundation + +/** + Session context data that is shared by all skills used by the Assistant. + */ +public struct MessageContextGlobalStateless: Codable, Equatable { + + /** + Built-in system properties that apply to all skills used by the assistant. + */ + public var system: MessageContextGlobalSystem? + + /** + The unique identifier of the session. + */ + public var sessionID: String? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case system = "system" + case sessionID = "session_id" + } + + /** + Initialize a `MessageContextGlobalStateless` with member variables. + + - parameter system: Built-in system properties that apply to all skills used by the assistant. + - parameter sessionID: The unique identifier of the session. + + - returns: An initialized `MessageContextGlobalStateless`. + */ + public init( + system: MessageContextGlobalSystem? = nil, + sessionID: String? = nil + ) + { + self.system = system + self.sessionID = sessionID + } + +} diff --git a/Source/AssistantV2/Models/MessageContextSkill.swift b/Source/AssistantV2/Models/MessageContextSkill.swift index 023f8a7d0..66cb6006d 100644 --- a/Source/AssistantV2/Models/MessageContextSkill.swift +++ b/Source/AssistantV2/Models/MessageContextSkill.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019, 2020. + * (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. @@ -18,7 +18,8 @@ import Foundation import IBMSwiftSDKCore /** - Contains information specific to a particular skill used by the Assistant. + Contains information specific to a particular skill used by the Assistant. The property name must be the same as the + name of the skill (for example, `main skill`). */ public struct MessageContextSkill: Codable, Equatable { @@ -30,7 +31,7 @@ public struct MessageContextSkill: Codable, Equatable { /** System context data used by the skill. */ - public var system: [String: JSON]? + public var system: MessageContextSkillSystem? // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { @@ -48,7 +49,7 @@ public struct MessageContextSkill: Codable, Equatable { */ public init( userDefined: [String: JSON]? = nil, - system: [String: JSON]? = nil + system: MessageContextSkillSystem? = nil ) { self.userDefined = userDefined diff --git a/Source/AssistantV2/Models/MessageContextSkillSystem.swift b/Source/AssistantV2/Models/MessageContextSkillSystem.swift new file mode 100644 index 000000000..d6fd8201e --- /dev/null +++ b/Source/AssistantV2/Models/MessageContextSkillSystem.swift @@ -0,0 +1,75 @@ +/** + * (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. + **/ + +import Foundation +import IBMSwiftSDKCore + +/** + System context data used by the skill. + */ +public struct MessageContextSkillSystem: Codable, Equatable { + + /** + An encoded string representing the current conversation state. By saving this value and then sending it in the + context of a subsequent message request, you can restore the conversation to the same state. This can be useful if + you need to return to an earlier point in the conversation. If you are using stateful sessions, you can also use a + stored state value to restore a paused conversation whose session has expired. + */ + public var state: String? + + /// Additional properties associated with this model. + public var additionalProperties: [String: JSON] + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case state = "state" + static let allValues = [state] + } + + /** + Initialize a `MessageContextSkillSystem` with member variables. + + - parameter state: An encoded string representing the current conversation state. By saving this value and then + sending it in the context of a subsequent message request, you can restore the conversation to the same state. + This can be useful if you need to return to an earlier point in the conversation. If you are using stateful + sessions, you can also use a stored state value to restore a paused conversation whose session has expired. + + - returns: An initialized `MessageContextSkillSystem`. + */ + public init( + state: String? = nil, + additionalProperties: [String: JSON] = [:] + ) + { + self.state = state + self.additionalProperties = additionalProperties + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + state = try container.decodeIfPresent(String.self, forKey: .state) + let dynamicContainer = try decoder.container(keyedBy: DynamicKeys.self) + additionalProperties = try dynamicContainer.decode([String: JSON].self, excluding: CodingKeys.allValues) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(state, forKey: .state) + var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self) + try dynamicContainer.encodeIfPresent(additionalProperties) + } + +} diff --git a/Source/AssistantV2/Models/MessageContextSkills.swift b/Source/AssistantV2/Models/MessageContextSkills.swift index 3edc04e7d..6ccaf71b6 100644 --- a/Source/AssistantV2/Models/MessageContextSkills.swift +++ b/Source/AssistantV2/Models/MessageContextSkills.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -18,9 +18,9 @@ import Foundation import IBMSwiftSDKCore /** - Information specific to particular skills used by the Assistant. - **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that apply - to the dialog skill used by the assistant. + Information specific to particular skills used by the assistant. + **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog skill + used by the assistant. */ public struct MessageContextSkills: Codable, Equatable { @@ -50,39 +50,3 @@ public struct MessageContextSkills: Codable, Equatable { } } - -public extension KeyedDecodingContainer where Key == DynamicKeys { - - /// Decode additional properties. - func decode(_ type: [String: MessageContextSkill].Type, excluding keys: [CodingKey]) throws -> [String: MessageContextSkill] { - var retval: [String: MessageContextSkill] = [:] - try self.allKeys.forEach { key in - if !keys.contains{ $0.stringValue == key.stringValue} { - let value = try self.decode(MessageContextSkill.self, forKey: key) - retval[key.stringValue] = value - } - } - return retval - } -} - -public extension KeyedEncodingContainer where Key == DynamicKeys { - - /// Encode additional properties. - mutating func encode(_ additionalProperties: [String: MessageContextSkill]) throws { - try additionalProperties.forEach { key, value in - guard let codingKey = DynamicKeys(stringValue: key) else { - let description = "Cannot construct CodingKey for \(key)" - let context = EncodingError.Context(codingPath: codingPath, debugDescription: description) - throw EncodingError.invalidValue(key, context) - } - try self.encode(value, forKey: codingKey) - } - } - - /// Encode additional properties if they are not nil. - mutating func encodeIfPresent(_ additionalProperties: [String: MessageContextSkill]?) throws { - guard let additionalProperties = additionalProperties else { return } - try encode(additionalProperties) - } -} diff --git a/Source/AssistantV2/Models/MessageContextStateless.swift b/Source/AssistantV2/Models/MessageContextStateless.swift new file mode 100644 index 000000000..bf7a458c0 --- /dev/null +++ b/Source/AssistantV2/Models/MessageContextStateless.swift @@ -0,0 +1,59 @@ +/** + * (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. + **/ + +import Foundation + +/** MessageContextStateless. */ +public struct MessageContextStateless: Codable, Equatable { + + /** + Session context data that is shared by all skills used by the Assistant. + */ + public var global: MessageContextGlobalStateless? + + /** + Information specific to particular skills used by the assistant. + **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog skill + used by the assistant. + */ + public var skills: MessageContextSkills? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case global = "global" + case skills = "skills" + } + + /** + Initialize a `MessageContextStateless` with member variables. + + - parameter global: Session context data that is shared by all skills used by the Assistant. + - parameter skills: Information specific to particular skills used by the assistant. + **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog + skill used by the assistant. + + - returns: An initialized `MessageContextStateless`. + */ + public init( + global: MessageContextGlobalStateless? = nil, + skills: MessageContextSkills? = nil + ) + { + self.global = global + self.skills = skills + } + +} diff --git a/Source/AssistantV2/Models/MessageInput.swift b/Source/AssistantV2/Models/MessageInput.swift index 7a5324f7c..86cdff696 100644 --- a/Source/AssistantV2/Models/MessageInput.swift +++ b/Source/AssistantV2/Models/MessageInput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -38,11 +38,6 @@ public struct MessageInput: Codable, Equatable { */ public var text: String? - /** - Optional properties that control how the assistant responds. - */ - public var options: MessageInputOptions? - /** Intents to use when evaluating the user input. Include intents from the previous response to continue using those intents rather than trying to recognize intents in the new input. @@ -60,14 +55,19 @@ public struct MessageInput: Codable, Equatable { */ public var suggestionID: String? + /** + Optional properties that control how the assistant responds. + */ + public var options: MessageInputOptions? + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case messageType = "message_type" case text = "text" - case options = "options" case intents = "intents" case entities = "entities" case suggestionID = "suggestion_id" + case options = "options" } /** @@ -76,30 +76,30 @@ public struct MessageInput: Codable, Equatable { - parameter messageType: The type of user input. Currently, only text input is supported. - parameter text: The text of the user input. This string cannot contain carriage return, newline, or tab characters. - - parameter options: Optional properties that control how the assistant responds. - parameter intents: Intents to use when evaluating the user input. Include intents from the previous response to continue using those intents rather than trying to recognize intents in the new input. - parameter entities: Entities to use when evaluating the message. Include entities from the previous response to continue using those entities rather than detecting entities in the new input. - parameter suggestionID: For internal use only. + - parameter options: Optional properties that control how the assistant responds. - returns: An initialized `MessageInput`. */ public init( messageType: String? = nil, text: String? = nil, - options: MessageInputOptions? = nil, intents: [RuntimeIntent]? = nil, entities: [RuntimeEntity]? = nil, - suggestionID: String? = nil + suggestionID: String? = nil, + options: MessageInputOptions? = nil ) { self.messageType = messageType self.text = text - self.options = options self.intents = intents self.entities = entities self.suggestionID = suggestionID + self.options = options } } diff --git a/Source/AssistantV2/Models/MessageInputOptions.swift b/Source/AssistantV2/Models/MessageInputOptions.swift index a2e61d07d..819c7e9aa 100644 --- a/Source/AssistantV2/Models/MessageInputOptions.swift +++ b/Source/AssistantV2/Models/MessageInputOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -21,13 +21,6 @@ import Foundation */ public struct MessageInputOptions: Codable, Equatable { - /** - Whether to return additional diagnostic information. Set to `true` to return additional information in the - `output.debug` property. If you also specify **return_context**=`true`, the returned skill context includes the - `system.state` property. - */ - public var debug: Bool? - /** Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. **Note:** This does not affect `turn_count` or any other context variables. @@ -39,6 +32,19 @@ public struct MessageInputOptions: Codable, Equatable { */ public var alternateIntents: Bool? + /** + Spelling correction options for the message. Any options specified on an individual message override the settings + configured for the skill. + */ + public var spelling: MessageInputOptionsSpelling? + + /** + Whether to return additional diagnostic information. Set to `true` to return additional information in the + `output.debug` property. If you also specify **return_context**=`true`, the returned skill context includes the + `system.state` property. + */ + public var debug: Bool? + /** Whether to return session context with the response. If you specify `true`, the response includes the `context` property. If you also specify **debug**=`true`, the returned skill context includes the `system.state` property. @@ -54,9 +60,10 @@ public struct MessageInputOptions: Codable, Equatable { // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { - case debug = "debug" case restart = "restart" case alternateIntents = "alternate_intents" + case spelling = "spelling" + case debug = "debug" case returnContext = "return_context" case export = "export" } @@ -64,13 +71,15 @@ public struct MessageInputOptions: Codable, Equatable { /** Initialize a `MessageInputOptions` with member variables. - - parameter debug: Whether to return additional diagnostic information. Set to `true` to return additional - information in the `output.debug` property. If you also specify **return_context**=`true`, the returned skill - context includes the `system.state` property. - parameter restart: Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. **Note:** This does not affect `turn_count` or any other context variables. - parameter alternateIntents: Whether to return more than one intent. Set to `true` to return all matching intents. + - parameter spelling: Spelling correction options for the message. Any options specified on an individual + message override the settings configured for the skill. + - parameter debug: Whether to return additional diagnostic information. Set to `true` to return additional + information in the `output.debug` property. If you also specify **return_context**=`true`, the returned skill + context includes the `system.state` property. - parameter returnContext: Whether to return session context with the response. If you specify `true`, the response includes the `context` property. If you also specify **debug**=`true`, the returned skill context includes the `system.state` property. @@ -81,16 +90,18 @@ public struct MessageInputOptions: Codable, Equatable { - returns: An initialized `MessageInputOptions`. */ public init( - debug: Bool? = nil, restart: Bool? = nil, alternateIntents: Bool? = nil, + spelling: MessageInputOptionsSpelling? = nil, + debug: Bool? = nil, returnContext: Bool? = nil, export: Bool? = nil ) { - self.debug = debug self.restart = restart self.alternateIntents = alternateIntents + self.spelling = spelling + self.debug = debug self.returnContext = returnContext self.export = export } diff --git a/Source/AssistantV2/Models/MessageInputOptionsSpelling.swift b/Source/AssistantV2/Models/MessageInputOptionsSpelling.swift new file mode 100644 index 000000000..4a2d0f5ca --- /dev/null +++ b/Source/AssistantV2/Models/MessageInputOptionsSpelling.swift @@ -0,0 +1,71 @@ +/** + * (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. + **/ + +import Foundation + +/** + Spelling correction options for the message. Any options specified on an individual message override the settings + configured for the skill. + */ +public struct MessageInputOptionsSpelling: Codable, Equatable { + + /** + Whether to use spelling correction when processing the input. If spelling correction is used and **auto_correct** + is `true`, any spelling corrections are automatically applied to the user input. If **auto_correct** is `false`, + any suggested corrections are returned in the **output.spelling** property. + This property overrides the value of the **spelling_suggestions** property in the workspace settings for the skill. + */ + public var suggestions: Bool? + + /** + Whether to use autocorrection when processing the input. If this property is `true`, any corrections are + automatically applied to the user input, and the original text is returned in the **output.spelling** property of + the message response. This property overrides the value of the **spelling_auto_correct** property in the workspace + settings for the skill. + */ + public var autoCorrect: Bool? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case suggestions = "suggestions" + case autoCorrect = "auto_correct" + } + + /** + Initialize a `MessageInputOptionsSpelling` with member variables. + + - parameter suggestions: Whether to use spelling correction when processing the input. If spelling correction is + used and **auto_correct** is `true`, any spelling corrections are automatically applied to the user input. If + **auto_correct** is `false`, any suggested corrections are returned in the **output.spelling** property. + This property overrides the value of the **spelling_suggestions** property in the workspace settings for the + skill. + - parameter autoCorrect: Whether to use autocorrection when processing the input. If this property is `true`, + any corrections are automatically applied to the user input, and the original text is returned in the + **output.spelling** property of the message response. This property overrides the value of the + **spelling_auto_correct** property in the workspace settings for the skill. + + - returns: An initialized `MessageInputOptionsSpelling`. + */ + public init( + suggestions: Bool? = nil, + autoCorrect: Bool? = nil + ) + { + self.suggestions = suggestions + self.autoCorrect = autoCorrect + } + +} diff --git a/Source/AssistantV2/Models/MessageInputOptionsStateless.swift b/Source/AssistantV2/Models/MessageInputOptionsStateless.swift new file mode 100644 index 000000000..53b15200f --- /dev/null +++ b/Source/AssistantV2/Models/MessageInputOptionsStateless.swift @@ -0,0 +1,82 @@ +/** + * (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. + **/ + +import Foundation + +/** + Optional properties that control how the assistant responds. + */ +public struct MessageInputOptionsStateless: Codable, Equatable { + + /** + Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. + **Note:** This does not affect `turn_count` or any other context variables. + */ + public var restart: Bool? + + /** + Whether to return more than one intent. Set to `true` to return all matching intents. + */ + public var alternateIntents: Bool? + + /** + Spelling correction options for the message. Any options specified on an individual message override the settings + configured for the skill. + */ + public var spelling: MessageInputOptionsSpelling? + + /** + Whether to return additional diagnostic information. Set to `true` to return additional information in the + `output.debug` property. + */ + public var debug: Bool? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case restart = "restart" + case alternateIntents = "alternate_intents" + case spelling = "spelling" + case debug = "debug" + } + + /** + Initialize a `MessageInputOptionsStateless` with member variables. + + - parameter restart: Whether to restart dialog processing at the root of the dialog, regardless of any + previously visited nodes. **Note:** This does not affect `turn_count` or any other context variables. + - parameter alternateIntents: Whether to return more than one intent. Set to `true` to return all matching + intents. + - parameter spelling: Spelling correction options for the message. Any options specified on an individual + message override the settings configured for the skill. + - parameter debug: Whether to return additional diagnostic information. Set to `true` to return additional + information in the `output.debug` property. + + - returns: An initialized `MessageInputOptionsStateless`. + */ + public init( + restart: Bool? = nil, + alternateIntents: Bool? = nil, + spelling: MessageInputOptionsSpelling? = nil, + debug: Bool? = nil + ) + { + self.restart = restart + self.alternateIntents = alternateIntents + self.spelling = spelling + self.debug = debug + } + +} diff --git a/Source/AssistantV2/Models/MessageInputStateless.swift b/Source/AssistantV2/Models/MessageInputStateless.swift new file mode 100644 index 000000000..4fc0e8df4 --- /dev/null +++ b/Source/AssistantV2/Models/MessageInputStateless.swift @@ -0,0 +1,105 @@ +/** + * (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. + **/ + +import Foundation + +/** + An input object that includes the input text. + */ +public struct MessageInputStateless: Codable, Equatable { + + /** + The type of user input. Currently, only text input is supported. + */ + public enum MessageType: String { + case text = "text" + } + + /** + The type of user input. Currently, only text input is supported. + */ + public var messageType: String? + + /** + The text of the user input. This string cannot contain carriage return, newline, or tab characters. + */ + public var text: String? + + /** + Intents to use when evaluating the user input. Include intents from the previous response to continue using those + intents rather than trying to recognize intents in the new input. + */ + public var intents: [RuntimeIntent]? + + /** + Entities to use when evaluating the message. Include entities from the previous response to continue using those + entities rather than detecting entities in the new input. + */ + public var entities: [RuntimeEntity]? + + /** + For internal use only. + */ + public var suggestionID: String? + + /** + Optional properties that control how the assistant responds. + */ + public var options: MessageInputOptionsStateless? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case messageType = "message_type" + case text = "text" + case intents = "intents" + case entities = "entities" + case suggestionID = "suggestion_id" + case options = "options" + } + + /** + Initialize a `MessageInputStateless` with member variables. + + - parameter messageType: The type of user input. Currently, only text input is supported. + - parameter text: The text of the user input. This string cannot contain carriage return, newline, or tab + characters. + - parameter intents: Intents to use when evaluating the user input. Include intents from the previous response + to continue using those intents rather than trying to recognize intents in the new input. + - parameter entities: Entities to use when evaluating the message. Include entities from the previous response + to continue using those entities rather than detecting entities in the new input. + - parameter suggestionID: For internal use only. + - parameter options: Optional properties that control how the assistant responds. + + - returns: An initialized `MessageInputStateless`. + */ + public init( + messageType: String? = nil, + text: String? = nil, + intents: [RuntimeIntent]? = nil, + entities: [RuntimeEntity]? = nil, + suggestionID: String? = nil, + options: MessageInputOptionsStateless? = nil + ) + { + self.messageType = messageType + self.text = text + self.intents = intents + self.entities = entities + self.suggestionID = suggestionID + self.options = options + } + +} diff --git a/Source/AssistantV2/Models/MessageOutput.swift b/Source/AssistantV2/Models/MessageOutput.swift index 1b954ed9f..b13b15b3a 100644 --- a/Source/AssistantV2/Models/MessageOutput.swift +++ b/Source/AssistantV2/Models/MessageOutput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -54,6 +54,11 @@ public struct MessageOutput: Codable, Equatable { */ public var userDefined: [String: JSON]? + /** + Properties describing any spelling corrections in the user input that was received. + */ + public var spelling: MessageOutputSpelling? + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case generic = "generic" @@ -62,6 +67,7 @@ public struct MessageOutput: Codable, Equatable { case actions = "actions" case debug = "debug" case userDefined = "user_defined" + case spelling = "spelling" } } diff --git a/Source/AssistantV2/Models/MessageOutputSpelling.swift b/Source/AssistantV2/Models/MessageOutputSpelling.swift new file mode 100644 index 000000000..c99f383b7 --- /dev/null +++ b/Source/AssistantV2/Models/MessageOutputSpelling.swift @@ -0,0 +1,49 @@ +/** + * (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. + **/ + +import Foundation + +/** + Properties describing any spelling corrections in the user input that was received. + */ +public struct MessageOutputSpelling: Codable, Equatable { + + /** + The user input text that was used to generate the response. If spelling autocorrection is enabled, this text + reflects any spelling corrections that were applied. + */ + public var text: String? + + /** + The original user input text. This property is returned only if autocorrection is enabled and the user input was + corrected. + */ + public var originalText: String? + + /** + Any suggested corrections of the input text. This property is returned only if spelling correction is enabled and + autocorrection is disabled. + */ + public var suggestedText: String? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case text = "text" + case originalText = "original_text" + case suggestedText = "suggested_text" + } + +} diff --git a/Source/AssistantV2/Models/MessageRequest.swift b/Source/AssistantV2/Models/MessageRequest.swift index 7f31e38d2..78de03d3e 100644 --- a/Source/AssistantV2/Models/MessageRequest.swift +++ b/Source/AssistantV2/Models/MessageRequest.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -17,7 +17,7 @@ import Foundation /** - A request formatted for the Watson Assistant service. + A stateful message request formatted for the Watson Assistant service. */ internal struct MessageRequest: Codable, Equatable { @@ -27,8 +27,9 @@ internal struct MessageRequest: Codable, Equatable { public var input: MessageInput? /** - State information for the conversation. The context is stored by the assistant on a per-session basis. You can use - this property to set or modify context variables, which can also be accessed by dialog nodes. + Context data for the conversation. You can use this property to set or modify context variables, which can also be + accessed by dialog nodes. The context is stored by the assistant on a per-session basis. + **Note:** The total size of the context data stored for a stateful session cannot exceed 100KB. */ public var context: MessageContext? @@ -42,9 +43,10 @@ internal struct MessageRequest: Codable, Equatable { Initialize a `MessageRequest` with member variables. - parameter input: An input object that includes the input text. - - parameter context: State information for the conversation. The context is stored by the assistant on a - per-session basis. You can use this property to set or modify context variables, which can also be accessed by - dialog nodes. + - parameter context: Context data for the conversation. You can use this property to set or modify context + variables, which can also be accessed by dialog nodes. The context is stored by the assistant on a per-session + basis. + **Note:** The total size of the context data stored for a stateful session cannot exceed 100KB. - returns: An initialized `MessageRequest`. */ diff --git a/Source/AssistantV2/Models/MessageRequestStateless.swift b/Source/AssistantV2/Models/MessageRequestStateless.swift new file mode 100644 index 000000000..6dc075f9c --- /dev/null +++ b/Source/AssistantV2/Models/MessageRequestStateless.swift @@ -0,0 +1,63 @@ +/** + * (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. + **/ + +import Foundation + +/** + A stateless message request formatted for the Watson Assistant service. + */ +internal struct MessageRequestStateless: Codable, Equatable { + + /** + An input object that includes the input text. + */ + public var input: MessageInputStateless? + + /** + Context data for the conversation. You can use this property to set or modify context variables, which can also be + accessed by dialog nodes. The context is not stored by the assistant. To maintain session state, include the + context from the previous response. + **Note:** The total size of the context data for a stateless session cannot exceed 250KB. + */ + public var context: MessageContextStateless? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case input = "input" + case context = "context" + } + + /** + Initialize a `MessageRequestStateless` with member variables. + + - parameter input: An input object that includes the input text. + - parameter context: Context data for the conversation. You can use this property to set or modify context + variables, which can also be accessed by dialog nodes. The context is not stored by the assistant. To maintain + session state, include the context from the previous response. + **Note:** The total size of the context data for a stateless session cannot exceed 250KB. + + - returns: An initialized `MessageRequestStateless`. + */ + public init( + input: MessageInputStateless? = nil, + context: MessageContextStateless? = nil + ) + { + self.input = input + self.context = context + } + +} diff --git a/Source/AssistantV2/Models/MessageResponse.swift b/Source/AssistantV2/Models/MessageResponse.swift index 271c60e9b..d6b2ac0c4 100644 --- a/Source/AssistantV2/Models/MessageResponse.swift +++ b/Source/AssistantV2/Models/MessageResponse.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -27,8 +27,8 @@ public struct MessageResponse: Codable, Equatable { public var output: MessageOutput /** - Context data for the conversation. The context is stored by the assistant on a per-session basis. You can use this - property to access context variables. + Context data for the conversation. You can use this property to access context variables. The context is stored by + the assistant on a per-session basis. **Note:** The context is included in message responses only if **return_context**=`true` in the message request. */ public var context: MessageContext? diff --git a/Source/AssistantV2/Models/MessageResponseStateless.swift b/Source/AssistantV2/Models/MessageResponseStateless.swift new file mode 100644 index 000000000..1efc115dc --- /dev/null +++ b/Source/AssistantV2/Models/MessageResponseStateless.swift @@ -0,0 +1,41 @@ +/** + * (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. + **/ + +import Foundation + +/** + A stateless response from the Watson Assistant service. + */ +public struct MessageResponseStateless: Codable, Equatable { + + /** + Assistant output to be rendered or processed by the client. + */ + public var output: MessageOutput + + /** + Context data for the conversation. You can use this property to access context variables. The context is not stored + by the assistant; to maintain session state, include the context from the response in the next message. + */ + public var context: MessageContextStateless + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case output = "output" + case context = "context" + } + +} diff --git a/Source/AssistantV2/Models/SearchResult.swift b/Source/AssistantV2/Models/SearchResult.swift index ab6ad5be4..6eb48c35f 100644 --- a/Source/AssistantV2/Models/SearchResult.swift +++ b/Source/AssistantV2/Models/SearchResult.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019. + * (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. @@ -49,7 +49,7 @@ public struct SearchResult: Codable, Equatable { public var url: String? /** - An object containing segments of text from search results with query-matching text highlighted using HTML + An object containing segments of text from search results with query-matching text highlighted using HTML `` tags. */ public var highlight: SearchResultHighlight? diff --git a/Source/AssistantV2/Models/SearchResultHighlight.swift b/Source/AssistantV2/Models/SearchResultHighlight.swift index 82735e58c..1e32f39d3 100644 --- a/Source/AssistantV2/Models/SearchResultHighlight.swift +++ b/Source/AssistantV2/Models/SearchResultHighlight.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019. + * (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. @@ -18,7 +18,7 @@ import Foundation import IBMSwiftSDKCore /** - An object containing segments of text from search results with query-matching text highlighted using HTML tags. + An object containing segments of text from search results with query-matching text highlighted using HTML `` tags. */ public struct SearchResultHighlight: Codable, Equatable { @@ -68,40 +68,5 @@ public struct SearchResultHighlight: Codable, Equatable { var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self) try dynamicContainer.encodeIfPresent(additionalProperties) } -} - -public extension KeyedDecodingContainer where Key == DynamicKeys { - - /// Decode additional properties. - func decode(_ type: [String: [String]].Type, excluding keys: [CodingKey]) throws -> [String: [String]] { - var retval: [String: [String]] = [:] - try self.allKeys.forEach { key in - if !keys.contains{ $0.stringValue == key.stringValue} { - let value = try self.decode([String].self, forKey: key) - retval[key.stringValue] = value - } - } - return retval - } -} -public extension KeyedEncodingContainer where Key == DynamicKeys { - - /// Encode additional properties. - mutating func encode(_ additionalProperties: [String: [String]]) throws { - try additionalProperties.forEach { key, value in - guard let codingKey = DynamicKeys(stringValue: key) else { - let description = "Cannot construct CodingKey for \(key)" - let context = EncodingError.Context(codingPath: codingPath, debugDescription: description) - throw EncodingError.invalidValue(key, context) - } - try self.encode(value, forKey: codingKey) - } - } - - /// Encode additional properties if they are not nil. - mutating func encodeIfPresent(_ additionalProperties: [String: [String]]?) throws { - guard let additionalProperties = additionalProperties else { return } - try encode(additionalProperties) - } } diff --git a/Source/CompareComplyV1/CompareComply.swift b/Source/CompareComplyV1/CompareComply.swift index 70222dded..78b2d31c2 100644 --- a/Source/CompareComplyV1/CompareComply.swift +++ b/Source/CompareComplyV1/CompareComply.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -53,10 +53,11 @@ public class CompareComply { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/DiscoveryV1/Discovery.swift b/Source/DiscoveryV1/Discovery.swift index 2dce3d4c2..fef4cfefd 100644 --- a/Source/DiscoveryV1/Discovery.swift +++ b/Source/DiscoveryV1/Discovery.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -55,9 +55,11 @@ public class Discovery { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/DiscoveryV1/Models/AggregationResult.swift b/Source/DiscoveryV1/Models/AggregationResult.swift index 98da230f2..e60b5d8c6 100644 --- a/Source/DiscoveryV1/Models/AggregationResult.swift +++ b/Source/DiscoveryV1/Models/AggregationResult.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2019. + * (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. @@ -43,12 +43,4 @@ public struct AggregationResult: Codable, Equatable { case aggregations = "aggregations" } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - if let keyAsString = try? container.decode(String.self, forKey: .key) { key = keyAsString } - if let keyAsInt = try? container.decode(Int.self, forKey: .key) { key = "\(keyAsInt)" } - matchingResults = try container.decodeIfPresent(Int.self, forKey: .matchingResults) - aggregations = try container.decodeIfPresent([QueryAggregation].self, forKey: .aggregations) - } - } diff --git a/Source/DiscoveryV1/Models/QueryAggregation.swift b/Source/DiscoveryV1/Models/QueryAggregation.swift index 2794f53a8..5f88c5081 100644 --- a/Source/DiscoveryV1/Models/QueryAggregation.swift +++ b/Source/DiscoveryV1/Models/QueryAggregation.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018. + * (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. @@ -16,91 +16,37 @@ import Foundation -/** An aggregation produced by the Discovery service to analyze the input provided. */ -public enum QueryAggregation: Codable, Equatable { - - // reference: https://cloud.ibm.com/docs/services/discovery/query-reference.html#aggregations - - case term(Term) - case filter(Filter) - case nested(Nested) - case histogram(Histogram) - case timeslice(Timeslice) - case topHits(TopHits) - case uniqueCount(Calculation) - case max(Calculation) - case min(Calculation) - case average(Calculation) - case sum(Calculation) - case generic(GenericQueryAggregation) - +/** + An aggregation produced by Discovery to analyze the input provided. + */ +public struct QueryAggregation: Codable, Equatable { + + /** + The type of aggregation command used. For example: term, filter, max, min, etc. + */ + public var type: String? + + /** + Array of aggregation results. + */ + public var results: [AggregationResult]? + + /** + Number of matching results. + */ + public var matchingResults: Int? + + /** + Aggregations returned by Discovery. + */ + public var aggregations: [QueryAggregation]? + + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case type = "type" - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - guard let type = try container.decodeIfPresent(String.self, forKey: .type) else { - // the specification does not identify `type` as a required field, - // so we need a generic catch-all in case it is not present - self = .generic(try GenericQueryAggregation(from: decoder)) - return - } - switch type { - case "term": self = .term(try Term(from: decoder)) - case "filter": self = .filter(try Filter(from: decoder)) - case "nested": self = .nested(try Nested(from: decoder)) - case "histogram": self = .histogram(try Histogram(from: decoder)) - case "timeslice": self = .timeslice(try Timeslice(from: decoder)) - case "top_hits": self = .topHits(try TopHits(from: decoder)) - case "unique_count": self = .uniqueCount(try Calculation(from: decoder)) - case "max": self = .max(try Calculation(from: decoder)) - case "min": self = .min(try Calculation(from: decoder)) - case "average": self = .average(try Calculation(from: decoder)) - case "sum": self = .sum(try Calculation(from: decoder)) - default: self = .generic(try GenericQueryAggregation(from: decoder)) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - switch self { - case .term(let term): - try container.encode("term", forKey: .type) - try term.encode(to: encoder) - case .filter(let filter): - try container.encode("filter", forKey: .type) - try filter.encode(to: encoder) - case .nested(let nested): - try container.encode("nested", forKey: .type) - try nested.encode(to: encoder) - case .histogram(let histogram): - try container.encode("histogram", forKey: .type) - try histogram.encode(to: encoder) - case .timeslice(let timeslice): - try container.encode("timeslice", forKey: .type) - try timeslice.encode(to: encoder) - case .topHits(let topHits): - try container.encode("top_hits", forKey: .type) - try topHits.encode(to: encoder) - case .uniqueCount(let uniqueCount): - try container.encode("unique_count", forKey: .type) - try uniqueCount.encode(to: encoder) - case .max(let max): - try container.encode("max", forKey: .type) - try max.encode(to: encoder) - case .min(let min): - try container.encode("min", forKey: .type) - try min.encode(to: encoder) - case .average(let average): - try container.encode("average", forKey: .type) - try average.encode(to: encoder) - case .sum(let sum): - try container.encode("sum", forKey: .type) - try sum.encode(to: encoder) - case .generic(let generic): - try generic.encode(to: encoder) - } + case results = "results" + case matchingResults = "matching_results" + case aggregations = "aggregations" } } diff --git a/Source/DiscoveryV2/Discovery.swift b/Source/DiscoveryV2/Discovery.swift index 5511ea972..403499b46 100644 --- a/Source/DiscoveryV2/Discovery.swift +++ b/Source/DiscoveryV2/Discovery.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019, 2020. + * (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. @@ -55,10 +55,11 @@ public class Discovery { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -710,6 +711,8 @@ public class Discovery { same **document_id** if it exists. **Note:** This operation only works on collections created to accept direct file uploads. It cannot be used to modify a collection that connects to an external source such as Microsoft SharePoint. + **Note:** If an uploaded document is segmented, all segments will be overwritten, even if the updated version of + the document has fewer segments. - parameter projectID: The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. @@ -809,6 +812,8 @@ public class Discovery { status code `200`) with the status set to 'deleted'. **Note:** This operation only works on collections created to accept direct file uploads. It cannot be used to modify a collection that connects to an external source such as Microsoft SharePoint. + **Note:** Segments of an uploaded document cannot be deleted individually. Delete all segments by deleting using + the `parent_document_id` of a segment result. - parameter projectID: The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. diff --git a/Source/DiscoveryV2/Models/QueryAggregation.swift b/Source/DiscoveryV2/Models/QueryAggregation.swift index 28e03676a..b69c4733b 100644 --- a/Source/DiscoveryV2/Models/QueryAggregation.swift +++ b/Source/DiscoveryV2/Models/QueryAggregation.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019. + * (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. @@ -16,91 +16,20 @@ import Foundation -/** An aggregation produced by the Discovery service to analyze the input provided. */ -public enum QueryAggregation: Codable, Equatable { - - // reference: https://cloud.ibm.com/docs/services/discovery/query-reference.html#aggregations +/** + An abstract aggregation type produced by Discovery to analyze the input provided. + */ +public struct QueryAggregation: Codable, Equatable { - case term(QueryTermAggregation) - case filter(QueryFilterAggregation) - case nested(QueryNestedAggregation) - case histogram(QueryHistogramAggregation) - case timeslice(QueryTimesliceAggregation) - case topHits(QueryTopHitsAggregation) - case uniqueCount(QueryCalculationAggregation) - case max(QueryCalculationAggregation) - case min(QueryCalculationAggregation) - case average(QueryCalculationAggregation) - case sum(QueryCalculationAggregation) - case generic(GenericQueryAggregation) + /** + The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, + average, unique_count, and top_hits. + */ + public var type: String + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case type = "type" } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - guard let type = try container.decodeIfPresent(String.self, forKey: .type) else { - // the specification does not identify `type` as a required field, - // so we need a generic catch-all in case it is not present - self = .generic(try GenericQueryAggregation(from: decoder)) - return - } - switch type { - case "term": self = .term(try QueryTermAggregation(from: decoder)) - case "filter": self = .filter(try QueryFilterAggregation(from: decoder)) - case "nested": self = .nested(try QueryNestedAggregation(from: decoder)) - case "histogram": self = .histogram(try QueryHistogramAggregation(from: decoder)) - case "timeslice": self = .timeslice(try QueryTimesliceAggregation(from: decoder)) - case "top_hits": self = .topHits(try QueryTopHitsAggregation(from: decoder)) - case "unique_count": self = .uniqueCount(try QueryCalculationAggregation(from: decoder)) - case "max": self = .max(try QueryCalculationAggregation(from: decoder)) - case "min": self = .min(try QueryCalculationAggregation(from: decoder)) - case "average": self = .average(try QueryCalculationAggregation(from: decoder)) - case "sum": self = .sum(try QueryCalculationAggregation(from: decoder)) - default: self = .generic(try GenericQueryAggregation(from: decoder)) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - switch self { - case .term(let term): - try container.encode("term", forKey: .type) - try term.encode(to: encoder) - case .filter(let filter): - try container.encode("filter", forKey: .type) - try filter.encode(to: encoder) - case .nested(let nested): - try container.encode("nested", forKey: .type) - try nested.encode(to: encoder) - case .histogram(let histogram): - try container.encode("histogram", forKey: .type) - try histogram.encode(to: encoder) - case .timeslice(let timeslice): - try container.encode("timeslice", forKey: .type) - try timeslice.encode(to: encoder) - case .topHits(let topHits): - try container.encode("top_hits", forKey: .type) - try topHits.encode(to: encoder) - case .uniqueCount(let uniqueCount): - try container.encode("unique_count", forKey: .type) - try uniqueCount.encode(to: encoder) - case .max(let max): - try container.encode("max", forKey: .type) - try max.encode(to: encoder) - case .min(let min): - try container.encode("min", forKey: .type) - try min.encode(to: encoder) - case .average(let average): - try container.encode("average", forKey: .type) - try average.encode(to: encoder) - case .sum(let sum): - try container.encode("sum", forKey: .type) - try sum.encode(to: encoder) - case .generic(let generic): - try generic.encode(to: encoder) - } - } - } diff --git a/Source/LanguageTranslatorV3/LanguageTranslator.swift b/Source/LanguageTranslatorV3/LanguageTranslator.swift index 76c37d48f..828763427 100644 --- a/Source/LanguageTranslatorV3/LanguageTranslator.swift +++ b/Source/LanguageTranslatorV3/LanguageTranslator.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2018, 2020. + * (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. @@ -55,10 +55,11 @@ public class LanguageTranslator { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift index 73f36785d..ee7aab160 100644 --- a/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift +++ b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -51,8 +51,10 @@ public class NaturalLanguageClassifier { In that case, try another initializer that directly passes in the credentials. */ - public init() throws { - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + public init?() { + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift b/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift index feeac1b3d..9e7b1b84f 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2017, 2020. + * (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. @@ -37,6 +37,10 @@ public struct CategoriesOptions: Codable, Equatable { Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. + The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom + categories models will no longer be accessible in Natural Language Understanding. The feature will be removed from + Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge Studio on + 17 December 2019. */ public var model: String? @@ -49,12 +53,18 @@ public struct CategoriesOptions: Codable, Equatable { /** Initialize a `CategoriesOptions` with member variables. + - parameter explanation: Set this to `true` to return explanations for each categorization. **This is available only for English categories.**. - parameter limit: Maximum number of categories to return. - parameter model: Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. + The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom + categories models will no longer be accessible in Natural Language Understanding. The feature will be removed + from Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge + Studio on 17 December 2019. + - returns: An initialized `CategoriesOptions`. */ public init( diff --git a/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift index 95c7e89a5..20ccb01d8 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2017, 2019. + * (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. @@ -20,6 +20,4 @@ import Foundation Returns information from the document, including author name, title, RSS/ATOM feeds, prominent page image, and publication date. Supports URL and HTML input types only. */ -public struct MetadataOptions: Codable, Equatable { - public init() { } -} +public typealias MetadataOptions = JSON diff --git a/Source/NaturalLanguageUnderstandingV1/Models/Model.swift b/Source/NaturalLanguageUnderstandingV1/Models/Model.swift index fb89e113b..3c6abcac9 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/Model.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/Model.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2017, 2018. + * (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. @@ -47,6 +47,11 @@ public struct Model: Codable, Equatable { /** The model version, if it was manually provided in Watson Knowledge Studio. */ + public var modelVersion: String? + + /** + (Deprecated — use `model_version`) The model version, if it was manually provided in Watson Knowledge Studio. + */ public var version: String? /** @@ -66,6 +71,7 @@ public struct Model: Codable, Equatable { case language = "language" case description = "description" case workspaceID = "workspace_id" + case modelVersion = "model_version" case version = "version" case versionDescription = "version_description" case created = "created" diff --git a/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift index 36462233a..f1f2a0585 100644 --- a/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift +++ b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2017, 2020. + * (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. @@ -57,10 +57,11 @@ public class NaturalLanguageUnderstanding { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/PersonalityInsightsV3/PersonalityInsights.swift b/Source/PersonalityInsightsV3/PersonalityInsights.swift index 8c0a5d265..38af3a917 100644 --- a/Source/PersonalityInsightsV3/PersonalityInsights.swift +++ b/Source/PersonalityInsightsV3/PersonalityInsights.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -64,10 +64,11 @@ public class PersonalityInsights { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -184,6 +185,8 @@ public class PersonalityInsights { - parameter rawScores: Indicates whether a raw score in addition to a normalized percentile is returned for each characteristic; raw scores are not compared with a sample population. By default, only normalized percentiles are returned. + - parameter csvHeaders: Indicates whether column labels are returned with a CSV response. By default, no column + labels are returned. Applies only when the response type is CSV (`text/csv`). - parameter consumptionPreferences: Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned. - parameter headers: A dictionary of request headers to be sent with this request. @@ -194,6 +197,7 @@ public class PersonalityInsights { contentLanguage: String? = nil, acceptLanguage: String? = nil, rawScores: Bool? = nil, + csvHeaders: Bool? = nil, consumptionPreferences: Bool? = nil, headers: [String: String]? = nil, completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) @@ -227,6 +231,10 @@ public class PersonalityInsights { let queryParameter = URLQueryItem(name: "raw_scores", value: "\(rawScores)") queryParameters.append(queryParameter) } + if let csvHeaders = csvHeaders { + let queryParameter = URLQueryItem(name: "csv_headers", value: "\(csvHeaders)") + queryParameters.append(queryParameter) + } if let consumptionPreferences = consumptionPreferences { let queryParameter = URLQueryItem(name: "consumption_preferences", value: "\(consumptionPreferences)") queryParameters.append(queryParameter) @@ -318,7 +326,7 @@ public class PersonalityInsights { csvHeaders: Bool? = nil, consumptionPreferences: Bool? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct body guard let body = profileContent.content else { diff --git a/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift index 6802419fa..7ae4bea11 100644 --- a/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift +++ b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2019. + * (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. @@ -37,14 +37,14 @@ public struct SpeechRecognitionAlternative: Codable, Equatable { the word followed by its start and end time in seconds, for example: `[["hello",0.0,1.2],["world",1.2,2.5]]`. Timestamps are returned only for the best alternative. */ - public var timestamps: [WordTimestamp]? + public var timestamps: [String]? /** A confidence score for each word of the transcript as a list of lists. Each inner list consists of two elements: the word and its confidence score in the range of 0.0 to 1.0, for example: `[["hello",0.95],["world",0.866]]`. Confidence scores are returned only for the best alternative and only with results marked as final. */ - public var wordConfidence: [WordConfidence]? + public var wordConfidence: [String]? // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { diff --git a/Source/SpeechToTextV1/SpeechToText.swift b/Source/SpeechToTextV1/SpeechToText.swift index 8a3f7d5ef..f673b61b2 100644 --- a/Source/SpeechToTextV1/SpeechToText.swift +++ b/Source/SpeechToTextV1/SpeechToText.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -63,8 +63,10 @@ public class SpeechToText { In that case, try another initializer that directly passes in the credentials. */ - public init() throws { - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + public init?() { + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -1638,7 +1640,7 @@ public class SpeechToText { wordTypeToAdd: String? = nil, customizationWeight: Double? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct header parameters var headerParameters = defaultHeaders @@ -1684,7 +1686,7 @@ public class SpeechToText { ) // execute REST request - request.response(completionHandler: completionHandler) + request.responseObject(completionHandler: completionHandler) } /** @@ -3096,7 +3098,7 @@ public class SpeechToText { customizationID: String, customLanguageModelID: String? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct header parameters var headerParameters = defaultHeaders @@ -3138,7 +3140,7 @@ public class SpeechToText { ) // execute REST request - request.response(completionHandler: completionHandler) + request.responseObject(completionHandler: completionHandler) } /** diff --git a/Source/TextToSpeechV1/TextToSpeech.swift b/Source/TextToSpeechV1/TextToSpeech.swift index 334efc87c..054de885d 100644 --- a/Source/TextToSpeechV1/TextToSpeech.swift +++ b/Source/TextToSpeechV1/TextToSpeech.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -22,14 +22,15 @@ import IBMSwiftSDKCore The IBM® Text to Speech service provides APIs that use IBM's speech-synthesis capabilities to synthesize text into natural-sounding speech in a variety of languages, dialects, and voices. The service supports at least one male or female voice, sometimes both, for each language. The audio is streamed back to the client with minimal delay. - For speech synthesis, the service supports a synchronous HTTP Representational State Transfer (REST) interface. It also - supports a WebSocket interface that provides both plain text and SSML input, including the SSML <mark> element - and word timings. SSML is an XML-based markup language that provides text annotation for speech-synthesis applications. - The service also offers a customization interface. You can use the interface to define sounds-like or phonetic - translations for words. A sounds-like translation consists of one or more words that, when combined, sound like the - word. A phonetic translation is based on the SSML phoneme format for representing a word. You can specify a phonetic - translation in standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM Symbolic - Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages support only IPA. + For speech synthesis, the service supports a synchronous HTTP Representational State Transfer (REST) interface and a + WebSocket interface. Both interfaces support plain text and SSML input. SSML is an XML-based markup language that + provides text annotation for speech-synthesis applications. The WebSocket interface also supports the SSML + <mark> element and word timings. + The service offers a customization interface that you can use to define sounds-like or phonetic translations for words. + A sounds-like translation consists of one or more words that, when combined, sound like the word. A phonetic + translation is based on the SSML phoneme format for representing a word. You can specify a phonetic translation in + standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM Symbolic Phonetic + Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages support only IPA. */ public class TextToSpeech { @@ -59,8 +60,10 @@ public class TextToSpeech { In that case, try another initializer that directly passes in the credentials. */ - public init() throws { - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + public init?() { + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -355,38 +358,7 @@ public class TextToSpeech { ) // execute REST request - request.response { (response: WatsonResponse?, error: WatsonError?) in - var response = response - guard let data = response?.result else { - completionHandler(response, error) - return - } - if accept?.lowercased().contains("audio/wav") == true { - // repair the WAV header - var wav = data - guard WAVRepair.isWAVFile(data: wav) else { - let error = WatsonError.other(message: "Expected returned audio to be in WAV format", metadata: nil) - completionHandler(nil, error) - return - } - WAVRepair.repairWAVHeader(data: &wav) - response?.result = wav - completionHandler(response, nil) - } else if accept?.lowercased().contains("ogg") == true && accept?.lowercased().contains("opus") == true { - do { - let decodedAudio = try TextToSpeechDecoder(audioData: data) - response?.result = decodedAudio.pcmDataWithHeaders - completionHandler(response, nil) - } catch { - let error = WatsonError.serialization(values: "returned audio") - completionHandler(nil, error) - return - } - } else { - completionHandler(response, nil) - } - } - + request.response(completionHandler: completionHandler) } /** diff --git a/Source/ToneAnalyzerV3/ToneAnalyzer.swift b/Source/ToneAnalyzerV3/ToneAnalyzer.swift index 4cbb720ef..c99cf62c2 100644 --- a/Source/ToneAnalyzerV3/ToneAnalyzer.swift +++ b/Source/ToneAnalyzerV3/ToneAnalyzer.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -58,10 +58,11 @@ public class ToneAnalyzer { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -152,6 +153,11 @@ public class ToneAnalyzer { - parameter sentences: Indicates whether the service is to return an analysis of each individual sentence in addition to its analysis of the full document. If `true` (the default), the service returns results for each sentence. + - parameter tones: **`2017-09-21`:** Deprecated. The service continues to accept the parameter for + backward-compatibility, but the parameter no longer affects the response. + **`2016-05-19`:** A comma-separated list of tones for which the service is to return its analysis of the input; + the indicated tones apply both to the full document and to individual sentences of the document. You can specify + one or more of the valid values. Omit the parameter to request results for all three tones. - parameter contentLanguage: The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for @@ -167,6 +173,7 @@ public class ToneAnalyzer { public func tone( toneContent: ToneContent, sentences: Bool? = nil, + tones: [String]? = nil, contentLanguage: String? = nil, acceptLanguage: String? = nil, headers: [String: String]? = nil, @@ -201,6 +208,10 @@ public class ToneAnalyzer { let queryParameter = URLQueryItem(name: "sentences", value: "\(sentences)") queryParameters.append(queryParameter) } + if let tones = tones { + let queryParameter = URLQueryItem(name: "tones", value: tones.joined(separator: ",")) + queryParameters.append(queryParameter) + } // construct REST request diff --git a/Source/VisualRecognitionV3/VisualRecognition.swift b/Source/VisualRecognitionV3/VisualRecognition.swift index c34b83527..1e42df8eb 100644 --- a/Source/VisualRecognitionV3/VisualRecognition.swift +++ b/Source/VisualRecognitionV3/VisualRecognition.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2016, 2020. + * (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. @@ -53,10 +53,11 @@ public class VisualRecognition { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -114,16 +115,6 @@ public class VisualRecognition { errorMessage = message } else if case let .some(.string(message)) = json["message"] { errorMessage = message - // ErrorAuthentication - } else if case let .some(.string(message)) = json["statusInfo"] { - errorMessage = message - // ErrorInfo - } else if case let .some(.object(errorObj)) = json["error"], // 404 - case let .some(.string(message)) = errorObj["description"] { - errorMessage = message - // ErrorHTML - } else if case let .some(.string(message)) = json["Error"] { // 413 - errorMessage = message } else { errorMessage = HTTPURLResponse.localizedString(forStatusCode: response.statusCode) } @@ -198,17 +189,20 @@ public class VisualRecognition { multipartFormData.append(thresholdData, withName: "threshold") } } - - // HAND EDIT: concat owners into csv data - if let csvOwners = owners?.joined(separator: ",").data(using: .utf8) { - multipartFormData.append(csvOwners, withName: "owners") + if let owners = owners { + for item in owners { + if let itemData = item.data(using: .utf8) { + multipartFormData.append(itemData, withName: "owners") + } + } } - - // HAND EDIT: concat classifier IDs into csv data - if let csvClassifierIDs = classifierIDs?.joined(separator: ",").data(using: .utf8) { - multipartFormData.append(csvClassifierIDs, withName: "classifier_ids") + if let classifierIDs = classifierIDs { + for item in classifierIDs { + if let itemData = item.data(using: .utf8) { + multipartFormData.append(itemData, withName: "classifier_ids") + } + } } - guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) return @@ -299,10 +293,10 @@ public class VisualRecognition { } positiveExamples.forEach { (classname, value) in let partName = "\(classname)_positive_examples" - multipartFormData.append(value, withName: partName, fileName: "\(classname).zip") + multipartFormData.append(value, withName: partName, fileName: classname) } if let negativeExamples = negativeExamples { - multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename.zip") + multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename") } guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) @@ -498,11 +492,11 @@ public class VisualRecognition { if let positiveExamples = positiveExamples { positiveExamples.forEach { (classname, value) in let partName = "\(classname)_positive_examples" - multipartFormData.append(value, withName: partName, fileName: "\(classname).zip") + multipartFormData.append(value, withName: partName, fileName: classname) } } if let negativeExamples = negativeExamples { - multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename.zip") + multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename") } guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) diff --git a/Source/VisualRecognitionV4/Models/ImageDetails.swift b/Source/VisualRecognitionV4/Models/ImageDetails.swift index 5ee2653f6..6f3a019c5 100644 --- a/Source/VisualRecognitionV4/Models/ImageDetails.swift +++ b/Source/VisualRecognitionV4/Models/ImageDetails.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019. + * (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. @@ -46,6 +46,9 @@ public struct ImageDetails: Codable, Equatable { */ public var dimensions: ImageDimensions? + /** + Details about the errors. + */ public var errors: [Error]? /** diff --git a/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift b/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift index d7e179e11..bb6047397 100644 --- a/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift +++ b/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019. + * (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. @@ -41,6 +41,11 @@ public struct ObjectTrainingStatus: Codable, Equatable { */ public var latestFailed: Bool + /** + Whether the model can be downloaded after the training status is `ready`. + */ + public var rscnnReady: Bool + /** Details about the training. If training is in progress, includes information about the status. If training is not in progress, includes a success message or information about why training failed. @@ -53,6 +58,7 @@ public struct ObjectTrainingStatus: Codable, Equatable { case inProgress = "in_progress" case dataChanged = "data_changed" case latestFailed = "latest_failed" + case rscnnReady = "rscnn_ready" case description = "description" } @@ -63,6 +69,7 @@ public struct ObjectTrainingStatus: Codable, Equatable { - parameter inProgress: Whether training is in progress. - parameter dataChanged: Whether there are changes to the training data since the most recent training. - parameter latestFailed: Whether the most recent training failed. + - parameter rscnnReady: Whether the model can be downloaded after the training status is `ready`. - parameter description: Details about the training. If training is in progress, includes information about the status. If training is not in progress, includes a success message or information about why training failed. @@ -73,6 +80,7 @@ public struct ObjectTrainingStatus: Codable, Equatable { inProgress: Bool, dataChanged: Bool, latestFailed: Bool, + rscnnReady: Bool, description: String ) { @@ -80,6 +88,7 @@ public struct ObjectTrainingStatus: Codable, Equatable { self.inProgress = inProgress self.dataChanged = dataChanged self.latestFailed = latestFailed + self.rscnnReady = rscnnReady self.description = description } diff --git a/Source/VisualRecognitionV4/VisualRecognition.swift b/Source/VisualRecognitionV4/VisualRecognition.swift index dc7e92060..397af8856 100644 --- a/Source/VisualRecognitionV4/VisualRecognition.swift +++ b/Source/VisualRecognitionV4/VisualRecognition.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2019, 2020. + * (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. @@ -53,10 +53,11 @@ public class VisualRecognition { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init(version: String) throws { + public init?(version: String) { self.version = version - - let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) + guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { + return nil + } self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -161,17 +162,16 @@ public class VisualRecognition { { // construct body let multipartFormData = MultipartFormData() - - // HAND EDIT: join collectionIDs into CSV string - if let csvCollectionIDsData = collectionIDs.joined(separator: ",").data(using: .utf8) { - multipartFormData.append(csvCollectionIDsData, withName: "collection_ids") + for item in collectionIDs { + if let itemData = item.data(using: .utf8) { + multipartFormData.append(itemData, withName: "collection_ids") + } } - - // HAND EDIT: join features into CSV string - if let csvFeaturesData = features.joined(separator: ",").data(using: .utf8) { - multipartFormData.append(csvFeaturesData, withName: "features") + for item in features { + if let itemData = item.data(using: .utf8) { + multipartFormData.append(itemData, withName: "features") + } } - if let imagesFile = imagesFile { for item in imagesFile { multipartFormData.append(item.data, withName: "images_file", mimeType: item.contentType, fileName: item.filename) @@ -524,6 +524,70 @@ public class VisualRecognition { request.response(completionHandler: completionHandler) } + /** + Get a model. + + Download a model that you can deploy to detect objects in images. The collection must include a generated model, + which is indicated in the response for the collection details as `"rscnn_ready": true`. If the value is `false`, + train or retrain the collection to generate the model. + Currently, the model format is specific to Android apps. For more information about how to deploy the model to your + app, see the [Watson Visual Recognition on Android](https://github.com/matt-ny/rscnn) project in GitHub. + + - parameter collectionID: The identifier of the collection. + - parameter feature: The feature for the model. + - parameter modelFormat: The format of the returned model. + - parameter headers: A dictionary of request headers to be sent with this request. + - parameter completionHandler: A function executed when the request completes with a successful result or error + */ + public func getModelFile( + collectionID: String, + feature: String, + modelFormat: String, + headers: [String: String]? = nil, + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + { + // construct header parameters + var headerParameters = defaultHeaders + if let headers = headers { + headerParameters.merge(headers) { (_, new) in new } + } + let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "getModelFile") + headerParameters.merge(sdkHeaders) { (_, new) in new } + headerParameters["Accept"] = "application/octet-stream" + + // construct query parameters + var queryParameters = [URLQueryItem]() + queryParameters.append(URLQueryItem(name: "version", value: version)) + queryParameters.append(URLQueryItem(name: "feature", value: feature)) + queryParameters.append(URLQueryItem(name: "model_format", value: modelFormat)) + + // construct REST request + let path = "/v4/collections/\(collectionID)/model" + guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { + completionHandler(nil, WatsonError.urlEncoding(path: path)) + return + } + + // ensure that serviceURL is set + guard let serviceEndpoint = serviceURL else { + completionHandler(nil, WatsonError.noEndpoint) + return + } + + let request = RestRequest( + session: session, + authenticator: authenticator, + errorResponseDecoder: errorResponseDecoder, + method: "GET", + url: serviceEndpoint + encodedPath, + headerParameters: headerParameters, + queryItems: queryParameters + ) + + // execute REST request + request.response(completionHandler: completionHandler) + } + /** Add images. diff --git a/WatsonDeveloperCloud.xcodeproj/project.pbxproj b/WatsonDeveloperCloud.xcodeproj/project.pbxproj index b0adacb31..80d46761b 100644 --- a/WatsonDeveloperCloud.xcodeproj/project.pbxproj +++ b/WatsonDeveloperCloud.xcodeproj/project.pbxproj @@ -375,6 +375,15 @@ 7E70D5C92388491E00CC8C80 /* Webhook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E70D5C62388491E00CC8C80 /* Webhook.swift */; }; 7E70D5CC238C1DF000CC8C80 /* TrainingEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E70D5CA238C1DF000CC8C80 /* TrainingEvents.swift */; }; 7E70D5CD238C1DF000CC8C80 /* TrainingEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E70D5CB238C1DF000CC8C80 /* TrainingEvent.swift */; }; + 7E8B21272475973700BE7EFA /* MessageContextSkillSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B211E2475973500BE7EFA /* MessageContextSkillSystem.swift */; }; + 7E8B21282475973700BE7EFA /* MessageInputStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B211F2475973600BE7EFA /* MessageInputStateless.swift */; }; + 7E8B21292475973700BE7EFA /* MessageInputOptionsSpelling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21202475973600BE7EFA /* MessageInputOptionsSpelling.swift */; }; + 7E8B212A2475973700BE7EFA /* MessageOutputSpelling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21212475973600BE7EFA /* MessageOutputSpelling.swift */; }; + 7E8B212B2475973700BE7EFA /* MessageRequestStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21222475973600BE7EFA /* MessageRequestStateless.swift */; }; + 7E8B212C2475973700BE7EFA /* MessageContextStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21232475973600BE7EFA /* MessageContextStateless.swift */; }; + 7E8B212D2475973700BE7EFA /* MessageResponseStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21242475973700BE7EFA /* MessageResponseStateless.swift */; }; + 7E8B212E2475973700BE7EFA /* MessageContextGlobalStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21252475973700BE7EFA /* MessageContextGlobalStateless.swift */; }; + 7E8B212F2475973700BE7EFA /* MessageInputOptionsStateless.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E8B21262475973700BE7EFA /* MessageInputOptionsStateless.swift */; }; 7E96EC3C233907660039388E /* GenericQueryAggregation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E96EC3B233907660039388E /* GenericQueryAggregation.swift */; }; 7E96EC3F23391C0A0039388E /* WordTimestamp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E96EC3D23391C0A0039388E /* WordTimestamp.swift */; }; 7E96EC4023391C0A0039388E /* WordConfidence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E96EC3E23391C0A0039388E /* WordConfidence.swift */; }; @@ -1339,6 +1348,15 @@ 7E70D5C62388491E00CC8C80 /* Webhook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Webhook.swift; sourceTree = ""; }; 7E70D5CA238C1DF000CC8C80 /* TrainingEvents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrainingEvents.swift; sourceTree = ""; }; 7E70D5CB238C1DF000CC8C80 /* TrainingEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrainingEvent.swift; sourceTree = ""; }; + 7E8B211E2475973500BE7EFA /* MessageContextSkillSystem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageContextSkillSystem.swift; sourceTree = ""; }; + 7E8B211F2475973600BE7EFA /* MessageInputStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageInputStateless.swift; sourceTree = ""; }; + 7E8B21202475973600BE7EFA /* MessageInputOptionsSpelling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageInputOptionsSpelling.swift; sourceTree = ""; }; + 7E8B21212475973600BE7EFA /* MessageOutputSpelling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageOutputSpelling.swift; sourceTree = ""; }; + 7E8B21222475973600BE7EFA /* MessageRequestStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRequestStateless.swift; sourceTree = ""; }; + 7E8B21232475973600BE7EFA /* MessageContextStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageContextStateless.swift; sourceTree = ""; }; + 7E8B21242475973700BE7EFA /* MessageResponseStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageResponseStateless.swift; sourceTree = ""; }; + 7E8B21252475973700BE7EFA /* MessageContextGlobalStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageContextGlobalStateless.swift; sourceTree = ""; }; + 7E8B21262475973700BE7EFA /* MessageInputOptionsStateless.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageInputOptionsStateless.swift; sourceTree = ""; }; 7E96EC3B233907660039388E /* GenericQueryAggregation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GenericQueryAggregation.swift; sourceTree = ""; }; 7E96EC3D23391C0A0039388E /* WordTimestamp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordTimestamp.swift; sourceTree = ""; }; 7E96EC3E23391C0A0039388E /* WordConfidence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordConfidence.swift; sourceTree = ""; }; @@ -2960,15 +2978,24 @@ 9220778D2152FC5900C8C7E4 /* DialogSuggestionValue.swift */, 922077842152FC5900C8C7E4 /* MessageContext.swift */, 922077952152FC5900C8C7E4 /* MessageContextGlobal.swift */, + 7E8B21252475973700BE7EFA /* MessageContextGlobalStateless.swift */, 9220778C2152FC5900C8C7E4 /* MessageContextGlobalSystem.swift */, CA8E92882236C638001BFABF /* MessageContextSkill.swift */, 922077932152FC5900C8C7E4 /* MessageContextSkills.swift */, + 7E8B211E2475973500BE7EFA /* MessageContextSkillSystem.swift */, + 7E8B21232475973600BE7EFA /* MessageContextStateless.swift */, 922077912152FC5900C8C7E4 /* MessageInput.swift */, 922077962152FC5900C8C7E4 /* MessageInputOptions.swift */, + 7E8B21202475973600BE7EFA /* MessageInputOptionsSpelling.swift */, + 7E8B21262475973700BE7EFA /* MessageInputOptionsStateless.swift */, + 7E8B211F2475973600BE7EFA /* MessageInputStateless.swift */, 922077892152FC5900C8C7E4 /* MessageOutput.swift */, 9220778B2152FC5900C8C7E4 /* MessageOutputDebug.swift */, + 7E8B21212475973600BE7EFA /* MessageOutputSpelling.swift */, 922077872152FC5900C8C7E4 /* MessageRequest.swift */, + 7E8B21222475973600BE7EFA /* MessageRequestStateless.swift */, 922077982152FC5900C8C7E4 /* MessageResponse.swift */, + 7E8B21242475973700BE7EFA /* MessageResponseStateless.swift */, 922077922152FC5900C8C7E4 /* RuntimeEntity.swift */, 7EDC39C423F4445000B13747 /* RuntimeEntityAlternative.swift */, 7EDC39C323F4445000B13747 /* RuntimeEntityInterpretation.swift */, @@ -5365,6 +5392,8 @@ 922078532152FCE400C8C7E4 /* DialogLogMessage.swift in Sources */, 922078412152FCE000C8C7E4 /* Assistant.swift in Sources */, 922078572152FCE400C8C7E4 /* MessageResponse.swift in Sources */, + 7E8B212C2475973700BE7EFA /* MessageContextStateless.swift in Sources */, + 7E8B212A2475973700BE7EFA /* MessageOutputSpelling.swift in Sources */, 7EC735DC2319DDB400A73810 /* RuntimeResponseGeneric.swift in Sources */, 922078442152FCE400C8C7E4 /* DialogSuggestion.swift in Sources */, 922078512152FCE400C8C7E4 /* RuntimeEntity.swift in Sources */, @@ -5372,13 +5401,17 @@ 5F2C5BE722E9FA0900A7628D /* SearchResultHighlight.swift in Sources */, 922078522152FCE400C8C7E4 /* MessageContextSkills.swift in Sources */, 922078432152FCE400C8C7E4 /* MessageContext.swift in Sources */, + 7E8B212D2475973700BE7EFA /* MessageResponseStateless.swift in Sources */, 922078562152FCE400C8C7E4 /* DialogNodesVisited.swift in Sources */, 924EE7BA21505D7A0048C0E5 /* Shared.swift in Sources */, 922078422152FCE400C8C7E4 /* DialogNodeAction.swift in Sources */, 922078452152FCE400C8C7E4 /* SessionResponse.swift in Sources */, + 7E8B212B2475973700BE7EFA /* MessageRequestStateless.swift in Sources */, 922078502152FCE400C8C7E4 /* MessageInput.swift in Sources */, 922078472152FCE400C8C7E4 /* CaptureGroup.swift in Sources */, 5F2C5BE622E9FA0900A7628D /* SearchResult.swift in Sources */, + 7E8B21292475973700BE7EFA /* MessageInputOptionsSpelling.swift in Sources */, + 7E8B21272475973700BE7EFA /* MessageContextSkillSystem.swift in Sources */, 9220784A2152FCE400C8C7E4 /* MessageOutputDebug.swift in Sources */, 922078482152FCE400C8C7E4 /* MessageOutput.swift in Sources */, 9220784D2152FCE400C8C7E4 /* RuntimeIntent.swift in Sources */, @@ -5386,7 +5419,10 @@ CA8E92892236C638001BFABF /* MessageContextSkill.swift in Sources */, 7EDC39C723F4445000B13747 /* RuntimeEntityAlternative.swift in Sources */, 7EDC39C623F4445000B13747 /* RuntimeEntityInterpretation.swift in Sources */, + 7E8B212E2475973700BE7EFA /* MessageContextGlobalStateless.swift in Sources */, 9220784C2152FCE400C8C7E4 /* DialogSuggestionValue.swift in Sources */, + 7E8B212F2475973700BE7EFA /* MessageInputOptionsStateless.swift in Sources */, + 7E8B21282475973700BE7EFA /* MessageInputStateless.swift in Sources */, 9220784E2152FCE400C8C7E4 /* DialogNodeOutputOptionsElementValue.swift in Sources */, 5F2C5BE822E9FA0900A7628D /* SearchResultMetadata.swift in Sources */, 922078462152FCE400C8C7E4 /* MessageRequest.swift in Sources */, From 31406413f8afc99c91976f0e0a4d573133ab780c Mon Sep 17 00:00:00 2001 From: Mike Kistler Date: Tue, 4 Jun 2019 10:10:42 -0700 Subject: [PATCH 02/13] Post-generation changes New hand-edits for STT Add coding extensions for MessageContextSkills feat(Hand-Edit): add functionality to encode/decode additional properties this is used to house additional fields returned by the search skill test(integration tests): update tests for new api definition n refactor(core typealias): typealias core authenticators this allows us to let the users interact with the authenticators without making the core an explicit dependency feat(service url): return a WatsonError if serviceURL is nil this adapts to the new format where serviceURL has been modified from a String to a String? (accounting for parameterized URL support) refactor(core import): use IBMSwiftSDKCore instead of RestKit feat(vis rec ui): remove faces method build(xcode): update dependency settings test(vr): update test values fix(hand edit): convert classifierIDs and owners to csv data --- Source/AssistantV2/Assistant.swift | 1 + .../Models/MessageContextSkills.swift | 36 ++++++ .../Models/SearchResultHighlight.swift | 35 ++++++ .../Models/AggregationResult.swift | 8 ++ .../DiscoveryV1/Models/QueryAggregation.swift | 112 +++++++++++++----- .../Models/MetadataOptions.swift | 4 +- .../PersonalityInsights.swift | 9 +- .../Models/SpeechRecognitionAlternative.swift | 4 +- Source/SpeechToTextV1/SpeechToText.swift | 8 +- Source/TextToSpeechV1/TextToSpeech.swift | 33 +++++- Source/ToneAnalyzerV3/ToneAnalyzer.swift | 10 -- .../VisualRecognition.swift | 39 +++--- 12 files changed, 228 insertions(+), 71 deletions(-) diff --git a/Source/AssistantV2/Assistant.swift b/Source/AssistantV2/Assistant.swift index 4b7e45c3e..de4f92062 100644 --- a/Source/AssistantV2/Assistant.swift +++ b/Source/AssistantV2/Assistant.swift @@ -156,6 +156,7 @@ public class Assistant { let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "createSession") headerParameters.merge(sdkHeaders) { (_, new) in new } headerParameters["Accept"] = "application/json" + headerParameters["Content-Type"] = "application/json" // construct query parameters var queryParameters = [URLQueryItem]() diff --git a/Source/AssistantV2/Models/MessageContextSkills.swift b/Source/AssistantV2/Models/MessageContextSkills.swift index 6ccaf71b6..6f2fb2cb4 100644 --- a/Source/AssistantV2/Models/MessageContextSkills.swift +++ b/Source/AssistantV2/Models/MessageContextSkills.swift @@ -50,3 +50,39 @@ public struct MessageContextSkills: Codable, Equatable { } } + +public extension KeyedDecodingContainer where Key == DynamicKeys { + + /// Decode additional properties. + func decode(_ type: [String: MessageContextSkill].Type, excluding keys: [CodingKey]) throws -> [String: MessageContextSkill] { + var retval: [String: MessageContextSkill] = [:] + try self.allKeys.forEach { key in + if !keys.contains{ $0.stringValue == key.stringValue} { + let value = try self.decode(MessageContextSkill.self, forKey: key) + retval[key.stringValue] = value + } + } + return retval + } +} + +public extension KeyedEncodingContainer where Key == DynamicKeys { + + /// Encode additional properties. + mutating func encode(_ additionalProperties: [String: MessageContextSkill]) throws { + try additionalProperties.forEach { key, value in + guard let codingKey = DynamicKeys(stringValue: key) else { + let description = "Cannot construct CodingKey for \(key)" + let context = EncodingError.Context(codingPath: codingPath, debugDescription: description) + throw EncodingError.invalidValue(key, context) + } + try self.encode(value, forKey: codingKey) + } + } + + /// Encode additional properties if they are not nil. + mutating func encodeIfPresent(_ additionalProperties: [String: MessageContextSkill]?) throws { + guard let additionalProperties = additionalProperties else { return } + try encode(additionalProperties) + } +} diff --git a/Source/AssistantV2/Models/SearchResultHighlight.swift b/Source/AssistantV2/Models/SearchResultHighlight.swift index 1e32f39d3..62d673925 100644 --- a/Source/AssistantV2/Models/SearchResultHighlight.swift +++ b/Source/AssistantV2/Models/SearchResultHighlight.swift @@ -68,5 +68,40 @@ public struct SearchResultHighlight: Codable, Equatable { var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self) try dynamicContainer.encodeIfPresent(additionalProperties) } +} + +public extension KeyedDecodingContainer where Key == DynamicKeys { + + /// Decode additional properties. + func decode(_ type: [String: [String]].Type, excluding keys: [CodingKey]) throws -> [String: [String]] { + var retval: [String: [String]] = [:] + try self.allKeys.forEach { key in + if !keys.contains{ $0.stringValue == key.stringValue} { + let value = try self.decode([String].self, forKey: key) + retval[key.stringValue] = value + } + } + return retval + } +} +public extension KeyedEncodingContainer where Key == DynamicKeys { + + /// Encode additional properties. + mutating func encode(_ additionalProperties: [String: [String]]) throws { + try additionalProperties.forEach { key, value in + guard let codingKey = DynamicKeys(stringValue: key) else { + let description = "Cannot construct CodingKey for \(key)" + let context = EncodingError.Context(codingPath: codingPath, debugDescription: description) + throw EncodingError.invalidValue(key, context) + } + try self.encode(value, forKey: codingKey) + } + } + + /// Encode additional properties if they are not nil. + mutating func encodeIfPresent(_ additionalProperties: [String: [String]]?) throws { + guard let additionalProperties = additionalProperties else { return } + try encode(additionalProperties) + } } diff --git a/Source/DiscoveryV1/Models/AggregationResult.swift b/Source/DiscoveryV1/Models/AggregationResult.swift index e60b5d8c6..003d4acba 100644 --- a/Source/DiscoveryV1/Models/AggregationResult.swift +++ b/Source/DiscoveryV1/Models/AggregationResult.swift @@ -43,4 +43,12 @@ public struct AggregationResult: Codable, Equatable { case aggregations = "aggregations" } + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + if let keyAsString = try? container.decode(String.self, forKey: .key) { key = keyAsString } + if let keyAsInt = try? container.decode(Int.self, forKey: .key) { key = "\(keyAsInt)" } + matchingResults = try container.decodeIfPresent(Int.self, forKey: .matchingResults) + aggregations = try container.decodeIfPresent([QueryAggregation].self, forKey: .aggregations) + } + } diff --git a/Source/DiscoveryV1/Models/QueryAggregation.swift b/Source/DiscoveryV1/Models/QueryAggregation.swift index 5f88c5081..eac9278a8 100644 --- a/Source/DiscoveryV1/Models/QueryAggregation.swift +++ b/Source/DiscoveryV1/Models/QueryAggregation.swift @@ -16,37 +16,91 @@ import Foundation -/** - An aggregation produced by Discovery to analyze the input provided. - */ -public struct QueryAggregation: Codable, Equatable { - - /** - The type of aggregation command used. For example: term, filter, max, min, etc. - */ - public var type: String? - - /** - Array of aggregation results. - */ - public var results: [AggregationResult]? - - /** - Number of matching results. - */ - public var matchingResults: Int? - - /** - Aggregations returned by Discovery. - */ - public var aggregations: [QueryAggregation]? - - // Map each property name to the key that shall be used for encoding/decoding. +/** An aggregation produced by the Discovery service to analyze the input provided. */ +public enum QueryAggregation: Codable, Equatable { + + // reference: https://cloud.ibm.com/docs/services/discovery/query-reference.html#aggregations + + case term(Term) + case filter(Filter) + case nested(Nested) + case histogram(Histogram) + case timeslice(Timeslice) + case topHits(TopHits) + case uniqueCount(Calculation) + case max(Calculation) + case min(Calculation) + case average(Calculation) + case sum(Calculation) + case generic(GenericQueryAggregation) + private enum CodingKeys: String, CodingKey { case type = "type" - case results = "results" - case matchingResults = "matching_results" - case aggregations = "aggregations" + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + guard let type = try container.decodeIfPresent(String.self, forKey: .type) else { + // the specification does not identify `type` as a required field, + // so we need a generic catch-all in case it is not present + self = .generic(try GenericQueryAggregation(from: decoder)) + return + } + switch type { + case "term": self = .term(try Term(from: decoder)) + case "filter": self = .filter(try Filter(from: decoder)) + case "nested": self = .nested(try Nested(from: decoder)) + case "histogram": self = .histogram(try Histogram(from: decoder)) + case "timeslice": self = .timeslice(try Timeslice(from: decoder)) + case "top_hits": self = .topHits(try TopHits(from: decoder)) + case "unique_count": self = .uniqueCount(try Calculation(from: decoder)) + case "max": self = .max(try Calculation(from: decoder)) + case "min": self = .min(try Calculation(from: decoder)) + case "average": self = .average(try Calculation(from: decoder)) + case "sum": self = .sum(try Calculation(from: decoder)) + default: self = .generic(try GenericQueryAggregation(from: decoder)) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + switch self { + case .term(let term): + try container.encode("term", forKey: .type) + try term.encode(to: encoder) + case .filter(let filter): + try container.encode("filter", forKey: .type) + try filter.encode(to: encoder) + case .nested(let nested): + try container.encode("nested", forKey: .type) + try nested.encode(to: encoder) + case .histogram(let histogram): + try container.encode("histogram", forKey: .type) + try histogram.encode(to: encoder) + case .timeslice(let timeslice): + try container.encode("timeslice", forKey: .type) + try timeslice.encode(to: encoder) + case .topHits(let topHits): + try container.encode("top_hits", forKey: .type) + try topHits.encode(to: encoder) + case .uniqueCount(let uniqueCount): + try container.encode("unique_count", forKey: .type) + try uniqueCount.encode(to: encoder) + case .max(let max): + try container.encode("max", forKey: .type) + try max.encode(to: encoder) + case .min(let min): + try container.encode("min", forKey: .type) + try min.encode(to: encoder) + case .average(let average): + try container.encode("average", forKey: .type) + try average.encode(to: encoder) + case .sum(let sum): + try container.encode("sum", forKey: .type) + try sum.encode(to: encoder) + case .generic(let generic): + try generic.encode(to: encoder) + } } } diff --git a/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift index 20ccb01d8..f7627efa0 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift @@ -20,4 +20,6 @@ import Foundation Returns information from the document, including author name, title, RSS/ATOM feeds, prominent page image, and publication date. Supports URL and HTML input types only. */ -public typealias MetadataOptions = JSON +public struct MetadataOptions: Codable, Equatable { + public init() { } +} diff --git a/Source/PersonalityInsightsV3/PersonalityInsights.swift b/Source/PersonalityInsightsV3/PersonalityInsights.swift index 38af3a917..1a98fceb8 100644 --- a/Source/PersonalityInsightsV3/PersonalityInsights.swift +++ b/Source/PersonalityInsightsV3/PersonalityInsights.swift @@ -185,8 +185,6 @@ public class PersonalityInsights { - parameter rawScores: Indicates whether a raw score in addition to a normalized percentile is returned for each characteristic; raw scores are not compared with a sample population. By default, only normalized percentiles are returned. - - parameter csvHeaders: Indicates whether column labels are returned with a CSV response. By default, no column - labels are returned. Applies only when the response type is CSV (`text/csv`). - parameter consumptionPreferences: Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned. - parameter headers: A dictionary of request headers to be sent with this request. @@ -197,7 +195,6 @@ public class PersonalityInsights { contentLanguage: String? = nil, acceptLanguage: String? = nil, rawScores: Bool? = nil, - csvHeaders: Bool? = nil, consumptionPreferences: Bool? = nil, headers: [String: String]? = nil, completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) @@ -231,10 +228,6 @@ public class PersonalityInsights { let queryParameter = URLQueryItem(name: "raw_scores", value: "\(rawScores)") queryParameters.append(queryParameter) } - if let csvHeaders = csvHeaders { - let queryParameter = URLQueryItem(name: "csv_headers", value: "\(csvHeaders)") - queryParameters.append(queryParameter) - } if let consumptionPreferences = consumptionPreferences { let queryParameter = URLQueryItem(name: "consumption_preferences", value: "\(consumptionPreferences)") queryParameters.append(queryParameter) @@ -326,7 +319,7 @@ public class PersonalityInsights { csvHeaders: Bool? = nil, consumptionPreferences: Bool? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct body guard let body = profileContent.content else { diff --git a/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift index 7ae4bea11..5e89f3eff 100644 --- a/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift +++ b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift @@ -37,14 +37,14 @@ public struct SpeechRecognitionAlternative: Codable, Equatable { the word followed by its start and end time in seconds, for example: `[["hello",0.0,1.2],["world",1.2,2.5]]`. Timestamps are returned only for the best alternative. */ - public var timestamps: [String]? + public var timestamps: [WordTimestamp]? /** A confidence score for each word of the transcript as a list of lists. Each inner list consists of two elements: the word and its confidence score in the range of 0.0 to 1.0, for example: `[["hello",0.95],["world",0.866]]`. Confidence scores are returned only for the best alternative and only with results marked as final. */ - public var wordConfidence: [String]? + public var wordConfidence: [WordConfidence]? // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { diff --git a/Source/SpeechToTextV1/SpeechToText.swift b/Source/SpeechToTextV1/SpeechToText.swift index f673b61b2..880b71406 100644 --- a/Source/SpeechToTextV1/SpeechToText.swift +++ b/Source/SpeechToTextV1/SpeechToText.swift @@ -1640,7 +1640,7 @@ public class SpeechToText { wordTypeToAdd: String? = nil, customizationWeight: Double? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct header parameters var headerParameters = defaultHeaders @@ -1686,7 +1686,7 @@ public class SpeechToText { ) // execute REST request - request.responseObject(completionHandler: completionHandler) + request.response(completionHandler: completionHandler) } /** @@ -3098,7 +3098,7 @@ public class SpeechToText { customizationID: String, customLanguageModelID: String? = nil, headers: [String: String]? = nil, - completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) + completionHandler: @escaping (WatsonResponse?, WatsonError?) -> Void) { // construct header parameters var headerParameters = defaultHeaders @@ -3140,7 +3140,7 @@ public class SpeechToText { ) // execute REST request - request.responseObject(completionHandler: completionHandler) + request.response(completionHandler: completionHandler) } /** diff --git a/Source/TextToSpeechV1/TextToSpeech.swift b/Source/TextToSpeechV1/TextToSpeech.swift index 054de885d..8ceb43d49 100644 --- a/Source/TextToSpeechV1/TextToSpeech.swift +++ b/Source/TextToSpeechV1/TextToSpeech.swift @@ -358,7 +358,38 @@ public class TextToSpeech { ) // execute REST request - request.response(completionHandler: completionHandler) + request.response { (response: WatsonResponse?, error: WatsonError?) in + var response = response + guard let data = response?.result else { + completionHandler(response, error) + return + } + if accept?.lowercased().contains("audio/wav") == true { + // repair the WAV header + var wav = data + guard WAVRepair.isWAVFile(data: wav) else { + let error = WatsonError.other(message: "Expected returned audio to be in WAV format", metadata: nil) + completionHandler(nil, error) + return + } + WAVRepair.repairWAVHeader(data: &wav) + response?.result = wav + completionHandler(response, nil) + } else if accept?.lowercased().contains("ogg") == true && accept?.lowercased().contains("opus") == true { + do { + let decodedAudio = try TextToSpeechDecoder(audioData: data) + response?.result = decodedAudio.pcmDataWithHeaders + completionHandler(response, nil) + } catch { + let error = WatsonError.serialization(values: "returned audio") + completionHandler(nil, error) + return + } + } else { + completionHandler(response, nil) + } + } + } /** diff --git a/Source/ToneAnalyzerV3/ToneAnalyzer.swift b/Source/ToneAnalyzerV3/ToneAnalyzer.swift index c99cf62c2..6e4bae49c 100644 --- a/Source/ToneAnalyzerV3/ToneAnalyzer.swift +++ b/Source/ToneAnalyzerV3/ToneAnalyzer.swift @@ -153,11 +153,6 @@ public class ToneAnalyzer { - parameter sentences: Indicates whether the service is to return an analysis of each individual sentence in addition to its analysis of the full document. If `true` (the default), the service returns results for each sentence. - - parameter tones: **`2017-09-21`:** Deprecated. The service continues to accept the parameter for - backward-compatibility, but the parameter no longer affects the response. - **`2016-05-19`:** A comma-separated list of tones for which the service is to return its analysis of the input; - the indicated tones apply both to the full document and to individual sentences of the document. You can specify - one or more of the valid values. Omit the parameter to request results for all three tones. - parameter contentLanguage: The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for @@ -173,7 +168,6 @@ public class ToneAnalyzer { public func tone( toneContent: ToneContent, sentences: Bool? = nil, - tones: [String]? = nil, contentLanguage: String? = nil, acceptLanguage: String? = nil, headers: [String: String]? = nil, @@ -208,10 +202,6 @@ public class ToneAnalyzer { let queryParameter = URLQueryItem(name: "sentences", value: "\(sentences)") queryParameters.append(queryParameter) } - if let tones = tones { - let queryParameter = URLQueryItem(name: "tones", value: tones.joined(separator: ",")) - queryParameters.append(queryParameter) - } // construct REST request diff --git a/Source/VisualRecognitionV3/VisualRecognition.swift b/Source/VisualRecognitionV3/VisualRecognition.swift index 1e42df8eb..bc11276df 100644 --- a/Source/VisualRecognitionV3/VisualRecognition.swift +++ b/Source/VisualRecognitionV3/VisualRecognition.swift @@ -115,6 +115,16 @@ public class VisualRecognition { errorMessage = message } else if case let .some(.string(message)) = json["message"] { errorMessage = message + // ErrorAuthentication + } else if case let .some(.string(message)) = json["statusInfo"] { + errorMessage = message + // ErrorInfo + } else if case let .some(.object(errorObj)) = json["error"], // 404 + case let .some(.string(message)) = errorObj["description"] { + errorMessage = message + // ErrorHTML + } else if case let .some(.string(message)) = json["Error"] { // 413 + errorMessage = message } else { errorMessage = HTTPURLResponse.localizedString(forStatusCode: response.statusCode) } @@ -189,20 +199,17 @@ public class VisualRecognition { multipartFormData.append(thresholdData, withName: "threshold") } } - if let owners = owners { - for item in owners { - if let itemData = item.data(using: .utf8) { - multipartFormData.append(itemData, withName: "owners") - } - } + + // HAND EDIT: concat owners into csv data + if let csvOwners = owners?.joined(separator: ",").data(using: .utf8) { + multipartFormData.append(csvOwners, withName: "owners") } - if let classifierIDs = classifierIDs { - for item in classifierIDs { - if let itemData = item.data(using: .utf8) { - multipartFormData.append(itemData, withName: "classifier_ids") - } - } + + // HAND EDIT: concat classifier IDs into csv data + if let csvClassifierIDs = classifierIDs?.joined(separator: ",").data(using: .utf8) { + multipartFormData.append(csvClassifierIDs, withName: "classifier_ids") } + guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) return @@ -293,10 +300,10 @@ public class VisualRecognition { } positiveExamples.forEach { (classname, value) in let partName = "\(classname)_positive_examples" - multipartFormData.append(value, withName: partName, fileName: classname) + multipartFormData.append(value, withName: partName, fileName: "\(classname).zip") } if let negativeExamples = negativeExamples { - multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename") + multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename.zip") } guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) @@ -492,11 +499,11 @@ public class VisualRecognition { if let positiveExamples = positiveExamples { positiveExamples.forEach { (classname, value) in let partName = "\(classname)_positive_examples" - multipartFormData.append(value, withName: partName, fileName: classname) + multipartFormData.append(value, withName: partName, fileName: "\(classname).zip") } } if let negativeExamples = negativeExamples { - multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename") + multipartFormData.append(negativeExamples, withName: "negative_examples", fileName: negativeExamplesFilename ?? "filename.zip") } guard let body = try? multipartFormData.toData() else { completionHandler(nil, WatsonError.serialization(values: "request multipart form data")) From 4801d06d47cec36e3a02a4830d27fbfabe85b941 Mon Sep 17 00:00:00 2001 From: repjarms Date: Thu, 3 Oct 2019 12:00:57 -0400 Subject: [PATCH 03/13] feat(environment auth): make environment authenticator a throwable this allows us to throw specific errors from the ConfigBasedAuthenticatorFactory that can inform a user what is wrong with their configuration --- Source/AssistantV1/Assistant.swift | 7 +++---- Source/AssistantV2/Assistant.swift | 7 +++---- Source/CompareComplyV1/CompareComply.swift | 7 +++---- Source/DiscoveryV1/Discovery.swift | 6 ++---- .../LanguageTranslatorV3/LanguageTranslator.swift | 7 +++---- .../NaturalLanguageClassifier.swift | 6 ++---- .../NaturalLanguageUnderstanding.swift | 7 +++---- .../PersonalityInsightsV3/PersonalityInsights.swift | 7 +++---- Source/SpeechToTextV1/SpeechToText.swift | 6 ++---- Source/TextToSpeechV1/TextToSpeech.swift | 6 ++---- Source/ToneAnalyzerV3/ToneAnalyzer.swift | 7 +++---- Source/VisualRecognitionV3/VisualRecognition.swift | 13 ++++++------- 12 files changed, 35 insertions(+), 51 deletions(-) diff --git a/Source/AssistantV1/Assistant.swift b/Source/AssistantV1/Assistant.swift index 1ac8f0e25..fbbe79a0b 100644 --- a/Source/AssistantV1/Assistant.swift +++ b/Source/AssistantV1/Assistant.swift @@ -54,11 +54,10 @@ public class Assistant { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/AssistantV2/Assistant.swift b/Source/AssistantV2/Assistant.swift index de4f92062..ce6b996cb 100644 --- a/Source/AssistantV2/Assistant.swift +++ b/Source/AssistantV2/Assistant.swift @@ -55,11 +55,10 @@ public class Assistant { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/CompareComplyV1/CompareComply.swift b/Source/CompareComplyV1/CompareComply.swift index 78b2d31c2..1aaef9fd4 100644 --- a/Source/CompareComplyV1/CompareComply.swift +++ b/Source/CompareComplyV1/CompareComply.swift @@ -53,11 +53,10 @@ public class CompareComply { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/DiscoveryV1/Discovery.swift b/Source/DiscoveryV1/Discovery.swift index fef4cfefd..109b442ff 100644 --- a/Source/DiscoveryV1/Discovery.swift +++ b/Source/DiscoveryV1/Discovery.swift @@ -55,11 +55,9 @@ public class Discovery { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/LanguageTranslatorV3/LanguageTranslator.swift b/Source/LanguageTranslatorV3/LanguageTranslator.swift index 828763427..3226b2e4f 100644 --- a/Source/LanguageTranslatorV3/LanguageTranslator.swift +++ b/Source/LanguageTranslatorV3/LanguageTranslator.swift @@ -55,11 +55,10 @@ public class LanguageTranslator { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift index ee7aab160..3ab08fd2d 100644 --- a/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift +++ b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift @@ -51,10 +51,8 @@ public class NaturalLanguageClassifier { In that case, try another initializer that directly passes in the credentials. */ - public init?() { - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + public init() throws { + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift index f1f2a0585..79b247fa9 100644 --- a/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift +++ b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift @@ -57,11 +57,10 @@ public class NaturalLanguageUnderstanding { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/PersonalityInsightsV3/PersonalityInsights.swift b/Source/PersonalityInsightsV3/PersonalityInsights.swift index 1a98fceb8..2110a0e42 100644 --- a/Source/PersonalityInsightsV3/PersonalityInsights.swift +++ b/Source/PersonalityInsightsV3/PersonalityInsights.swift @@ -64,11 +64,10 @@ public class PersonalityInsights { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/SpeechToTextV1/SpeechToText.swift b/Source/SpeechToTextV1/SpeechToText.swift index 880b71406..a7d441990 100644 --- a/Source/SpeechToTextV1/SpeechToText.swift +++ b/Source/SpeechToTextV1/SpeechToText.swift @@ -63,10 +63,8 @@ public class SpeechToText { In that case, try another initializer that directly passes in the credentials. */ - public init?() { - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + public init() throws { + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/TextToSpeechV1/TextToSpeech.swift b/Source/TextToSpeechV1/TextToSpeech.swift index 8ceb43d49..8c3ee4134 100644 --- a/Source/TextToSpeechV1/TextToSpeech.swift +++ b/Source/TextToSpeechV1/TextToSpeech.swift @@ -60,10 +60,8 @@ public class TextToSpeech { In that case, try another initializer that directly passes in the credentials. */ - public init?() { - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + public init() throws { + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/ToneAnalyzerV3/ToneAnalyzer.swift b/Source/ToneAnalyzerV3/ToneAnalyzer.swift index 6e4bae49c..a71831b9e 100644 --- a/Source/ToneAnalyzerV3/ToneAnalyzer.swift +++ b/Source/ToneAnalyzerV3/ToneAnalyzer.swift @@ -58,11 +58,10 @@ public class ToneAnalyzer { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { diff --git a/Source/VisualRecognitionV3/VisualRecognition.swift b/Source/VisualRecognitionV3/VisualRecognition.swift index bc11276df..5d33650b7 100644 --- a/Source/VisualRecognitionV3/VisualRecognition.swift +++ b/Source/VisualRecognitionV3/VisualRecognition.swift @@ -53,11 +53,10 @@ public class VisualRecognition { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { @@ -115,14 +114,14 @@ public class VisualRecognition { errorMessage = message } else if case let .some(.string(message)) = json["message"] { errorMessage = message - // ErrorAuthentication + // ErrorAuthentication } else if case let .some(.string(message)) = json["statusInfo"] { errorMessage = message - // ErrorInfo + // ErrorInfo } else if case let .some(.object(errorObj)) = json["error"], // 404 case let .some(.string(message)) = errorObj["description"] { errorMessage = message - // ErrorHTML + // ErrorHTML } else if case let .some(.string(message)) = json["Error"] { // 413 errorMessage = message } else { From 82df050c62ec53cc4c9a275079e16da6d3c5f911 Mon Sep 17 00:00:00 2001 From: repjarms Date: Tue, 26 Nov 2019 10:04:16 -0500 Subject: [PATCH 04/13] feat(hand edit): make discoveryv2 environment init throwable --- Source/DiscoveryV2/Discovery.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/DiscoveryV2/Discovery.swift b/Source/DiscoveryV2/Discovery.swift index 403499b46..8fda25461 100644 --- a/Source/DiscoveryV2/Discovery.swift +++ b/Source/DiscoveryV2/Discovery.swift @@ -55,11 +55,10 @@ public class Discovery { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { From 64542e24b5053dc855394ea6dfc484529e8dddff Mon Sep 17 00:00:00 2001 From: repjarms Date: Thu, 3 Oct 2019 12:25:14 -0400 Subject: [PATCH 05/13] feat(hand edit): make VR V4 environment init throwable this should be provided by the generator in future releases --- Source/VisualRecognitionV4/VisualRecognition.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/VisualRecognitionV4/VisualRecognition.swift b/Source/VisualRecognitionV4/VisualRecognition.swift index 397af8856..b6699c4d2 100644 --- a/Source/VisualRecognitionV4/VisualRecognition.swift +++ b/Source/VisualRecognitionV4/VisualRecognition.swift @@ -53,11 +53,10 @@ public class VisualRecognition { - parameter version: The release date of the version of the API to use. Specify the date in "YYYY-MM-DD" format. */ - public init?(version: String) { + public init(version: String) throws { self.version = version - guard let authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) else { - return nil - } + + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator if let serviceURL = CredentialUtils.getServiceURL(credentialPrefix: serviceSdkName) { From 49018cefccc2ce5e3ca651840ef00e8ee046b9c9 Mon Sep 17 00:00:00 2001 From: repjarms Date: Fri, 22 Nov 2019 10:58:57 -0500 Subject: [PATCH 06/13] feat(hand edit): add discriminator support for QueryAggregation --- .../DiscoveryV2/Models/QueryAggregation.swift | 91 +++++++++++++++++-- 1 file changed, 81 insertions(+), 10 deletions(-) diff --git a/Source/DiscoveryV2/Models/QueryAggregation.swift b/Source/DiscoveryV2/Models/QueryAggregation.swift index b69c4733b..51a44a150 100644 --- a/Source/DiscoveryV2/Models/QueryAggregation.swift +++ b/Source/DiscoveryV2/Models/QueryAggregation.swift @@ -16,20 +16,91 @@ import Foundation -/** - An abstract aggregation type produced by Discovery to analyze the input provided. - */ -public struct QueryAggregation: Codable, Equatable { +/** An aggregation produced by the Discovery service to analyze the input provided. */ +public enum QueryAggregation: Codable, Equatable { + + // reference: https://cloud.ibm.com/docs/services/discovery/query-reference.html#aggregations - /** - The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, - average, unique_count, and top_hits. - */ - public var type: String + case term(QueryTermAggregation) + case filter(QueryFilterAggregation) + case nested(QueryNestedAggregation) + case histogram(QueryHistogramAggregation) + case timeslice(QueryTimesliceAggregation) + case topHits(QueryTopHitsAggregation) + case uniqueCount(QueryCalculationAggregation) + case max(QueryCalculationAggregation) + case min(QueryCalculationAggregation) + case average(QueryCalculationAggregation) + case sum(QueryCalculationAggregation) + case generic(GenericQueryAggregation) - // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case type = "type" } + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + guard let type = try container.decodeIfPresent(String.self, forKey: .type) else { + // the specification does not identify `type` as a required field, + // so we need a generic catch-all in case it is not present + self = .generic(try GenericQueryAggregation(from: decoder)) + return + } + switch type { + case "term": self = .term(try QueryTermAggregation(from: decoder)) + case "filter": self = .filter(try QueryFilterAggregation(from: decoder)) + case "nested": self = .nested(try QueryNestedAggregation(from: decoder)) + case "histogram": self = .histogram(try QueryHistogramAggregation(from: decoder)) + case "timeslice": self = .timeslice(try QueryTimesliceAggregation(from: decoder)) + case "top_hits": self = .topHits(try QueryTopHitsAggregation(from: decoder)) + case "unique_count": self = .uniqueCount(try QueryCalculationAggregation(from: decoder)) + case "max": self = .max(try QueryCalculationAggregation(from: decoder)) + case "min": self = .min(try QueryCalculationAggregation(from: decoder)) + case "average": self = .average(try QueryCalculationAggregation(from: decoder)) + case "sum": self = .sum(try QueryCalculationAggregation(from: decoder)) + default: self = .generic(try GenericQueryAggregation(from: decoder)) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + switch self { + case .term(let term): + try container.encode("term", forKey: .type) + try term.encode(to: encoder) + case .filter(let filter): + try container.encode("filter", forKey: .type) + try filter.encode(to: encoder) + case .nested(let nested): + try container.encode("nested", forKey: .type) + try nested.encode(to: encoder) + case .histogram(let histogram): + try container.encode("histogram", forKey: .type) + try histogram.encode(to: encoder) + case .timeslice(let timeslice): + try container.encode("timeslice", forKey: .type) + try timeslice.encode(to: encoder) + case .topHits(let topHits): + try container.encode("top_hits", forKey: .type) + try topHits.encode(to: encoder) + case .uniqueCount(let uniqueCount): + try container.encode("unique_count", forKey: .type) + try uniqueCount.encode(to: encoder) + case .max(let max): + try container.encode("max", forKey: .type) + try max.encode(to: encoder) + case .min(let min): + try container.encode("min", forKey: .type) + try min.encode(to: encoder) + case .average(let average): + try container.encode("average", forKey: .type) + try average.encode(to: encoder) + case .sum(let sum): + try container.encode("sum", forKey: .type) + try sum.encode(to: encoder) + case .generic(let generic): + try generic.encode(to: encoder) + } + } + } From fda100946955474985a677a94ce6e1c0d05d36d4 Mon Sep 17 00:00:00 2001 From: repjarms Date: Thu, 3 Oct 2019 16:53:12 -0400 Subject: [PATCH 07/13] fix(hand edit): parse "collectionIDs" and "features" into csv data this is required by the service and is a necessary hand edit for the time being. --- .../VisualRecognition.swift | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/VisualRecognitionV4/VisualRecognition.swift b/Source/VisualRecognitionV4/VisualRecognition.swift index b6699c4d2..53cd10da0 100644 --- a/Source/VisualRecognitionV4/VisualRecognition.swift +++ b/Source/VisualRecognitionV4/VisualRecognition.swift @@ -55,7 +55,7 @@ public class VisualRecognition { */ public init(version: String) throws { self.version = version - + let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName) self.authenticator = authenticator @@ -161,16 +161,17 @@ public class VisualRecognition { { // construct body let multipartFormData = MultipartFormData() - for item in collectionIDs { - if let itemData = item.data(using: .utf8) { - multipartFormData.append(itemData, withName: "collection_ids") - } + + // HAND EDIT: join collectionIDs into CSV string + if let csvCollectionIDsData = collectionIDs.joined(separator: ",").data(using: .utf8) { + multipartFormData.append(csvCollectionIDsData, withName: "collection_ids") } - for item in features { - if let itemData = item.data(using: .utf8) { - multipartFormData.append(itemData, withName: "features") - } + + // HAND EDIT: join features into CSV string + if let csvFeaturesData = features.joined(separator: ",").data(using: .utf8) { + multipartFormData.append(csvFeaturesData, withName: "features") } + if let imagesFile = imagesFile { for item in imagesFile { multipartFormData.append(item.data, withName: "images_file", mimeType: item.contentType, fileName: item.filename) From 80378efe2f3a1d7d656646838036e222c4d0d471 Mon Sep 17 00:00:00 2001 From: repjarms Date: Fri, 17 Jan 2020 15:08:10 -0500 Subject: [PATCH 08/13] fix(hand edit): keep model in CategoriesOptions --- .../Models/CategoriesOptions.swift | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift b/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift index 9e7b1b84f..feeac1b3d 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/CategoriesOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2017, 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,6 @@ public struct CategoriesOptions: Codable, Equatable { Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. - The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom - categories models will no longer be accessible in Natural Language Understanding. The feature will be removed from - Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge Studio on - 17 December 2019. */ public var model: String? @@ -53,18 +49,12 @@ public struct CategoriesOptions: Codable, Equatable { /** Initialize a `CategoriesOptions` with member variables. - - parameter explanation: Set this to `true` to return explanations for each categorization. **This is available only for English categories.**. - parameter limit: Maximum number of categories to return. - parameter model: Enter a [custom model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. - The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom - categories models will no longer be accessible in Natural Language Understanding. The feature will be removed - from Knowledge Studio on an earlier date. Custom categories models will no longer be accessible in Knowledge - Studio on 17 December 2019. - - returns: An initialized `CategoriesOptions`. */ public init( From 44040c6f62326d61cf2669ca44fae53267f59be1 Mon Sep 17 00:00:00 2001 From: repjarms Date: Tue, 26 May 2020 09:15:26 -0400 Subject: [PATCH 09/13] test(integration tests): update tests for new operations --- Tests/AssistantV2Tests/AssistantV2Tests.swift | 32 +++++++++++++++++++ .../VisualRecognitionV4Tests.swift | 29 +++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/Tests/AssistantV2Tests/AssistantV2Tests.swift b/Tests/AssistantV2Tests/AssistantV2Tests.swift index 56c051da5..516b372e8 100644 --- a/Tests/AssistantV2Tests/AssistantV2Tests.swift +++ b/Tests/AssistantV2Tests/AssistantV2Tests.swift @@ -41,6 +41,7 @@ class AssistantV2Tests: XCTestCase { ("testDeleteSession", testDeleteSession), ("testDeleteSessionWithInvalidSessionID", testDeleteSessionWithInvalidSessionID), ("testMessage", testMessage), + ("testMessageStateless", testMessageStateless), ("testMessageWithInvalidSessionID", testMessageWithInvalidSessionID), ] } @@ -279,6 +280,37 @@ class AssistantV2Tests: XCTestCase { waitForExpectations() } + func testMessageStateless() { + let description = "Test message stateless" + let statelessMessageExpectation = self.expectation(description: description) + + let testInput: MessageInputStateless = MessageInputStateless(messageType: "text", text: "This is a test", intents: nil, entities: nil, suggestionID: nil, options: nil) + + let testGlobalContext: MessageContextGlobalStateless = MessageContextGlobalStateless(system: nil, sessionID: nil) + let testContext: MessageContextStateless = MessageContextStateless(global: testGlobalContext, skills: nil) + + assistant.messageStateless(assistantID: assistantID, input: testInput, context: testContext, headers: nil) { + response, error in + + if let error = error { + XCTFail(unexpectedErrorMessage(error)) + return + } + + guard let messageResponse = response?.result else { + XCTFail(missingResultMessage) + return + } + + XCTAssertNotNil(messageResponse.output) + XCTAssertNotNil(messageResponse.context) + + statelessMessageExpectation.fulfill() + } + + waitForExpectations() + } + func testMessageWithSystemEntity() { let description1 = "Create a session" let expectation1 = self.expectation(description: description1) diff --git a/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift b/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift index caab24d57..1dd736731 100644 --- a/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift +++ b/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift @@ -457,6 +457,35 @@ class VisualRecognitionV4Tests: XCTestCase { waitForExpectations() } + + // MARK: - Downloading model files locally + + func testGetModelFile() { + let description = "Get Model File" + let modelFileExpectation = self.expectation(description: description) + + visualRecognition.getModelFile(collectionID: collectionID, feature: "objects", modelFormat: "rscnn", headers: nil) { + response, error in + + // make sure we didn't get an error + if let error = error { + XCTFail(unexpectedErrorMessage(error)) + return + } + + // make sure we got a response + guard let modelData = response?.result else { + XCTFail("No model data returned") + return + } + + // we expect the model to contain data + XCTAssertFalse(modelData.isEmpty) + + modelFileExpectation.fulfill() + } + waitForExpectations() + } // MARK: - Managing images in a collection From 9a41be20a4ab8c4355df9ac595b67b3c1d3612fb Mon Sep 17 00:00:00 2001 From: repjarms Date: Wed, 27 May 2020 12:59:20 -0400 Subject: [PATCH 10/13] fix(hand edit): keep system as a [String: JSON]? the generator overwrote it into a defined model which would be a breaking change --- Source/AssistantV2/Models/MessageContextSkill.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/AssistantV2/Models/MessageContextSkill.swift b/Source/AssistantV2/Models/MessageContextSkill.swift index 66cb6006d..099ff03fd 100644 --- a/Source/AssistantV2/Models/MessageContextSkill.swift +++ b/Source/AssistantV2/Models/MessageContextSkill.swift @@ -31,7 +31,7 @@ public struct MessageContextSkill: Codable, Equatable { /** System context data used by the skill. */ - public var system: MessageContextSkillSystem? + public var system: [String: JSON]? // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { @@ -49,7 +49,7 @@ public struct MessageContextSkill: Codable, Equatable { */ public init( userDefined: [String: JSON]? = nil, - system: MessageContextSkillSystem? = nil + system: [String: JSON]? = nil ) { self.userDefined = userDefined From 168aa3ec872eb3b200a4fea320fee43dddcebc47 Mon Sep 17 00:00:00 2001 From: repjarms Date: Wed, 27 May 2020 13:33:47 -0400 Subject: [PATCH 11/13] chore(vr test instance): update instance credentials --- .travis.yml | 263 +++++++++++++----- .../WatsonCredentials.swift.enc | Bin 4320 -> 4320 bytes .../VisualRecognitionV4Tests.swift | 2 +- 3 files changed, 197 insertions(+), 68 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc4c8eb99..dd2a61c01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ osx_image: xcode10.1 -before_install: addons: homebrew: packages: @@ -18,132 +17,262 @@ jobs: language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme AssistantV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme AssistantV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme AssistantV2 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme AssistantV2 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme CompareComplyV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme CompareComplyV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme DiscoveryV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme DiscoveryV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme LanguageTranslatorV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme LanguageTranslatorV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme NaturalLanguageClassifierV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme NaturalLanguageClassifierV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme NaturalLanguageUnderstandingV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme NaturalLanguageUnderstandingV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme PersonalityInsightsV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme PersonalityInsightsV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme SpeechToTextV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme SpeechToTextV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme TextToSpeechV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme TextToSpeechV1 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme ToneAnalyzerV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme ToneAnalyzerV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme VisualRecognitionV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme VisualRecognitionV3 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - os: osx language: objective-c osx_image: xcode11 before_install: - - brew install carthage || true - - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json -d - - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json -d + - brew install carthage || true + - openssl aes-256-cbc -K $encrypted_6b91f4629b52_key -iv $encrypted_6b91f4629b52_iv + -in ./Source/SupportingFiles/WatsonCredentials.swift.enc -out ./Source/SupportingFiles/WatsonCredentials.swift + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-input.json + -d + - openssl aes-256-cbc -K $encrypted_d84ac0b7eb5c_key -iv $encrypted_d84ac0b7eb5c_iv + -in Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json.enc + -out Tests/CompareComplyV1Tests/Resources/cloud-object-storage-credentials-output.json + -d install: carthage bootstrap --platform iOS --no-use-binaries --cache-builds - script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj -scheme VisualRecognitionV4 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ 11 build test | xcpretty + script: set -o pipefail && travis_retry xcodebuild -project WatsonDeveloperCloud.xcodeproj + -scheme VisualRecognitionV4 -destination platform\=iOS\ Simulator,OS\=13.0,name\=iPhone\ + 11 build test | xcpretty - stage: release new version script: "./Scripts/travis/new-release.sh" os: osx @@ -153,4 +282,4 @@ jobs: script: "./Scripts/travis/deploy-to-cocoapods.sh" os: osx osx_image: xcode11 - if: branch = master AND type = push AND fork = false \ No newline at end of file + if: branch = master AND type = push AND fork = false diff --git a/Source/SupportingFiles/WatsonCredentials.swift.enc b/Source/SupportingFiles/WatsonCredentials.swift.enc index dcb7b448037f2f4bc67559a25e0dcd31d5620a2d..8575788e6894fe268f739322f332e933bcb16074 100644 GIT binary patch literal 4320 zcmV<65FhUsE>{koLbZ+PV}y?(nJ*ylF@=WxAK{gU1v?vPQ;I!j9ZfLusC}ymM=rf& zQ_Kas+CVc`FmQe_kSc8Qv7xQtJuQbq0V1zXck%tHV74kvm)qkEnqw6(Yusso5 z%`cCa2mq~vU4l11%q;e###6x{TBuQovQtMa?>qR7bXm1cXBXX$+G;E!Wj4hQIyi>R zxo|ZNC6j-}1ugo%hpNT4kxO{24^qN}`_@!}c@cB-V#fS*;fF`RrFcV(oAl}fWN{WX zByl-c#?CB9G-gE;)tO=)XU@fTXEFt@jYX1V4LS|Hya#i7>XPNhcG9SgilS?#NnNKM z!#o=iP%gZms0VDvf1}MtnPSO>=Lg+mDLqI zE7&>z4P*{m)5~Iokn1SRo89;JYpYDm3L3f1(sA?1g$-<4f|}6W#y%(tFjkNurIncM zZ*}(|I?yE3O8fRYTJ!v;eOj1y3`*DgI|vM?l1>HgFcLm5*F66aO2Gcq_B6CAN=O}w zV1uIAFr&@f#LjtiGqRMHIZG-V*ETrKyI1M9P}Y)tjq}m@j1~$r#027ZU$*s}MU>%E z2tTG&=ef)^RDD8+aE#V(P6_z(lCiRY%1Pl@0J~unRcAn`b0*ab&|zJQ{LbWVt_wf> zj5%_ewTtgjp0)PEa3HvoW!t-_V(exx{NPd>BRCU!97& z0^lGgfeX1M6b?50+|u#;mWqRFSAm*+&b=1M`aNPV+j(&betqA2XU2bFwYIC5IjMtm zR%RUMS2Z8mvCEg&HQyA!f7^}m5HV*^g&76e{G}5sNrM1o^ABuX)B{&-ku)gigf!m=23YV zky5dFtpcRoEFmVjm_j23AmD%_L3nc+S8pt>hrFlJ1ypW>P89E}f+jT9-E9(9=!<$c zpHq7K#(-rY?oHoC?Dj$3p9+ZAfhe9=iPLjE-_7~g!@+ph5Lq&OIikrE*~>i{46^JQ zEs$a&=oMflN(NCO9%vlYrB)1|1QdzuqM-~oNePo8_5C(7@qk@OX~7}r+3?N;JQbMi z5Ozx%eVm92e9F%7PbMEqMCjlvDe>U^qxz=Zlo>K(H{J|7 zD&=bN$3%FT-mv{==KSG|^Nw#XVYMsK!<(3VG5ZC#he=r0*W9rzWc~~*TkXo1?oH)i zwJn+6k$B%^gY)?K>NeGw+vrgkSbYygbR6K15`n`Yvv+3dDO>}%gPa^@hUQqwv{O+Xa{6I3UkY$@<)7>NL z1ej1WIH%s)u8zGefXfFd{^{=))#OhZ0t-&;3U zHWx{m$@=uU7|?gZ6}-Sfc=VNB0(A`kc8*JvqP6elNO}M`m6-I#uq;t*T5*-XJmY)asvQwY(%@tp0xkM^vVEt6;=AMWt_eJpL`yo+; z26rO*8bHsOMV&LKj~x3m?S2msT9`77+&P%L5XFUxzeh_s9ra@lq{Bg3gWn001kq>V zHHzn#@v?-KtPsf0FtNHmF^?q0Uzi_^Y(QU_Z=11MnGYZd@ zD1C1AU2Xlay-(;qHYcbjs~dT7ws;~GA-PnbD6N6c_;_ww_k-oqAJqt)r*Qb|_6+6~ zh0qoagoCTVq!rs=mk73QS=I=b{Rh@C4+#E)Wbd3x#2PrSO|0*mUXb~40R~t1G)_G@ z=RYv#h?7GgHxmEjMxp5BCR{-LK8n9Am5;g1@Mq@g+Oj>2e~(}%C2sbuVzcF95I&7r zLbeueN-dVO1D5I;=a)|(?w8czjMTvro+rrA=B7~Q_d^R@iN;;C5hJF>lNzM>Va+Fl z<9{Coa5uSfmny<;g#Xr81hWp=K7P<$C=Cip`9CT<&CdG6iCO0bOc>0qNO8X;1!g^= zHq15Oc=|xLGX{v~wWM#hX+`UQZ9sB=HIeWYuv3E?qDQL5E?Cf99=iI*0m&C|7&O!k z*_{Ctk&)KUVdaFWYLhruEGSvR&<}3>#2vkd;yHi>c?m{Au+-99NK|{X3_N`df>YD1 zFff<^cpN>0$`>Tna2nFe7;M;$3cX&<7*>*JXS7m~@ny%}59t5aY`J|Iq|5415Y%+Y|ega zYUQ1+oM#2&+uR$hnkhx3rP;Um@4MAwSUHbbRP+v21G#=;?@m@`d^FL|NDDu#Z6iBy zZouCa;$il=sk~WaNCA=Mx>T8UFHdta{F$d#2S^5F$;HZO^|HKxf&H4@wUzBgs|*5n zJ3qV#3ApiigaaUlPgl>>h}=ON;heI6Ho(gnMOshQF&sH1R-T}{zYgN;9d8*w3rYXa zp^~F&w2=KP4aDG>z{&P4m#fmXyc>#3w7=0)G`lnr`Zjn1=NNVhEbmpmX?@gyU9L6Vk;LT*U|IU;P9=}bYA!v*59I<1FA&!O<)`)|Gh}u zG5y2+V6tRjz5o_VbJ&CV96>b=jxid=$~WCcRDU6vp^gfFUm&7lj06i2{A`8F2k@O+ zrqrai(qB{VHcwr71c{{h0YxsBDk#nzhB)MH%iIhmly{Am6%l#$8pyU}b!tkB&2Gf} zJ2K~6J7+5@RvzIH_>gLAVGJ_yO(WFR|J`Xtlp-1SJ&~UCT2MOM zEB+`!kTdx7c3mNkG@~r>1ENr(@BRX_HG21xr|vAOAb$g|PuVK8W_}P1e(Dyg`%j-| zeo6b$<&E68Al?=8lq9fwO|qVOm=cGkNZ2Nav?->Q|0ca{nL9dp4h}VIT}!|Xflemj zA#;e%AM*XQYHbnL#6awYP>w;ZYJ(fWO64t3#obn$>K&pNfVc^$ycc&UqbgCXv z+cO4%QFz+5P&#p0XB*jj5sCV2BWPS_*t{@}maM5$gE6$lt{9%PUQX>l9K*35HGWrE z{NiB}z@_1!MliYq65x~6+9D;@4gZ-uDMUwG#b$#HG!uyUn$@qGD1c)niz^_cu8xe# zxnaM>K9deBUCc0ZqSNhyu-uDfWId?qKA4pD!fx~b3JqXoL0o2l)uyr)#5haCN=Zx2f`%Upg5jih%`z5|Sh9~?Of0;~Qw`8KzN{i8Tk)Rdw4?(m>mo}E|r>2N=e`6R7bM;JW1`5_)ySicb#M34#}$Ng|toXdG-->kI#OMBVC zM@$_kbZ8eto^_>?>oBX(bl%+4>7&=On z3{tbn;7;(mPyhj%rdtjZiK98nq{AW?p`1x*x6Onb4(ZPlJql4Um`C~^NYts2jEZuP z=5W@Gos|pALgWBY8Qx!+!{>CQZn{%^_1g#V8!Ej4#RvxKYyPR2hqZM*VIca9U_j34=fvwWs~5;#n+8kfwdaID_0?>Qav3RNd2me!?*4n!pmE z2$Fkvp(Q(22L<5pQE>mojDtL;vi5F=vKZ8z^v7~~y)RD#0BKp=BbRmW+y^IR*OO)+ z^D^Az*P0>7{bSe;w(gZg&Q+-#7vfD}MmuKjL^?|LUS{nxiP~T9SuCSyT~?;~v$?y9 zsYOi3wMhh!`C=_v`br5;UIXH0Cy7$sKj6=S5m5#sV;ExHTs&MIU3Fc56!rqo`kKqH zVv-j}H_O6sGK-ijz`$)h*J5S&JGDQCc&3B;d~gmzKdT|zogH%SK8D39u>BPf^1o!2 zLT-u1^=6r_SZR{|PL!mtl9F{EmwsQoPhWv3OyBr<@{Y6%7d>obLs(jI<7p|FjuF`- zwyY$|7W8eN@+Od4NfgS`Y*lu!wB)o^7oUrut1YTFDagp?Szcz`pLB!O;7}1Em$>O( z1@8~L%lr{3f*A{bxk&@prraD}_NEklHh%Hsr_fifM9e9_7*V#m|D+)w+kU3>hM&N_ ztVKC*c9rRy49J7*Id#3T<6E>m8#WA`DiOl^;365G7+kkR zIC6fWV~Ak_IEbYZ#h16$bkxgD+uV15FIH^({NvIa8M{kU?+`L@m#%)`tJp|*FZvL z<1W+EeOk}bVO!U|#}^=|-;J^-qJB#hhFM{9s%zSg8yd4%T$X-{QXoEBIpv;1cT~)7IdB$?DI5ltG?cDutndCXZGZ4I z%_rQ$j!?T%JiYRXmwH=3mCU+0$s{5qTeJBq`}0-xF&)W_(Ex*5aJL~ z4!i)<74+Xei3>frx?0vySY+M_v0634G*~}vA`)XSC9%z5XA4xBHbCX^yHjt#isOm^ zfwSnbkcwY6kribddqFE)Ba{KAcKT*0!nbyp*|_OSrW3M9pMt|}^KG==@W%pzA9lwE z|H%%5$xS$=*TgZdQ!aV!X}87iZ=lAB5G@RCg|gg+2r^s+oztBiNEaamf^HeuJ%shEEFK$-x>;3`Oi>n;F@_xPE(Kq1)lx zkx19!AmbMNXYl1sc05hWA0q^Q&UpcTxlf3x)q_^uM0Ep$v~au&Emi%Z`p}@t%_uZ0 zIqeY7HaSHpNkjzU56HllcSb^-1)3b2sPxnfule4KCNu&ie=lsH{fX~0*pSom_O*`N5x5BQR8PX-cSD2}J^`^pme&A7$33;j z$sLJpwPR}aCJvKeQ=Iv~)xsh_9cdKm$kfyn!awQ^sG4>+^O137CkFqsU?hg9oZ_ow zrkIrJi%WFi$q@ux(eOvW94B!-9+jF%RD}X%s6SA#c93D3DEo zsT)eN(DPKGU(lzcJL@u3PJ@)$K&<_xdVy$Lt%Jso0s04v{*h(nhcPn}5u-7xxVeTE zh5fp)VanKFH;os66Hv$}wXxQz087Ys!6_D2rT+K%ylFkH%*0puXUo{m% z&oQ_WleQhjqT3i|fX~uNC{6N%)SSi;R!g6YNANy+;Fxh*n`A7Y^DxNnU1ScieM}xR4*+Ng{($&fC$Q-T>NxjMk;hDRS)ugJV}CXP2@nC#)UnlQPK= zPM4VikCI!DR7^~Sve#s!)t!s(;c+Eb$zf^{){=2mu#3Ih)5pn&(sXhPrNe{=@s^+W zm^={$;-XTV+?s7~_dECdobzaIcXdhCq!fa?s2|BW3WDUVPpcKP#H$jJ;Sxcc?R;`; z)bzVfMnbkEca7}4^y)N`$Mf=Sl88=YPDVIifFEiIT=OzZpeCtU0^V6xoOUeNDi2qq z<($AMbalBsOJ6wB9WBgpcUQcWf4UKPRrl_f_yG=Q__HHrgCCM+P0%kPkdhiDXmpTaOuV(v=>-P8~y;rG41iI+@{ z67F5}Fj4MdX8tiOVTxc4y-OXD{K&Xe>XVmfw#VUPJB>yD1RdyARmg!jAtZZ3o9rZ2 zIVK-l07INVz$`4hE#Nw|ys|C@;4Mk)LXAx97^(o++$p>UrbmVu{6V}MR&YP;r(4l{ zx<*^b$|z{{67vD4N=y2a#gkS&j0*jZ#MUe(pEIDf{{*|I8lkCw{2N$_siGndEugq}P> zj4~wwfJ9iXE4k1q?5;H7zwlbhdC7MUnw*CfD5amdIGE9h%wAM+p?7*nM!2w6 zvbFvy*m>VjBX_H_k3;oX4S4SP=a?%`z>k86nX4x*o+^!0 z<3*pmsL4=I2BYBUJ+15!ou*v~ zLP0uY``I0FQGtp!6jv}dQ?R?tRrHz{oY4Q%(=xqYxbXEZwntD9&KbIq!P-h$L@6E> zmSYQz-q5jXh1wFWY*+7H%H>4}yza)l(t_SaJDcywPuuAu2^LHjMI)BW+9zrlI0x8c zPug>WI4}5M;;TD7Ify<`REz=j4M|X^0qrF+x3(1q#4Z8H4kDPmx_RB)rei_L;66@; z;t8Vm0S7ATuS|*0<$U_F*hP7Y^GtU^7N*^a*0`fSQHO2BKd_Ge#9;^H1*2y&WL-=5 zQ@I1bPX*yG2YuARdcPednDm4(fK*cun))cmGpM-!*TECI7kOkX!ZlL!4(STipFg4ayZ@V>8l zJoUyNh$LARYl^)#jh%W@ayFwxc1vUrj&{-;LLv=pOa5?YTB zljh2N_Zb(Pz`dMg_3_ohrI+%Ig(5+Gj~!jiL3$8&l7pbRcFWlw0w~tT7=iToGctRA zSA{*GH@I#Lx?U5UWbsTM^-JyqVGn_kC@Yj?6>$VZhAXNhVOp?R^Gwwxhuc5)rJkR`>C5}u8U584e#%IItJiz79z0OXi8%dldMz`+AbxDp%3eB4 z--3upwK-K10n8+)+=Y#Qeukn!K|}1+PNY3 zNWp=JF>W94(|U+}il`fFo7poigo#Ajr8FyHWGLY#xBGpmNdhf{GwM>itDXpz!Chls zG8jIE2M5m-b7y7g(Kb@kOLEo6yfCjA#}xSqmGt#52XtG|MIaKQehi@<4XxsPFV`NQ zV~RM~B#<-wgC>)tF&l#^{A3-Zo%$iL=EHNI(K|e6Vg1uD=TRO`J>Y61vJ?FZ`Com| zPImg+*FSsKjQo$grkNZpzY5}f80))hz)d7m)b*9ZX&I?85jbZCQ2bmc9<>31G^+8< zKrDJZL^&_Z4V!}eF^m|Yn@F6}Ajoy5D#m)*XQx7ExvUUJ}_D%GLes00L_1dNpG{j-$#XO%-i`l})_6~UMqiACmK+Yvp-wTh$*&D}&#N4eF zl$zw`(Lt#B@3n<YZsOtF&xII`%l3BOM0xYhm3w^?+A%&iV&_7$RSNDZAsDh|0Vo_F;Z zP2LN6VdajrKGWUs?M%_dX>4&QZ0gduNjq|G zjDXmbkK{~yvO8*86_n2~)c5RXHmk!%{^2lHnPYPq34weKLR8**(R+jlsT|r;9B3kq z#EncGn@i_0>#Q|-Fjv`ImTnc=KV&1fKY0^k@x=CD!IqvMoH!m4^lDx#12Z9Ji-o55 z=51Si_SSbM+z)%oUh~5{8oc0E&4!ng#+8gaiVqyOy*)$jELNIm0qva#ksR;ay|(v_ z*tgVS^L)JdPpH^5aQOF1GPDE^HE_wN%KF`w-k0{-#A6p+ytDk&LrY*0t-SYRc#|Ar z)y(<^e{8%hYh?%bXY}yp7tT5CHTD-YD_Rq{0SQ`Z-oO O^4;YGzo-tU+YoVdk#3Lx diff --git a/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift b/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift index 1dd736731..d2be10385 100644 --- a/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift +++ b/Tests/VisualRecognitionV4Tests/VisualRecognitionV4Tests.swift @@ -29,7 +29,7 @@ class VisualRecognitionV4Tests: XCTestCase { private let collectionID = WatsonCredentials.VisualRecognitionV4CollectionID private let giraffeCollectionID = WatsonCredentials.VisualRecognitionV4GiraffeCollectionID private let trainingDummyCollectionID = WatsonCredentials.VisualRecognitionV4TrainingDummyCollectionID - private let trainingDummyImageID = "1280px-Giraffe_Ithala_KZN_South_4b75885f184a39650eab62a086601068" + private let trainingDummyImageID = "MV5BZWJhZTdmMjQtNWQxOC00YzMwLTg_005ade9d99ec84c2dfe56f634998f7b8" private let giraffeImageURL = giraffeURL static var allTests: [(String, (VisualRecognitionV4Tests) -> () throws -> Void)] { From 22640b0fb5bf34fbe1529a0df2905bfd1f6e543e Mon Sep 17 00:00:00 2001 From: repjarms Date: Wed, 3 Jun 2020 08:47:02 -0400 Subject: [PATCH 12/13] chore(copyrights): lint copyright dates --- Source/AssistantV1/Assistant.swift | 2 +- Source/AssistantV1/Models/DialogNodeOutputGeneric.swift | 2 +- Source/AssistantV1/Models/MessageInput.swift | 2 +- Source/AssistantV1/Models/WorkspaceSystemSettings.swift | 2 +- Source/AssistantV2/Assistant.swift | 2 +- Source/AssistantV2/Models/MessageContext.swift | 2 +- Source/AssistantV2/Models/MessageContextGlobal.swift | 2 +- Source/AssistantV2/Models/MessageContextSkill.swift | 2 +- Source/AssistantV2/Models/MessageContextSkills.swift | 2 +- Source/AssistantV2/Models/MessageInput.swift | 2 +- Source/AssistantV2/Models/MessageInputOptions.swift | 2 +- Source/AssistantV2/Models/MessageOutput.swift | 2 +- Source/AssistantV2/Models/MessageRequest.swift | 2 +- Source/AssistantV2/Models/MessageResponse.swift | 2 +- Source/AssistantV2/Models/SearchResult.swift | 2 +- Source/AssistantV2/Models/SearchResultHighlight.swift | 2 +- Source/CompareComplyV1/CompareComply.swift | 2 +- Source/DiscoveryV1/Discovery.swift | 2 +- Source/DiscoveryV1/Models/AggregationResult.swift | 2 +- Source/DiscoveryV1/Models/QueryAggregation.swift | 2 +- Source/DiscoveryV2/Discovery.swift | 2 +- Source/DiscoveryV2/Models/QueryAggregation.swift | 2 +- Source/LanguageTranslatorV3/LanguageTranslator.swift | 2 +- .../NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift | 2 +- .../NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift | 2 +- Source/NaturalLanguageUnderstandingV1/Models/Model.swift | 2 +- .../NaturalLanguageUnderstanding.swift | 2 +- Source/PersonalityInsightsV3/PersonalityInsights.swift | 2 +- Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift | 2 +- Source/SpeechToTextV1/SpeechToText.swift | 2 +- Source/TextToSpeechV1/TextToSpeech.swift | 2 +- Source/ToneAnalyzerV3/ToneAnalyzer.swift | 2 +- Source/VisualRecognitionV3/VisualRecognition.swift | 2 +- Source/VisualRecognitionV4/Models/ImageDetails.swift | 2 +- Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift | 2 +- Source/VisualRecognitionV4/VisualRecognition.swift | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Source/AssistantV1/Assistant.swift b/Source/AssistantV1/Assistant.swift index fbbe79a0b..14a6367ca 100644 --- a/Source/AssistantV1/Assistant.swift +++ b/Source/AssistantV1/Assistant.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift b/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift index 56202ae4c..42a47402c 100644 --- a/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift +++ b/Source/AssistantV1/Models/DialogNodeOutputGeneric.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV1/Models/MessageInput.swift b/Source/AssistantV1/Models/MessageInput.swift index 1b60c5985..8c5d15e45 100644 --- a/Source/AssistantV1/Models/MessageInput.swift +++ b/Source/AssistantV1/Models/MessageInput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2017, 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/Source/AssistantV1/Models/WorkspaceSystemSettings.swift b/Source/AssistantV1/Models/WorkspaceSystemSettings.swift index 65e375c58..962b7287f 100644 --- a/Source/AssistantV1/Models/WorkspaceSystemSettings.swift +++ b/Source/AssistantV1/Models/WorkspaceSystemSettings.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Assistant.swift b/Source/AssistantV2/Assistant.swift index ce6b996cb..120a1f778 100644 --- a/Source/AssistantV2/Assistant.swift +++ b/Source/AssistantV2/Assistant.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageContext.swift b/Source/AssistantV2/Models/MessageContext.swift index 62af7fa0b..f592c4fcc 100644 --- a/Source/AssistantV2/Models/MessageContext.swift +++ b/Source/AssistantV2/Models/MessageContext.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageContextGlobal.swift b/Source/AssistantV2/Models/MessageContextGlobal.swift index ad2c5c0d3..d5fe41c40 100644 --- a/Source/AssistantV2/Models/MessageContextGlobal.swift +++ b/Source/AssistantV2/Models/MessageContextGlobal.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageContextSkill.swift b/Source/AssistantV2/Models/MessageContextSkill.swift index 099ff03fd..d1fcb75c5 100644 --- a/Source/AssistantV2/Models/MessageContextSkill.swift +++ b/Source/AssistantV2/Models/MessageContextSkill.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/AssistantV2/Models/MessageContextSkills.swift b/Source/AssistantV2/Models/MessageContextSkills.swift index 6f2fb2cb4..fb71fd309 100644 --- a/Source/AssistantV2/Models/MessageContextSkills.swift +++ b/Source/AssistantV2/Models/MessageContextSkills.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageInput.swift b/Source/AssistantV2/Models/MessageInput.swift index 86cdff696..c76ac506c 100644 --- a/Source/AssistantV2/Models/MessageInput.swift +++ b/Source/AssistantV2/Models/MessageInput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageInputOptions.swift b/Source/AssistantV2/Models/MessageInputOptions.swift index 819c7e9aa..d9ac34fdf 100644 --- a/Source/AssistantV2/Models/MessageInputOptions.swift +++ b/Source/AssistantV2/Models/MessageInputOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageOutput.swift b/Source/AssistantV2/Models/MessageOutput.swift index b13b15b3a..41a14bb75 100644 --- a/Source/AssistantV2/Models/MessageOutput.swift +++ b/Source/AssistantV2/Models/MessageOutput.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageRequest.swift b/Source/AssistantV2/Models/MessageRequest.swift index 78de03d3e..fd5bb0f44 100644 --- a/Source/AssistantV2/Models/MessageRequest.swift +++ b/Source/AssistantV2/Models/MessageRequest.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/MessageResponse.swift b/Source/AssistantV2/Models/MessageResponse.swift index d6b2ac0c4..1872d6d28 100644 --- a/Source/AssistantV2/Models/MessageResponse.swift +++ b/Source/AssistantV2/Models/MessageResponse.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/AssistantV2/Models/SearchResult.swift b/Source/AssistantV2/Models/SearchResult.swift index 6eb48c35f..f48631678 100644 --- a/Source/AssistantV2/Models/SearchResult.swift +++ b/Source/AssistantV2/Models/SearchResult.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/AssistantV2/Models/SearchResultHighlight.swift b/Source/AssistantV2/Models/SearchResultHighlight.swift index 62d673925..6ee372be8 100644 --- a/Source/AssistantV2/Models/SearchResultHighlight.swift +++ b/Source/AssistantV2/Models/SearchResultHighlight.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/CompareComplyV1/CompareComply.swift b/Source/CompareComplyV1/CompareComply.swift index 1aaef9fd4..70222dded 100644 --- a/Source/CompareComplyV1/CompareComply.swift +++ b/Source/CompareComplyV1/CompareComply.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/DiscoveryV1/Discovery.swift b/Source/DiscoveryV1/Discovery.swift index 109b442ff..2dce3d4c2 100644 --- a/Source/DiscoveryV1/Discovery.swift +++ b/Source/DiscoveryV1/Discovery.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/DiscoveryV1/Models/AggregationResult.swift b/Source/DiscoveryV1/Models/AggregationResult.swift index 003d4acba..98da230f2 100644 --- a/Source/DiscoveryV1/Models/AggregationResult.swift +++ b/Source/DiscoveryV1/Models/AggregationResult.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2018, 2019. * * 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/Source/DiscoveryV1/Models/QueryAggregation.swift b/Source/DiscoveryV1/Models/QueryAggregation.swift index eac9278a8..2794f53a8 100644 --- a/Source/DiscoveryV1/Models/QueryAggregation.swift +++ b/Source/DiscoveryV1/Models/QueryAggregation.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2018. * * 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/Source/DiscoveryV2/Discovery.swift b/Source/DiscoveryV2/Discovery.swift index 8fda25461..8a79096b7 100644 --- a/Source/DiscoveryV2/Discovery.swift +++ b/Source/DiscoveryV2/Discovery.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/DiscoveryV2/Models/QueryAggregation.swift b/Source/DiscoveryV2/Models/QueryAggregation.swift index 51a44a150..28e03676a 100644 --- a/Source/DiscoveryV2/Models/QueryAggregation.swift +++ b/Source/DiscoveryV2/Models/QueryAggregation.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2019. * * 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/Source/LanguageTranslatorV3/LanguageTranslator.swift b/Source/LanguageTranslatorV3/LanguageTranslator.swift index 3226b2e4f..76c37d48f 100644 --- a/Source/LanguageTranslatorV3/LanguageTranslator.swift +++ b/Source/LanguageTranslatorV3/LanguageTranslator.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (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/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift index 3ab08fd2d..73f36785d 100644 --- a/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift +++ b/Source/NaturalLanguageClassifierV1/NaturalLanguageClassifier.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift index f7627efa0..95c7e89a5 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/MetadataOptions.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2017, 2019. * * 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/Source/NaturalLanguageUnderstandingV1/Models/Model.swift b/Source/NaturalLanguageUnderstandingV1/Models/Model.swift index 3c6abcac9..45c6bfb2e 100644 --- a/Source/NaturalLanguageUnderstandingV1/Models/Model.swift +++ b/Source/NaturalLanguageUnderstandingV1/Models/Model.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2017, 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/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift index 79b247fa9..36462233a 100644 --- a/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift +++ b/Source/NaturalLanguageUnderstandingV1/NaturalLanguageUnderstanding.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2017, 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/Source/PersonalityInsightsV3/PersonalityInsights.swift b/Source/PersonalityInsightsV3/PersonalityInsights.swift index 2110a0e42..8c0a5d265 100644 --- a/Source/PersonalityInsightsV3/PersonalityInsights.swift +++ b/Source/PersonalityInsightsV3/PersonalityInsights.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift index 5e89f3eff..6802419fa 100644 --- a/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift +++ b/Source/SpeechToTextV1/Models/SpeechRecognitionAlternative.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 2019. * * 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/Source/SpeechToTextV1/SpeechToText.swift b/Source/SpeechToTextV1/SpeechToText.swift index a7d441990..8a3f7d5ef 100644 --- a/Source/SpeechToTextV1/SpeechToText.swift +++ b/Source/SpeechToTextV1/SpeechToText.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/TextToSpeechV1/TextToSpeech.swift b/Source/TextToSpeechV1/TextToSpeech.swift index 8c3ee4134..076070001 100644 --- a/Source/TextToSpeechV1/TextToSpeech.swift +++ b/Source/TextToSpeechV1/TextToSpeech.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/ToneAnalyzerV3/ToneAnalyzer.swift b/Source/ToneAnalyzerV3/ToneAnalyzer.swift index a71831b9e..4cbb720ef 100644 --- a/Source/ToneAnalyzerV3/ToneAnalyzer.swift +++ b/Source/ToneAnalyzerV3/ToneAnalyzer.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/VisualRecognitionV3/VisualRecognition.swift b/Source/VisualRecognitionV3/VisualRecognition.swift index 5d33650b7..c34b83527 100644 --- a/Source/VisualRecognitionV3/VisualRecognition.swift +++ b/Source/VisualRecognitionV3/VisualRecognition.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2016, 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/Source/VisualRecognitionV4/Models/ImageDetails.swift b/Source/VisualRecognitionV4/Models/ImageDetails.swift index 6f3a019c5..4bfbe353d 100644 --- a/Source/VisualRecognitionV4/Models/ImageDetails.swift +++ b/Source/VisualRecognitionV4/Models/ImageDetails.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift b/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift index bb6047397..e6bb1e77a 100644 --- a/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift +++ b/Source/VisualRecognitionV4/Models/ObjectTrainingStatus.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. diff --git a/Source/VisualRecognitionV4/VisualRecognition.swift b/Source/VisualRecognitionV4/VisualRecognition.swift index 53cd10da0..78d0cf955 100644 --- a/Source/VisualRecognitionV4/VisualRecognition.swift +++ b/Source/VisualRecognitionV4/VisualRecognition.swift @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 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. From b3fb5ed64da3bd536f50437f8bb118718b141a27 Mon Sep 17 00:00:00 2001 From: repjarms Date: Thu, 4 Jun 2020 09:41:36 -0400 Subject: [PATCH 13/13] fix(hand edit): maintain MessageInputOptions parameter position --- Source/AssistantV2/Models/MessageInputOptions.swift | 6 +++--- Tests/AssistantV2Tests/AssistantV2Tests.swift | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/AssistantV2/Models/MessageInputOptions.swift b/Source/AssistantV2/Models/MessageInputOptions.swift index d9ac34fdf..5f5c85c15 100644 --- a/Source/AssistantV2/Models/MessageInputOptions.swift +++ b/Source/AssistantV2/Models/MessageInputOptions.swift @@ -90,12 +90,12 @@ public struct MessageInputOptions: Codable, Equatable { - returns: An initialized `MessageInputOptions`. */ public init( + debug: Bool? = nil, restart: Bool? = nil, alternateIntents: Bool? = nil, - spelling: MessageInputOptionsSpelling? = nil, - debug: Bool? = nil, returnContext: Bool? = nil, - export: Bool? = nil + export: Bool? = nil, + spelling: MessageInputOptionsSpelling? = nil ) { self.restart = restart diff --git a/Tests/AssistantV2Tests/AssistantV2Tests.swift b/Tests/AssistantV2Tests/AssistantV2Tests.swift index 516b372e8..8b3480c3f 100644 --- a/Tests/AssistantV2Tests/AssistantV2Tests.swift +++ b/Tests/AssistantV2Tests/AssistantV2Tests.swift @@ -238,7 +238,8 @@ class AssistantV2Tests: XCTestCase { let description3 = "Continue a conversation." let expectation3 = self.expectation(description: description3) - let messageInput = MessageInput(messageType: MessageInput.MessageType.text.rawValue, text: "I'm good, how are you?") + let messageInputOptions = MessageInputOptions(debug: false, restart: false, alternateIntents: false, returnContext: true, export: false, spelling: nil) + let messageInput = MessageInput(messageType: MessageInput.MessageType.text.rawValue, text: "I'm good, how are you?", options: messageInputOptions) assistant.message(assistantID: assistantID, sessionID: sessionID, input: messageInput, context: nil) { response, error in @@ -273,7 +274,7 @@ class AssistantV2Tests: XCTestCase { XCTAssertEqual(intents[0].intent, "General_Greetings") // verify context - XCTAssertNil(context) + XCTAssertNotNil(context) expectation3.fulfill() }