Skip to content

Commit 56f2f6a

Browse files
committed
[*] 1.2.1 - UTF-8 fixed for some cases
1 parent 0640293 commit 56f2f6a

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ uer.delete('contacts') # will remove user entities for given session
148148

149149
#Changelog
150150

151+
* 1.2.1 - fixed UTF-8 in text-requests
151152
* 1.2.0 - added configurable session_id and full userEntities support
152153
* 1.1.4 - removed unused dependency and updated default API version
153154
* 1.1.3 - fixed non-correctly serialized parameters in new contexts during query send process

lib/api-ai-ruby/constants.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ApiAiRuby
22
class Constants
3-
VERSION = '1.2.0'
3+
VERSION = '1.2.1'
44
DEFAULT_BASE_URL = 'https://api.api.ai/v1/'
55
DEFAULT_API_VERSION = '20150910'
66
DEFAULT_CLIENT_LANG = 'en'

lib/api-ai-ruby/crud/user_entity_request.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class UserEntitiesRequest < ApiAiRuby::RequestQuery
33

44
def initialize(client, options = {})
55
super client, options
6+
@headers['Content-Type'] = 'application/json; charset=UTF-8'
67
@crud_base_uri = client.api_base_url + 'userEntities'
78
@uri = @crud_base_uri
89
end

lib/api-ai-ruby/request/text_request.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class TextRequest < ApiAiRuby::RequestQuery
33
def initialize (client, options={})
44
options[:lang] = client.api_lang
55
super client, options
6+
@headers['Content-Type'] = 'application/json; charset=UTF-8'
67
end
78
end
89
end

spec/api-ai-ruby/api_spec.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
expect(response[:result][:action]).to eq 'greeting'
1313
end
1414

15+
it 'should correct work with utf-8 entities' do
16+
response = @client.text_request '你好'
17+
expect(response[:result][:resolvedQuery]).to eq '你好'
18+
end
1519
it 'should use input contexts' do
1620
response = @client.text_request 'Hello', :resetContexts => true
1721
expect(response[:result][:action]).to eq 'greeting'
@@ -36,7 +40,9 @@
3640
end
3741

3842
it 'should send voiceData to API' do
39-
expect(@client.voice_request(File.new(fixture_path + '/hello.wav'))[:result][:resolvedQuery]).to eq 'hello'
43+
# expect(@client.voice_request(File.new(fixture_path + '/hello.wav'))[:result][:resolvedQuery]).to eq 'hello'
44+
# asr was disabled for non-premium users
45+
expect {@client.voice_request(File.new(fixture_path + '/hello.wav'))}.to raise_error(ApiAiRuby::RequestError)
4046
end
4147

4248
it 'should correctly set contexts with parameters' do
@@ -98,8 +104,5 @@
98104
@uer.delete('dwarfs')
99105
expect{@uer.retrieve('dwarfs')}.to raise_error(ApiAiRuby::RequestError)
100106
end
101-
102107
end
103-
104-
105108
end

0 commit comments

Comments
 (0)