ibm_watson 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3834857c16b6974709d114b4d0093223e322a871c9f961d19d8f47617c20e135
4
- data.tar.gz: 90ef6a24e38b40ec0254bf7b13b62851578c20807182371eb42be16a2a92f968
3
+ metadata.gz: 2b27fbff4d3847691ce67cabe41fcc8b232a1d671631126cfeedf501674d6725
4
+ data.tar.gz: a61caeff375e304b1a31e7b32f61f0638728dd75e8691d65d3a3bde225b80b50
5
5
  SHA512:
6
- metadata.gz: f14e249f5918715bb65c504206b67a65426c51611360e6f1b5661f6889d44af05345873e94afd680e229ac0cbcb4d02853101f071c3addb23bceb8e172ad3c43
7
- data.tar.gz: b31d31588da90ebf7012a335a53537b69cf7f28ea68cd9ff928e388d05aee6b0cdd25eb5a36cc470f0a77c5c5728c4af49ee3e3088c0d229273f6d5132bb31ce
6
+ metadata.gz: 89cd8d4c28251093e95a4fcfe4537f481da27c6689391be06822b62d1522bbaaf2e36fc11c28f51d3b44c4da9d6f308b0129cd0b52fe3994bf5377af0a8172a0
7
+ data.tar.gz: c1e2f944f9bf0db887c374468c038fef0e3224859fae24be6202974e7f6eebc4673f9ae232382d89a70dee2929fe3eb5e5548c074583c0995f5636a46dac0e1d
@@ -0,0 +1,200 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 IBM All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # The IBM Watson™ Assistant service combines machine learning, natural language
18
+ # understanding, and integrated dialog tools to create conversation flows between your
19
+ # apps and your users.
20
+
21
+ require "concurrent"
22
+ require "erb"
23
+ require "json"
24
+ require_relative "./detailed_response"
25
+
26
+ require_relative "./watson_service"
27
+
28
+ # Module for the Watson APIs
29
+ module IBMWatson
30
+ ##
31
+ # The Assistant V2 service.
32
+ class AssistantV2 < WatsonService
33
+ include Concurrent::Async
34
+ ##
35
+ # @!method initialize(args)
36
+ # Construct a new client for the Assistant service.
37
+ #
38
+ # @param args [Hash] The args to initialize with
39
+ # @option args version [String] The API version date to use with the service, in
40
+ # "YYYY-MM-DD" format. Whenever the API is changed in a backwards
41
+ # incompatible way, a new minor version of the API is released.
42
+ # The service uses the API version for the date you specify, or
43
+ # the most recent version before that date. Note that you should
44
+ # not programmatically specify the current date at runtime, in
45
+ # case the API has been updated since your application's release.
46
+ # Instead, specify a version date that is compatible with your
47
+ # application, and don't change it until your application is
48
+ # ready for a later version.
49
+ # @option args url [String] The base url to use when contacting the service (e.g.
50
+ # "https://gateway.watsonplatform.net/assistant/api").
51
+ # The base url may differ between Bluemix regions.
52
+ # @option args username [String] The username used to authenticate with the service.
53
+ # Username and password credentials are only required to run your
54
+ # application locally or outside of Bluemix. When running on
55
+ # Bluemix, the credentials will be automatically loaded from the
56
+ # `VCAP_SERVICES` environment variable.
57
+ # @option args password [String] The password used to authenticate with the service.
58
+ # Username and password credentials are only required to run your
59
+ # application locally or outside of Bluemix. When running on
60
+ # Bluemix, the credentials will be automatically loaded from the
61
+ # `VCAP_SERVICES` environment variable.
62
+ # @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
63
+ # this API key is provided, the SDK will manage the token and handle the
64
+ # refreshing.
65
+ # @option args iam_access_token [String] An IAM access token is fully managed by the application.
66
+ # Responsibility falls on the application to refresh the token, either before
67
+ # it expires or reactively upon receiving a 401 from the service as any requests
68
+ # made with an expired token will fail.
69
+ # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
70
+ # 'https://iam.ng.bluemix.net/identity/token'.
71
+ def initialize(args = {})
72
+ @__async_initialized__ = false
73
+ defaults = {}
74
+ defaults[:version] = nil
75
+ defaults[:url] = "https://gateway.watsonplatform.net/assistant/api"
76
+ defaults[:username] = nil
77
+ defaults[:password] = nil
78
+ defaults[:iam_apikey] = nil
79
+ defaults[:iam_access_token] = nil
80
+ defaults[:iam_url] = nil
81
+ args = defaults.merge(args)
82
+ args[:vcap_services_name] = "conversation"
83
+ super
84
+ @version = args[:version]
85
+ end
86
+
87
+ #########################
88
+ # Sessions
89
+ #########################
90
+
91
+ ##
92
+ # @!method create_session(assistant_id:)
93
+ # Create a session.
94
+ # Create a new session. A session is used to send user input to a skill and receive
95
+ # responses. It also maintains the state of the conversation.
96
+ # @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
97
+ # on the **Assistants** tab of the Watson Assistant tool. For information about
98
+ # creating assistants, see the
99
+ # [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
100
+ #
101
+ # **Note:** Currently, the v2 API does not support creating assistants.
102
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
103
+ def create_session(assistant_id:)
104
+ raise ArgumentError("assistant_id must be provided") if assistant_id.nil?
105
+
106
+ headers = {
107
+ }
108
+ params = {
109
+ "version" => @version
110
+ }
111
+ method_url = "/v2/assistants/%s/sessions" % [ERB::Util.url_encode(assistant_id)]
112
+ response = request(
113
+ method: "POST",
114
+ url: method_url,
115
+ headers: headers,
116
+ params: params,
117
+ accept_json: true
118
+ )
119
+ response
120
+ end
121
+
122
+ ##
123
+ # @!method delete_session(assistant_id:, session_id:)
124
+ # Delete session.
125
+ # Deletes a session explicitly before it times out.
126
+ # @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
127
+ # on the **Assistants** tab of the Watson Assistant tool. For information about
128
+ # creating assistants, see the
129
+ # [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
130
+ #
131
+ # **Note:** Currently, the v2 API does not support creating assistants.
132
+ # @param session_id [String] Unique identifier of the session.
133
+ # @return [nil]
134
+ def delete_session(assistant_id:, session_id:)
135
+ raise ArgumentError("assistant_id must be provided") if assistant_id.nil?
136
+
137
+ raise ArgumentError("session_id must be provided") if session_id.nil?
138
+
139
+ headers = {
140
+ }
141
+ params = {
142
+ "version" => @version
143
+ }
144
+ method_url = "/v2/assistants/%s/sessions/%s" % [ERB::Util.url_encode(assistant_id), ERB::Util.url_encode(session_id)]
145
+ request(
146
+ method: "DELETE",
147
+ url: method_url,
148
+ headers: headers,
149
+ params: params,
150
+ accept_json: true
151
+ )
152
+ nil
153
+ end
154
+ #########################
155
+ # Message
156
+ #########################
157
+
158
+ ##
159
+ # @!method message(assistant_id:, session_id:, input: nil, context: nil)
160
+ # Send user input to assistant.
161
+ # Send user input to an assistant and receive a response.
162
+ #
163
+ # There is no rate limit for this operation.
164
+ # @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
165
+ # on the **Assistants** tab of the Watson Assistant tool. For information about
166
+ # creating assistants, see the
167
+ # [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
168
+ #
169
+ # **Note:** Currently, the v2 API does not support creating assistants.
170
+ # @param session_id [String] Unique identifier of the session.
171
+ # @param input [MessageInput] An input object that includes the input text.
172
+ # @param context [MessageContext] State information for the conversation.
173
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
174
+ def message(assistant_id:, session_id:, input: nil, context: nil)
175
+ raise ArgumentError("assistant_id must be provided") if assistant_id.nil?
176
+
177
+ raise ArgumentError("session_id must be provided") if session_id.nil?
178
+
179
+ headers = {
180
+ }
181
+ params = {
182
+ "version" => @version
183
+ }
184
+ data = {
185
+ "input" => input,
186
+ "context" => context
187
+ }
188
+ method_url = "/v2/assistants/%s/sessions/%s/message" % [ERB::Util.url_encode(assistant_id), ERB::Util.url_encode(session_id)]
189
+ response = request(
190
+ method: "POST",
191
+ url: method_url,
192
+ headers: headers,
193
+ params: params,
194
+ json: data,
195
+ accept_json: true
196
+ )
197
+ response
198
+ end
199
+ end
200
+ end
@@ -1235,10 +1235,14 @@ module IBMWatson
1235
1235
  # @param customization_id [String] The customization ID (GUID) of the custom language model. You must make the
1236
1236
  # request with service credentials created for the instance of the service that owns
1237
1237
  # the custom model.
1238
- # @param corpus_name [String] The name of the corpus for the custom language model. When adding a corpus, do not
1239
- # include spaces in the name; use a localized name that matches the language of the
1240
- # custom model; and do not use the name `user`, which is reserved by the service to
1241
- # denote custom words added or modified by the user.
1238
+ # @param corpus_name [String] The name of the new corpus for the custom language model. Use a localized name
1239
+ # that matches the language of the custom model and reflects the contents of the
1240
+ # corpus.
1241
+ # * Include a maximum of 128 characters in the name.
1242
+ # * Do not include spaces, slashes, or backslashes in the name.
1243
+ # * Do not use the name of a corpus that has already been added to the custom model.
1244
+ # * Do not use the name `user`, which is reserved by the service to denote custom
1245
+ # words that are added or modified by the user.
1242
1246
  # @param corpus_file [File] A plain text file that contains the training data for the corpus. Encode the file
1243
1247
  # in UTF-8 if it contains non-ASCII characters; the service assumes UTF-8 encoding
1244
1248
  # if it encounters non-ASCII characters. With cURL, use the `--data-binary` option
@@ -1294,10 +1298,7 @@ module IBMWatson
1294
1298
  # @param customization_id [String] The customization ID (GUID) of the custom language model. You must make the
1295
1299
  # request with service credentials created for the instance of the service that owns
1296
1300
  # the custom model.
1297
- # @param corpus_name [String] The name of the corpus for the custom language model. When adding a corpus, do not
1298
- # include spaces in the name; use a localized name that matches the language of the
1299
- # custom model; and do not use the name `user`, which is reserved by the service to
1300
- # denote custom words added or modified by the user.
1301
+ # @param corpus_name [String] The name of the corpus for the custom language model.
1301
1302
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1302
1303
  def get_corpus(customization_id:, corpus_name:)
1303
1304
  raise ArgumentError("customization_id must be provided") if customization_id.nil?
@@ -1329,10 +1330,7 @@ module IBMWatson
1329
1330
  # @param customization_id [String] The customization ID (GUID) of the custom language model. You must make the
1330
1331
  # request with service credentials created for the instance of the service that owns
1331
1332
  # the custom model.
1332
- # @param corpus_name [String] The name of the corpus for the custom language model. When adding a corpus, do not
1333
- # include spaces in the name; use a localized name that matches the language of the
1334
- # custom model; and do not use the name `user`, which is reserved by the service to
1335
- # denote custom words added or modified by the user.
1333
+ # @param corpus_name [String] The name of the corpus for the custom language model.
1336
1334
  # @return [nil]
1337
1335
  def delete_corpus(customization_id:, corpus_name:)
1338
1336
  raise ArgumentError("customization_id must be provided") if customization_id.nil?
@@ -2024,12 +2022,26 @@ module IBMWatson
2024
2022
  # speech recognition and with the `Content-Type` header, including the `rate`,
2025
2023
  # `channels`, and `endianness` parameters that are used with some formats. The
2026
2024
  # default contained audio format is `audio/wav`.
2025
+ #
2026
+ # ### Naming restrictions for embedded audio files
2027
+ #
2028
+ # The name of an audio file that is embedded within an archive-type resource must
2029
+ # meet the following restrictions:
2030
+ # * Include a maximum of 128 characters in the file name; this includes the file
2031
+ # extension.
2032
+ # * Do not include spaces, slashes, or backslashes in the file name.
2033
+ # * Do not use the name of an audio file that has already been added to the custom
2034
+ # model as part of an archive-type resource.
2027
2035
  # @param customization_id [String] The customization ID (GUID) of the custom acoustic model. You must make the
2028
2036
  # request with service credentials created for the instance of the service that owns
2029
2037
  # the custom model.
2030
- # @param audio_name [String] The name of the audio resource for the custom acoustic model. When adding an audio
2031
- # resource, do not include spaces in the name; use a localized name that matches the
2032
- # language of the custom model.
2038
+ # @param audio_name [String] The name of the new audio resource for the custom acoustic model. Use a localized
2039
+ # name that matches the language of the custom model and reflects the contents of
2040
+ # the resource.
2041
+ # * Include a maximum of 128 characters in the name.
2042
+ # * Do not include spaces, slashes, or backslashes in the name.
2043
+ # * Do not use the name of an audio resource that has already been added to the
2044
+ # custom model.
2033
2045
  # @param audio_resource [String] The audio resource that is to be added to the custom acoustic model, an individual
2034
2046
  # audio file or an archive file.
2035
2047
  # @param content_type [String] The type of the input.
@@ -2098,9 +2110,7 @@ module IBMWatson
2098
2110
  # @param customization_id [String] The customization ID (GUID) of the custom acoustic model. You must make the
2099
2111
  # request with service credentials created for the instance of the service that owns
2100
2112
  # the custom model.
2101
- # @param audio_name [String] The name of the audio resource for the custom acoustic model. When adding an audio
2102
- # resource, do not include spaces in the name; use a localized name that matches the
2103
- # language of the custom model.
2113
+ # @param audio_name [String] The name of the audio resource for the custom acoustic model.
2104
2114
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2105
2115
  def get_audio(customization_id:, audio_name:)
2106
2116
  raise ArgumentError("customization_id must be provided") if customization_id.nil?
@@ -2132,9 +2142,7 @@ module IBMWatson
2132
2142
  # @param customization_id [String] The customization ID (GUID) of the custom acoustic model. You must make the
2133
2143
  # request with service credentials created for the instance of the service that owns
2134
2144
  # the custom model.
2135
- # @param audio_name [String] The name of the audio resource for the custom acoustic model. When adding an audio
2136
- # resource, do not include spaces in the name; use a localized name that matches the
2137
- # language of the custom model.
2145
+ # @param audio_name [String] The name of the audio resource for the custom acoustic model.
2138
2146
  # @return [nil]
2139
2147
  def delete_audio(customization_id:, audio_name:)
2140
2148
  raise ArgumentError("customization_id must be provided") if customization_id.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMWatson
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/ibm_watson.rb CHANGED
@@ -5,6 +5,7 @@ module IBMWatson
5
5
  require_relative("./ibm_watson/personality_insights_v3.rb")
6
6
  require_relative("./ibm_watson/tone_analyzer_v3.rb")
7
7
  require_relative("./ibm_watson/assistant_v1.rb")
8
+ require_relative("./ibm_watson/assistant_v2.rb")
8
9
  require_relative("./ibm_watson/text_to_speech_v1.rb")
9
10
  require_relative("./ibm_watson/discovery_v1.rb")
10
11
  require_relative("./ibm_watson/natural_language_understanding_v1.rb")
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("./../test_helper.rb")
4
+ SimpleCov.command_name "test:integration"
5
+
6
+ if !ENV["ASSISTANT_V2_USERNAME"].nil? && !ENV["ASSISTANT_V2_PASSWORD"].nil?
7
+ # Integration tests for the Watson Assistant V2 Service
8
+ class AssistantV2Test < Minitest::Test
9
+ def test_create_delete_session
10
+ # skip "Skip to allow for concurrent travis jobs"
11
+ service = IBMWatson::AssistantV2.new(
12
+ version: "2018-12-31",
13
+ username: ENV["ASSISTANT_V2_USERNAME"],
14
+ password: ENV["ASSISTANT_V2_PASSWORD"],
15
+ url: ENV["ASSISTANT_V2_URL"],
16
+ assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"]
17
+ )
18
+ service.add_default_headers(
19
+ headers: {
20
+ "X-Watson-Learning-Opt-Out" => "1",
21
+ "X-Watson-Test" => "1"
22
+ }
23
+ )
24
+ service_response = service.create_session(
25
+ assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"]
26
+ )
27
+ session_id = service_response.result["session_id"]
28
+ assert((200..299).cover?(service_response.status))
29
+ service.delete_session(
30
+ assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
31
+ session_id: session_id
32
+ )
33
+ end
34
+
35
+ def test_message
36
+ service = IBMWatson::AssistantV2.new(
37
+ username: ENV["ASSISTANT_V2_USERNAME"],
38
+ password: ENV["ASSISTANT_V2_PASSWORD"],
39
+ version: "2018-02-16",
40
+ url: ENV["ASSISTANT_V2_URL"]
41
+ )
42
+ service.add_default_headers(
43
+ headers: {
44
+ "X-Watson-Learning-Opt-Out" => "1",
45
+ "X-Watson-Test" => "1"
46
+ }
47
+ )
48
+ service_response = service.message(
49
+ assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
50
+ session_id: ENV["ASSISTANT_V2_SESSION_ID"],
51
+ input: { "text" => "Turn on the lights" },
52
+ context: nil
53
+ )
54
+ assert((200..299).cover?(service_response.status))
55
+
56
+ context = service_response.result["context"]
57
+ service_response = service.message(
58
+ assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
59
+ session_id: ENV["ASSISTANT_V2_SESSION_ID"],
60
+ input: { "text" => "Turn on the lights" },
61
+ context: context
62
+ )
63
+ assert((200..299).cover?(service_response.status))
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("json")
4
+ require_relative("./../test_helper.rb")
5
+ require("webmock/minitest")
6
+ SimpleCov.command_name "test:unit"
7
+
8
+ WebMock.disable_net_connect!(allow_localhost: true)
9
+
10
+ # Unit tests for the Watson Assistant V1 Service
11
+ class AssistantV2Test < Minitest::Test
12
+ def test_message
13
+ service = IBMWatson::AssistantV2.new(
14
+ username: "username",
15
+ password: "password",
16
+ version: "2018-02-16"
17
+ )
18
+ # service.set_default_headers("x-watson-learning-opt-out" => true)
19
+ assistant_id = "f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec"
20
+ session_id = "session"
21
+ message_response = {
22
+ "context" => {
23
+ "conversation_id" => "1b7b67c0-90ed-45dc-8508-9488bc483d5b",
24
+ "system" => {
25
+ "dialog_stack" => ["root"],
26
+ "dialog_turn_counter" => 1,
27
+ "dialog_request_counter" => 1
28
+ }
29
+ },
30
+ "intents" => [],
31
+ "entities" => [],
32
+ "input" => {},
33
+ "output" => {
34
+ "text" => "okay",
35
+ "log_messages" => []
36
+ }
37
+ }
38
+ headers = {
39
+ "Content-Type" => "application/json"
40
+ }
41
+ stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v2/assistants/f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec/sessions/session/message?version=2018-02-16")
42
+ .with(
43
+ body: "{\"input\":{\"text\":\"Turn on the lights\"}}",
44
+ headers: {
45
+ "Accept" => "application/json",
46
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
47
+ "Content-Type" => "application/json",
48
+ "Host" => "gateway.watsonplatform.net"
49
+ }
50
+ ).to_return(status: 200, body: message_response.to_json, headers: headers)
51
+ service_response = service.message(
52
+ assistant_id: assistant_id,
53
+ session_id: session_id,
54
+ input: { "text" => "Turn on the lights" },
55
+ context: nil
56
+ )
57
+ assert_equal(message_response, service_response.result)
58
+
59
+ message_ctx = {
60
+ "context" => {
61
+ "conversation_id" => "1b7b67c0-90ed-45dc-8508-9488bc483d5b",
62
+ "system" => {
63
+ "dialog_stack" => ["root"],
64
+ "dialog_turn_counter" => 2,
65
+ "dialog_request_counter" => 1
66
+ }
67
+ }
68
+ }
69
+ stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v2/assistants/f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec/sessions/session/message?version=2018-02-16")
70
+ .with(
71
+ body: "{\"input\":{\"text\":\"Turn on the lights\"},\"context\":\"{\\\"conversation_id\\\":\\\"1b7b67c0-90ed-45dc-8508-9488bc483d5b\\\",\\\"system\\\":{\\\"dialog_stack\\\":[\\\"root\\\"],\\\"dialog_turn_counter\\\":2,\\\"dialog_request_counter\\\":1}}\"}",
72
+ headers: {
73
+ "Accept" => "application/json",
74
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
75
+ "Content-Type" => "application/json",
76
+ "Host" => "gateway.watsonplatform.net"
77
+ }
78
+ ).to_return(status: 200, body: message_response.to_json, headers: headers)
79
+ service_response = service.message(
80
+ assistant_id: assistant_id,
81
+ session_id: session_id,
82
+ input: { "text" => "Turn on the lights" },
83
+ context: message_ctx["context"].to_json
84
+ )
85
+ assert_equal(message_response, service_response.result)
86
+ end
87
+
88
+ def test_create_session
89
+ # response = {
90
+ # "name" => "Pizza app",
91
+ # "created" => "2015-12-06T23:53:59.153Z",
92
+ # "language" => "en",
93
+ # "metadata" => {},
94
+ # "updated" => "2015-12-06T23:53:59.153Z",
95
+ # "description" => "Pizza app",
96
+ # "assistant_id" => "pizza_app-e0f3"
97
+ # }
98
+ # headers = {
99
+ # "Content-Type" => "application/json"
100
+ # }
101
+ stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v2/assistants/pizza_app-e0f3/sessions?version=2018-02-16")
102
+ .with(
103
+ headers: {
104
+ "Accept" => "application/json",
105
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
106
+ "Host" => "gateway.watsonplatform.net"
107
+ }
108
+ ).to_return(status: 200, body: "", headers: {})
109
+ service = IBMWatson::AssistantV2.new(
110
+ username: "username",
111
+ password: "password",
112
+ version: "2018-02-16"
113
+ )
114
+ service_response = service.create_session(
115
+ assistant_id: "pizza_app-e0f3"
116
+ )
117
+ assert_equal("", service_response.result)
118
+ end
119
+
120
+ def test_delete_session
121
+ stub_request(:delete, "https://gateway.watsonplatform.net/assistant/api/v2/assistants/pizza_app-e0f3/sessions/session?version=2018-02-16")
122
+ .with(
123
+ headers: {
124
+ "Accept" => "application/json",
125
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
126
+ "Host" => "gateway.watsonplatform.net"
127
+ }
128
+ ).to_return(status: 200, body: "", headers: {})
129
+ service = IBMWatson::AssistantV2.new(
130
+ username: "username",
131
+ password: "password",
132
+ version: "2018-02-16"
133
+ )
134
+ service_response = service.delete_session(
135
+ assistant_id: "pizza_app-e0f3",
136
+ session_id: "session"
137
+ )
138
+ assert_nil(service_response)
139
+ end
140
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_watson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-14 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -245,6 +245,7 @@ files:
245
245
  - bin/setup
246
246
  - lib/ibm_watson.rb
247
247
  - lib/ibm_watson/assistant_v1.rb
248
+ - lib/ibm_watson/assistant_v2.rb
248
249
  - lib/ibm_watson/detailed_response.rb
249
250
  - lib/ibm_watson/discovery_v1.rb
250
251
  - lib/ibm_watson/iam_token_manager.rb
@@ -264,6 +265,7 @@ files:
264
265
  - rakefile
265
266
  - test/appveyor_status.rb
266
267
  - test/integration/test_assistant_v1.rb
268
+ - test/integration/test_assistant_v2.rb
267
269
  - test/integration/test_discovery_v1.rb
268
270
  - test/integration/test_iam_assistant_v1.rb
269
271
  - test/integration/test_language_translator_v3.rb
@@ -276,6 +278,7 @@ files:
276
278
  - test/integration/test_visual_recognition_v3.rb
277
279
  - test/test_helper.rb
278
280
  - test/unit/test_assistant_v1.rb
281
+ - test/unit/test_assistant_v2.rb
279
282
  - test/unit/test_configure_http_client.rb
280
283
  - test/unit/test_discovery_v1.rb
281
284
  - test/unit/test_iam_token_manager.rb