api-ai-ruby 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -9
- data/lib/api-ai-ruby/client.rb +0 -1
- data/lib/api-ai-ruby/constants.rb +1 -1
- data/lib/api-ai-ruby/request_query.rb +0 -1
- data/spec/api-ai-ruby/api_spec.rb +2 -2
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fbef071683c7b7e9915319e38ae44faa162a040
|
4
|
+
data.tar.gz: a60d2a0684adebc1f8e8b2461cce2aff7c876e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1d53a014ef3c8b82c41176a06358eee4ce4294aa1bc342a3175155de82fc810fd6fd0b8742aba7bba32214489c67459862c287db6f9b500b679eefa1e50dad3
|
7
|
+
data.tar.gz: e6b25282f16e842fe635be4cd1e07fee703753142ed1dc46f6cf9560e3be108d4e21ff673bd84466205fd4963c6b1cc43b02305413e872426a457b5b184e832f
|
data/README.md
CHANGED
@@ -7,12 +7,11 @@ A Ruby SDK to the https://api.ai natural language processing service.
|
|
7
7
|
|
8
8
|
## Basic Usage
|
9
9
|
|
10
|
-
Just pass correct credentials to ApiAiRuby::Client constructor
|
10
|
+
Just pass correct credentials to **ApiAiRuby::Client** constructor
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
client = ApiAiRuby::Client.new(
|
14
14
|
:client_access_token => 'YOUR_ACCESS_TOKEN',
|
15
|
-
:subscription_key => 'YOUR_SUBSCRIPTION_KEY'
|
16
15
|
)
|
17
16
|
```
|
18
17
|
After that you can send text requests to the https://api.ai with command
|
@@ -52,15 +51,14 @@ Example answer:
|
|
52
51
|
}
|
53
52
|
```
|
54
53
|
|
55
|
-
voice_request and text_request methods returns symbolized https://api.ai response. Structure of response can be found
|
54
|
+
**voice_request** and **text_request** methods returns symbolized https://api.ai response. Structure of response can be found at https://docs.api.ai/docs/query#response.
|
56
55
|
|
57
56
|
## Advanced usage
|
58
57
|
|
59
|
-
During client
|
58
|
+
During client instantiating you can additionally set parameters like **api url**, request **language** and **version** (more info at https://docs.api.ai/docs/versioning, https://docs.api.ai/docs/languages)
|
60
59
|
|
61
60
|
```ruby
|
62
61
|
ApiAiRuby::Client.new(
|
63
|
-
subscription_key: 'YOUR_SUBSCRIPTION_KEY',
|
64
62
|
client_access_token: 'YOUR_ACCESS_TOKEN',
|
65
63
|
api_lang: 'FR',
|
66
64
|
api_base_url: 'http://example.com/v1/',
|
@@ -68,15 +66,16 @@ ApiAiRuby::Client.new(
|
|
68
66
|
)
|
69
67
|
```
|
70
68
|
|
71
|
-
And you also can send additional data to server during request, use second parameter of text_request and voice_request methods
|
69
|
+
And you also can send additional data to server during request, use second parameter of **text_request** and **voice_request** methods to do that
|
72
70
|
|
73
71
|
```ruby
|
74
72
|
response = client.text_request 'Hello', :contexts => ['firstContext'], :resetContexts => true
|
75
|
-
response = client.voice_request
|
73
|
+
response = client.voice_request file, :timezone => "America/New_York"
|
76
74
|
```
|
77
|
-
More information about possible parameters
|
78
|
-
|
75
|
+
More information about possible parameters can be found at https://docs.api.ai/docs/query page
|
79
76
|
|
77
|
+
#Error handling
|
78
|
+
**ApiAiRuby::Client** currently able to raise two kind of errors: **ApiAiRuby::ClientError** (due to configuration mismatch) and **ApiAiRuby::RequestError** in case of something goes wrong during request. For both kind of errors you can get **error.message** (as usual) and **ApiAiRuby::RequestError** can additionally give you code of server error (you can get it with **error.code**)
|
80
79
|
|
81
80
|
|
82
81
|
|
data/lib/api-ai-ruby/client.rb
CHANGED
@@ -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) { ApiAiRuby::Client.new(:client_access_token => '3485a96fb27744db83e78b8c4bc9e7b7')}
|
5
5
|
|
6
6
|
it 'should return response' do
|
7
7
|
response = client.text_request 'Hello'
|
@@ -28,7 +28,7 @@ describe 'api' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should response with error on wrong credentials' do
|
31
|
-
client = ApiAiRuby::Client.new(
|
31
|
+
client = ApiAiRuby::Client.new(client_access_token: 'CS')
|
32
32
|
expect {client.text_request}.to raise_error(ApiAiRuby::RequestError)
|
33
33
|
end
|
34
34
|
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-ai-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- api.ai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: http
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.9.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: http-form_data
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
69
|
description: Plugin makes it easy to integrate your Ruby application with https://api.ai
|
@@ -74,7 +74,7 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
-
|
77
|
+
- .gitignore
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE
|
80
80
|
- README.md
|
@@ -105,17 +105,17 @@ require_paths:
|
|
105
105
|
- lib
|
106
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - '>='
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.0.14
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: ruby SDK for https://api.ai
|