voxable-api-ai-ruby 2.1.1 → 2.1.2

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: 5928158fbc32dc24cbff4c855ccda97badce255a48e338ab261d35c8bca80b95
4
- data.tar.gz: 91052c399111f4f64ab72447d0b68f10c732945245f074899b19ab6a11d45fe4
3
+ metadata.gz: a08920d0ffa37880fadd68d0bc76527ab319a1ce479f2884100b9b0b6c7386d0
4
+ data.tar.gz: 281a5a6d78bb49c6c713596c2596d498f0a5d088bbf97005749b652e7d17c508
5
5
  SHA512:
6
- metadata.gz: cd7d8bc6502dd52b1e2a2d6781879b62b2455cb08b6e52c7ec0cb87a1a1944377a79d940362a25c09acc2ad37b6d655677d63f103afa3eb4dd8a651131b35da8
7
- data.tar.gz: ca7a08a7eb405225e556232a510543545d49bdbb5921307ec0d0d86d5df926223d4037cf69933f81cde87265f68020e250416f78c691eb4dee6ede50824e6d2f
6
+ metadata.gz: 4ae3541d1053e40782928561918476dd0c31e24cc08af9f4afb2625e1f1ff384fdf66d34da03b96fac87ffb5d0404f8dff0480749a99ff277f275d07a11dd3d7
7
+ data.tar.gz: 4085c18a56178fcd967e4e254e31a8e537c093a5aa2d1d918bcfd75d5ad048818233699e0ad21b475f3debd09bb3556f80e6923c523dfbf747d372b74f76c242
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # The API.AI ruby gem
2
2
 
3
+ **⚠️ This is a forked version of the official Dialogflow Ruby client. It's out-of-date, and used by [Voxable](http://voxable.io) for our own projects. You're welcome to use it, of course, but you likely want [the official client gem](https://github.com/dialogflow/dialogflow-ruby-client).**
4
+
3
5
  A Ruby SDK to the https://api.ai natural language processing service.
4
6
 
5
7
  ## Installation
@@ -0,0 +1,13 @@
1
+ require 'voxable-api-ai-ruby/constants'
2
+ require 'voxable-api-ai-ruby/client'
3
+ require 'voxable-api-ai-ruby/request_error'
4
+ require 'voxable-api-ai-ruby/client_error'
5
+ require 'voxable-api-ai-ruby/request'
6
+ require 'voxable-api-ai-ruby/text_request'
7
+ require 'voxable-api-ai-ruby/voice_request'
8
+ require 'voxable-api-ai-ruby/update_entities_request'
9
+ require 'voxable-api-ai-ruby/update_intent_request'
10
+ require 'voxable-api-ai-ruby/get_intent_request'
11
+ require 'voxable-api-ai-ruby/get_entity_request'
12
+
13
+ module VoxableApiAiRuby; end
@@ -1,4 +1,4 @@
1
- module ApiAiRuby
1
+ module VoxableApiAiRuby
2
2
  class Client
3
3
  attr_accessor :client_access_token, :developer_access_token
4
4
  attr_writer :user_agent, :api_version, :api_lang, :api_base_url
@@ -16,19 +16,19 @@ module ApiAiRuby
16
16
 
17
17
  # @return [String]
18
18
  def user_agent
19
- @user_agent ||= "ApiAiRubyGem/#{ApiAiRuby::Constants::VERSION}"
19
+ @user_agent ||= "ApiAiRubyGem/#{VoxableApiAiRuby::Constants::VERSION}"
20
20
  end
21
21
 
22
22
  def api_base_url
23
- @api_base_url ||= ApiAiRuby::Constants::DEFAULT_BASE_URL
23
+ @api_base_url ||= VoxableApiAiRuby::Constants::DEFAULT_BASE_URL
24
24
  end
25
25
 
26
26
  def api_lang
27
- @api_lang ||= ApiAiRuby::Constants::DEFAULT_CLIENT_LANG
27
+ @api_lang ||= VoxableApiAiRuby::Constants::DEFAULT_CLIENT_LANG
28
28
  end
29
29
 
30
30
  def api_version
31
- @api_version ||= ApiAiRuby::Constants::DEFAULT_API_VERSION
31
+ @api_version ||= VoxableApiAiRuby::Constants::DEFAULT_API_VERSION
32
32
  end
33
33
 
34
34
  # @return [Hash]
@@ -50,51 +50,51 @@ module ApiAiRuby
50
50
  end
51
51
 
52
52
  def text_request (query = '', options = {})
53
- raise ApiAiRuby::ClientError.new('Credentials missing') if !client_credentials?
53
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !client_credentials?
54
54
  options[:params] ||= {}
55
55
  options[:params] = options[:params].merge({ query: query })
56
- ApiAiRuby::TextRequest.new(self, options).perform
56
+ VoxableApiAiRuby::TextRequest.new(self, options).perform
57
57
  end
58
58
 
59
59
  def voice_request(file_stream, options = {})
60
- raise ApiAiRuby::ClientError.new('Credentials missing') if !client_credentials?
60
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !client_credentials?
61
61
  options[:form] ||= {}
62
62
  options[:form] = options[:form].merge({ file: file_stream })
63
- ApiAiRuby::VoiceRequest.new(self, options).perform
63
+ VoxableApiAiRuby::VoiceRequest.new(self, options).perform
64
64
  end
65
65
 
66
66
  def update_entities_request(entities, options = {})
67
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
67
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
68
68
  options[:json] = entities
69
- ApiAiRuby::UpdateEntitiesRequest.new(self, options).perform
69
+ VoxableApiAiRuby::UpdateEntitiesRequest.new(self, options).perform
70
70
  end
71
71
 
72
72
  def update_intent_request(intent, options = {})
73
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
73
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
74
74
  options[:json] = intent
75
- ApiAiRuby::UpdateIntentRequest.new(self, options).perform
75
+ VoxableApiAiRuby::UpdateIntentRequest.new(self, options).perform
76
76
  end
77
77
 
78
78
  def get_intent_request(iid, options = {})
79
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
79
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
80
80
  options[:iid] = iid
81
- ApiAiRuby::GetIntentRequest.new(self, options).perform
81
+ VoxableApiAiRuby::GetIntentRequest.new(self, options).perform
82
82
  end
83
83
 
84
84
  def get_intents_request(options = {})
85
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
86
- ApiAiRuby::GetIntentRequest.new(self, options).perform
85
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
86
+ VoxableApiAiRuby::GetIntentRequest.new(self, options).perform
87
87
  end
88
88
 
89
89
  def get_entity_request(eid, options = {})
90
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
90
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
91
91
  options[:eid] = eid
92
- ApiAiRuby::GetEntityRequest.new(self, options).perform
92
+ VoxableApiAiRuby::GetEntityRequest.new(self, options).perform
93
93
  end
94
94
 
95
95
  def get_entities_request(options = {})
96
- raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
97
- ApiAiRuby::GetEntityRequest.new(self, options).perform
96
+ raise VoxableApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials?
97
+ VoxableApiAiRuby::GetEntityRequest.new(self, options).perform
98
98
  end
99
99
  end
100
100
  end
@@ -1,4 +1,4 @@
1
- module ApiAiRuby
1
+ module VoxableApiAiRuby
2
2
  class ClientError < StandardError
3
3
 
4
4
  end
@@ -1,6 +1,6 @@
1
- module ApiAiRuby
1
+ module VoxableApiAiRuby
2
2
  class Constants
3
- VERSION = '2.1.1'
3
+ VERSION = '2.1.2'
4
4
  DEFAULT_BASE_URL = 'https://api.api.ai/v1/'
5
5
  DEFAULT_API_VERSION = '20150204'
6
6
  DEFAULT_CLIENT_LANG = 'en'
@@ -1,6 +1,6 @@
1
- module ApiAiRuby
2
- class GetEntityRequest < ApiAiRuby::Request
3
- def initialize (client, options={})
1
+ module VoxableApiAiRuby
2
+ class GetEntityRequest < VoxableApiAiRuby::Request
3
+ def initialize(client, options={})
4
4
  @path = "entities/#{ options.delete(:eid) }"
5
5
 
6
6
  super client, options
@@ -1,5 +1,5 @@
1
- module ApiAiRuby
2
- class GetIntentRequest < ApiAiRuby::Request
1
+ module VoxableApiAiRuby
2
+ class GetIntentRequest < VoxableApiAiRuby::Request
3
3
  def initialize (client, options={})
4
4
  @path = "intents/#{ options.delete(:iid) }"
5
5
 
@@ -2,15 +2,15 @@ require 'http'
2
2
  require 'http/form_data'
3
3
  require 'uri'
4
4
 
5
- module ApiAiRuby
5
+ module VoxableApiAiRuby
6
6
  class Request
7
7
 
8
8
  attr_accessor :client, :headers, :options, :request_method, :uri
9
9
 
10
- # @param client [ApiAiRuby::Client]
10
+ # @param client [VoxableApiAiRuby::Client]
11
11
  # @param path [String] the path to the proper API endpoint
12
12
  # @param options [Hash]
13
- # @return [ApiAiRuby::TextRequest]
13
+ # @return [VoxableApiAiRuby::TextRequest]
14
14
 
15
15
  def initialize(client, options = {})
16
16
  @client = client
@@ -20,7 +20,8 @@ module ApiAiRuby
20
20
  options[:params] = options[:params].merge({ lang: client.api_lang })
21
21
  @options = options
22
22
  @headers = {
23
- 'Authorization': 'Bearer ' + client.client_access_token
23
+ 'Authorization': ('Bearer ' + client.client_access_token),
24
+ 'Content-Type': 'application/json; charset=utf-8'
24
25
  }
25
26
  end
26
27
 
@@ -39,7 +40,7 @@ module ApiAiRuby
39
40
  def fail_or_return_response_body(code, body)
40
41
  error = false
41
42
  if code != 200 || ( !body.kind_of?(Array) && body[:status] && body[:status][:code] != 200 )
42
- error = ApiAiRuby::RequestError.new body[:status][:errorDetails], body[:status][:code]
43
+ error = VoxableApiAiRuby::RequestError.new body[:status][:errorDetails], body[:status][:code]
43
44
  end
44
45
  fail(error) if error
45
46
  body
@@ -58,4 +59,4 @@ module ApiAiRuby
58
59
  object
59
60
  end
60
61
  end
61
- end
62
+ end
@@ -1,4 +1,4 @@
1
- module ApiAiRuby
1
+ module VoxableApiAiRuby
2
2
  class RequestError < StandardError
3
3
  #return [Integer]
4
4
  attr_reader :code
@@ -7,7 +7,7 @@ module ApiAiRuby
7
7
  #
8
8
  # @param message [Exception, String]
9
9
  # @param code [Integer]
10
- # @return [ApiAiRuby::RequestError]
10
+ # @return [VoxableApiAiRuby::RequestError]
11
11
  def initialize(message = '', code = nil)
12
12
  super(message)
13
13
  @code = code
@@ -1,5 +1,5 @@
1
- module ApiAiRuby
2
- class TextRequest < ApiAiRuby::Request
1
+ module VoxableApiAiRuby
2
+ class TextRequest < VoxableApiAiRuby::Request
3
3
  def initialize (client, options={})
4
4
  @path = 'query'
5
5
 
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
- module ApiAiRuby
4
- class UpdateEntitiesRequest < ApiAiRuby::Request
3
+ module VoxableApiAiRuby
4
+ class UpdateEntitiesRequest < VoxableApiAiRuby::Request
5
5
  def initialize (client, options={})
6
6
  @path = 'entities'
7
7
 
@@ -9,7 +9,8 @@ module ApiAiRuby
9
9
  @request_method = :put
10
10
  # TODO: There should be a method for generating the proper headers.
11
11
  @headers = {
12
- 'Authorization': 'Bearer ' + client.developer_access_token
12
+ 'Authorization': 'Bearer ' + client.developer_access_token,
13
+ 'Content-Type': 'application/json; charset=utf-8'
13
14
  }
14
15
  end
15
16
  end
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
- module ApiAiRuby
4
- class UpdateIntentRequest < ApiAiRuby::Request
3
+ module VoxableApiAiRuby
4
+ class UpdateIntentRequest < VoxableApiAiRuby::Request
5
5
  def initialize (client, options={})
6
6
  @path = "intents/#{ options[:json][:id] }"
7
7
 
@@ -1,10 +1,10 @@
1
1
  require 'json'
2
2
 
3
- module ApiAiRuby
4
- class VoiceRequest < ApiAiRuby::Request
5
- # @param client [ApiAiRuby::Client]
3
+ module VoxableApiAiRuby
4
+ class VoiceRequest < VoxableApiAiRuby::Request
5
+ # @param client [VoxableApiAiRuby::Client]
6
6
  # @param options [Hash]
7
- # @return [ApiAiRuby::VoiceRequest]
7
+ # @return [VoxableApiAiRuby::VoiceRequest]
8
8
  def initialize(client, options = {})
9
9
  @path = 'query'
10
10
 
@@ -20,4 +20,4 @@ module ApiAiRuby
20
20
  self
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
3
  describe 'api' do
4
- let (:client) { ApiAiRuby::Client.new(:client_access_token => '3485a96fb27744db83e78b8c4bc9e7b7')}
4
+ let (:client) { VoxableApiAiRuby::Client.new(:client_access_token => '3485a96fb27744db83e78b8c4bc9e7b7')}
5
5
 
6
6
  it 'should return response' do
7
7
  response = client.text_request 'Hello'
@@ -28,8 +28,8 @@ describe 'api' do
28
28
  end
29
29
 
30
30
  it 'should response with error on wrong credentials' do
31
- client = ApiAiRuby::Client.new(client_access_token: 'CS')
32
- expect {client.text_request}.to raise_error(ApiAiRuby::RequestError)
31
+ client = VoxableApiAiRuby::Client.new(client_access_token: 'CS')
32
+ expect {client.text_request}.to raise_error(VoxableApiAiRuby::RequestError)
33
33
  end
34
34
 
35
35
  it 'should send voiceData to API' do
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe ApiAiRuby::Client do
3
+ describe VoxableApiAiRuby::Client do
4
4
  describe '#user_agent' do
5
5
  it 'defaults ApiAiRubyRubyGem/version' do
6
- expect(subject.user_agent).to eq("ApiAiRubyGem/#{ApiAiRuby::Constants::VERSION}")
6
+ expect(subject.user_agent).to eq("ApiAiRubyGem/#{VoxableApiAiRuby::Constants::VERSION}")
7
7
  end
8
8
  end
9
9
 
@@ -16,49 +16,49 @@ describe ApiAiRuby::Client do
16
16
 
17
17
  describe '#client_credentials?' do
18
18
  it 'returns true if all client credentials are present' do
19
- client = ApiAiRuby::Client.new(client_access_token: 'CS')
19
+ client = VoxableApiAiRuby::Client.new(client_access_token: 'CS')
20
20
  expect(client.client_credentials?).to be_truthy
21
21
  end
22
22
 
23
23
  it 'returns false if any client credentials are missing' do
24
- client = ApiAiRuby::Client.new()
24
+ client = VoxableApiAiRuby::Client.new()
25
25
  expect(client.client_credentials?).to be_falsey
26
26
  end
27
27
 
28
28
  it 'raises error on request without client credentials' do
29
- expect {subject.text_request '123'}.to raise_error(ApiAiRuby::ClientError)
30
- expect {subject.voice_request '123'}.to raise_error(ApiAiRuby::ClientError)
29
+ expect {subject.text_request '123'}.to raise_error(VoxableApiAiRuby::ClientError)
30
+ expect {subject.voice_request '123'}.to raise_error(VoxableApiAiRuby::ClientError)
31
31
  end
32
32
  end
33
33
 
34
34
  describe '#developer_credentials?' do
35
35
  it 'returns true if all developer credentials are present' do
36
- client = ApiAiRuby::Client.new(developer_access_token: 'CS')
36
+ client = VoxableApiAiRuby::Client.new(developer_access_token: 'CS')
37
37
  expect(client.developer_credentials?).to be_truthy
38
38
  end
39
39
 
40
40
  it 'returns false if any developer credentials are missing' do
41
- client = ApiAiRuby::Client.new()
41
+ client = VoxableApiAiRuby::Client.new()
42
42
  expect(client.developer_credentials?).to be_falsey
43
43
  end
44
44
 
45
45
  it 'raises error on request without developer credentials' do
46
- expect {subject.text_request '123'}.to raise_error(ApiAiRuby::ClientError)
47
- expect {subject.voice_request '123'}.to raise_error(ApiAiRuby::ClientError)
46
+ expect {subject.text_request '123'}.to raise_error(VoxableApiAiRuby::ClientError)
47
+ expect {subject.voice_request '123'}.to raise_error(VoxableApiAiRuby::ClientError)
48
48
  end
49
49
  end
50
50
 
51
51
  describe '#properties' do
52
52
 
53
53
  it 'has correct default properties' do
54
- client = ApiAiRuby::Client.new(client_access_token: 'CS')
55
- expect(client.api_base_url).to eq ApiAiRuby::Constants::DEFAULT_BASE_URL
56
- expect(client.api_version).to eq ApiAiRuby::Constants::DEFAULT_API_VERSION
57
- expect(client.api_lang).to eq ApiAiRuby::Constants::DEFAULT_CLIENT_LANG
54
+ client = VoxableApiAiRuby::Client.new(client_access_token: 'CS')
55
+ expect(client.api_base_url).to eq VoxableApiAiRuby::Constants::DEFAULT_BASE_URL
56
+ expect(client.api_version).to eq VoxableApiAiRuby::Constants::DEFAULT_API_VERSION
57
+ expect(client.api_lang).to eq VoxableApiAiRuby::Constants::DEFAULT_CLIENT_LANG
58
58
  end
59
59
 
60
60
  it 'correctly creates client with given properties' do
61
- client = ApiAiRuby::Client.new(client_access_token: 'CS', api_lang: 'RU', api_base_url: 'http://localhost', api_version: '1234')
61
+ client = VoxableApiAiRuby::Client.new(client_access_token: 'CS', api_lang: 'RU', api_base_url: 'http://localhost', api_version: '1234')
62
62
  expect(client.api_base_url).to eq 'http://localhost'
63
63
  expect(client.api_version).to eq '1234'
64
64
  expect(client.api_lang).to eq 'RU'
@@ -1,21 +1,21 @@
1
1
  require 'helper'
2
2
 
3
- describe ApiAiRuby::RequestError do
3
+ describe VoxableApiAiRuby::RequestError do
4
4
  describe '#code' do
5
5
  it 'returns the error code' do
6
- error = ApiAiRuby::RequestError.new('execution expired', 123)
6
+ error = VoxableApiAiRuby::RequestError.new('execution expired', 123)
7
7
  expect(error.code).to eq(123)
8
8
  end
9
9
  end
10
10
 
11
11
  describe '#message' do
12
12
  it 'returns the error message' do
13
- error = ApiAiRuby::RequestError.new('execution expired')
13
+ error = VoxableApiAiRuby::RequestError.new('execution expired')
14
14
  expect(error.message).to eq('execution expired')
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
- describe ApiAiRuby::ClientError do
19
+ describe VoxableApiAiRuby::ClientError do
20
20
 
21
- end
21
+ end
@@ -10,7 +10,7 @@ SimpleCov.start do
10
10
  end
11
11
 
12
12
 
13
- require 'api-ai-ruby'
13
+ require 'voxable-api-ai-ruby'
14
14
  require 'rspec'
15
15
  #require 'webmock/rspec'
16
16
 
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'api-ai-ruby/constants'
4
+ require 'voxable-api-ai-ruby/constants'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'voxable-api-ai-ruby'
8
- spec.version = ApiAiRuby::Constants::VERSION
8
+ spec.version = VoxableApiAiRuby::Constants::VERSION
9
9
  spec.authors = ['api.ai']
10
10
  spec.email = ['shingarev@api.ai']
11
11
  spec.summary = %q{ruby SDK for https://api.ai }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxable-api-ai-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - api.ai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,19 +79,18 @@ files:
79
79
  - LICENSE
80
80
  - README.md
81
81
  - Rakefile
82
- - lib/api-ai-ruby.rb
83
- - lib/api-ai-ruby/client.rb
84
- - lib/api-ai-ruby/client_error.rb
85
- - lib/api-ai-ruby/constants.rb
86
- - lib/api-ai-ruby/get_entity_request.rb
87
- - lib/api-ai-ruby/get_intent_request.rb
88
- - lib/api-ai-ruby/request.rb
89
- - lib/api-ai-ruby/request_error.rb
90
- - lib/api-ai-ruby/text_request.rb
91
- - lib/api-ai-ruby/update_entities_request.rb
92
- - lib/api-ai-ruby/update_intent_request.rb
93
- - lib/api-ai-ruby/voice_request.rb
94
- - scratch.rb
82
+ - lib/voxable-api-ai-ruby.rb
83
+ - lib/voxable-api-ai-ruby/client.rb
84
+ - lib/voxable-api-ai-ruby/client_error.rb
85
+ - lib/voxable-api-ai-ruby/constants.rb
86
+ - lib/voxable-api-ai-ruby/get_entity_request.rb
87
+ - lib/voxable-api-ai-ruby/get_intent_request.rb
88
+ - lib/voxable-api-ai-ruby/request.rb
89
+ - lib/voxable-api-ai-ruby/request_error.rb
90
+ - lib/voxable-api-ai-ruby/text_request.rb
91
+ - lib/voxable-api-ai-ruby/update_entities_request.rb
92
+ - lib/voxable-api-ai-ruby/update_intent_request.rb
93
+ - lib/voxable-api-ai-ruby/voice_request.rb
95
94
  - spec/api-ai-ruby/api_spec.rb
96
95
  - spec/api-ai-ruby/client_spec.rb
97
96
  - spec/api-ai-ruby/error_spec.rb
@@ -1,12 +0,0 @@
1
- require 'api-ai-ruby/constants'
2
- require 'api-ai-ruby/client'
3
- require 'api-ai-ruby/request_error'
4
- require 'api-ai-ruby/client_error'
5
- require 'api-ai-ruby/request'
6
- require 'api-ai-ruby/text_request'
7
- require 'api-ai-ruby/voice_request'
8
- require 'api-ai-ruby/update_entities_request'
9
- require 'api-ai-ruby/update_intent_request'
10
- require 'api-ai-ruby/get_intent_request'
11
- require 'api-ai-ruby/get_entity_request'
12
-
data/scratch.rb DELETED
@@ -1,89 +0,0 @@
1
- require 'api-ai-ruby'
2
- require 'json'
3
- require '/Users/techpeace/.rvm/gems/ruby-2.2.0@vthreat/gems/awesome_print-1.6.1/lib/awesome_print'
4
-
5
- client = ApiAiRuby::Client.new(
6
- client_access_token: '6075a4572e17430d8976d3d236962ac4',
7
- developer_access_token: '9da728dd53cd47ba8de7b87080ccaa4b',
8
- subscription_key: '24c81cc6-0d3d-4a1c-8701-a3bd7ba6b02a',
9
- )
10
-
11
- =begin
12
- result = client.text_request('hello there')
13
- puts result.inspect
14
-
15
- entities = [
16
- {
17
- name: 'car',
18
- entries: [
19
- {
20
- value: 'car',
21
- synonyms: %w(car auto bus trike)
22
- }
23
- ]
24
- }
25
- ]
26
- result = client.update_entities_request(entities)
27
-
28
- puts result.inspect
29
-
30
- #curl -k -X PUT --data "[{'name': 'car', 'entries': [{'value':'car', 'synonyms':['car', 'auto', 'bus', 'whip']} ]}]" -H "Content-Type: application/json" -H "Authorization: Bearer 5dae99c607d2462bb11e1c2882816125" -H "ocp-apim-subscription-key: 24c81cc6-0d3d-4a1c-8701-a3bd7ba6b02a" "https://api.api.ai/api/entities?v=20150204"
31
-
32
- intent = {
33
- "id": "1dbfe740-2fbd-4c5e-95cf-0b3090eda942",
34
- "name": "launchSimulation",
35
- "auto": true,
36
- "contexts": [],
37
- "templates": [
38
- "launch a @simulation:simulationName @sys.date-time:simulationTime",
39
- "open @simulation:simulationName @sys.date-time:simulationTime",
40
- "run a @simulation:simulationName @sys.date-time:simulationTime",
41
- "run a @simulation:simulationName simulation @sys.date-time:simulationTime"
42
- ],
43
- "responses": [
44
- {
45
- "resetContexts": false,
46
- "affectedContexts": [],
47
- "parameters": [
48
- {
49
- "required": true,
50
- "dataType": "@simulation",
51
- "name": "simulationName",
52
- "value": "$simulationName",
53
- "prompts": [
54
- "Okay, which simulation would you like to run?",
55
- nil
56
- ]
57
- },
58
- {
59
- "required": false,
60
- "dataType": "@sys.date-time",
61
- "name": "simulationTime",
62
- "value": "$simulationTime",
63
- "defaultValue": ""
64
- }
65
- ],
66
- "speech": "okay, launching $simulationName simulation"
67
- }
68
- ],
69
- "state": "LEARNED",
70
- "priority": 750000,
71
- "cortanaCommand": {
72
- "navigateOrService": "NAVIGATE",
73
- "target": ""
74
- },
75
- "assistantCommand": {
76
- "urlCommand": "",
77
- "doCommand": ""
78
- }
79
- }
80
-
81
- result = client.update_intent_request(intent)
82
-
83
- puts result
84
- =end
85
-
86
- #result = client.get_intent_request('1dbfe740-2fbd-4c5e-95cf-0b3090eda942')
87
- result = client.get_intents_request
88
- puts result.to_json
89
-