diff --git a/README.md b/README.md index 8e7d062..9eb3356 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ uer.delete('contacts') # will remove user entities for given session #Changelog +* 1.2.1 - fixed UTF-8 in text-requests * 1.2.0 - added configurable session_id and full userEntities support * 1.1.4 - removed unused dependency and updated default API version * 1.1.3 - fixed non-correctly serialized parameters in new contexts during query send process diff --git a/lib/api-ai-ruby/constants.rb b/lib/api-ai-ruby/constants.rb index 802ff42..b42425e 100644 --- a/lib/api-ai-ruby/constants.rb +++ b/lib/api-ai-ruby/constants.rb @@ -1,6 +1,6 @@ module ApiAiRuby class Constants - VERSION = '1.2.0' + VERSION = '1.2.1' DEFAULT_BASE_URL = 'https://api.api.ai/v1/' DEFAULT_API_VERSION = '20150910' DEFAULT_CLIENT_LANG = 'en' diff --git a/lib/api-ai-ruby/crud/user_entity_request.rb b/lib/api-ai-ruby/crud/user_entity_request.rb index 6672de1..1bc2bb6 100644 --- a/lib/api-ai-ruby/crud/user_entity_request.rb +++ b/lib/api-ai-ruby/crud/user_entity_request.rb @@ -3,6 +3,7 @@ class UserEntitiesRequest < ApiAiRuby::RequestQuery def initialize(client, options = {}) super client, options + @headers['Content-Type'] = 'application/json; charset=UTF-8' @crud_base_uri = client.api_base_url + 'userEntities' @uri = @crud_base_uri end diff --git a/lib/api-ai-ruby/request/text_request.rb b/lib/api-ai-ruby/request/text_request.rb index e886f24..9449042 100644 --- a/lib/api-ai-ruby/request/text_request.rb +++ b/lib/api-ai-ruby/request/text_request.rb @@ -3,6 +3,7 @@ class TextRequest < ApiAiRuby::RequestQuery def initialize (client, options={}) options[:lang] = client.api_lang super client, options + @headers['Content-Type'] = 'application/json; charset=UTF-8' end end end diff --git a/spec/api-ai-ruby/api_spec.rb b/spec/api-ai-ruby/api_spec.rb index 184e6da..f9fcfc6 100644 --- a/spec/api-ai-ruby/api_spec.rb +++ b/spec/api-ai-ruby/api_spec.rb @@ -12,6 +12,10 @@ expect(response[:result][:action]).to eq 'greeting' end + it 'should correct work with utf-8 entities' do + response = @client.text_request '你好' + expect(response[:result][:resolvedQuery]).to eq '你好' + end it 'should use input contexts' do response = @client.text_request 'Hello', :resetContexts => true expect(response[:result][:action]).to eq 'greeting' @@ -36,7 +40,9 @@ end it 'should send voiceData to API' do - expect(@client.voice_request(File.new(fixture_path + '/hello.wav'))[:result][:resolvedQuery]).to eq 'hello' + # expect(@client.voice_request(File.new(fixture_path + '/hello.wav'))[:result][:resolvedQuery]).to eq 'hello' + # asr was disabled for non-premium users + expect {@client.voice_request(File.new(fixture_path + '/hello.wav'))}.to raise_error(ApiAiRuby::RequestError) end it 'should correctly set contexts with parameters' do @@ -98,8 +104,5 @@ @uer.delete('dwarfs') expect{@uer.retrieve('dwarfs')}.to raise_error(ApiAiRuby::RequestError) end - end - - end