api-ai-ruby 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: b0c26a1fbd164ecd6dd0e2dc0f3b4f6b3786ff7c
4
- data.tar.gz: bfe06cb9f86d69f0157a3779b6d464acd8cc5641
3
+ metadata.gz: 1fbef071683c7b7e9915319e38ae44faa162a040
4
+ data.tar.gz: a60d2a0684adebc1f8e8b2461cce2aff7c876e00
5
5
  SHA512:
6
- metadata.gz: d7f1aa1be77d99141a6925257cedb478c791cf5fd894863cf57dd9357df015c3217c640054ac179a11f5d4cd16f71946cbc2791af4be6a56c96bec1e033bba90
7
- data.tar.gz: a7e6803956b3ad09e637cf428f6c429e82cb148f38f18567e664088380a697c0568fe1229585d1f114d3eac55eb20f7bbbf1b671d2b2484ec812e0ab8fe45f2e
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 here (https://docs.api.ai/docs/query#response)
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 instantination 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)
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 for that
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 'Hello', :timezone => "America/New_York"
73
+ response = client.voice_request file, :timezone => "America/New_York"
76
74
  ```
77
- More information about possible parameters cand be found at https://docs.api.ai/docs/query page
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
 
@@ -35,7 +35,6 @@ module ApiAiRuby
35
35
  def credentials
36
36
  {
37
37
  client_access_token: client_access_token,
38
- subscription_key: subscription_key
39
38
  }
40
39
  end
41
40
 
@@ -1,6 +1,6 @@
1
1
  module ApiAiRuby
2
2
  class Constants
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  DEFAULT_BASE_URL = 'https://api.api.ai/v1/'
5
5
  DEFAULT_API_VERSION = '20150204'
6
6
  DEFAULT_CLIENT_LANG = 'en'
@@ -18,7 +18,6 @@ module ApiAiRuby
18
18
  @options = options
19
19
  @headers = {
20
20
  'Authorization': 'Bearer ' + client.client_access_token,
21
- 'ocp-apim-subscription-key': 'Bearer ' + client.client_access_token
22
21
  }
23
22
  end
24
23
 
@@ -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', :subscription_key => 'cb9693af-85ce-4fbf-844a-5563722fc27f')}
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(subscription_key: 'SK', client_access_token: 'CS')
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.0.0
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: 2015-12-22 00:00:00.000000000 Z
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
- - ".gitignore"
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.4.8
118
+ rubygems_version: 2.0.14
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: ruby SDK for https://api.ai