typetalk 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/typetalk/api.rb +4 -7
- data/lib/typetalk/error.rb +0 -1
- data/lib/typetalk/version.rb +1 -1
- data/spec/typetalk/api/auth_spec.rb +5 -5
- data/spec/typetalk/api/user_spec.rb +2 -2
- data/typetalk.gemspec +0 -1
- metadata +3 -19
data/lib/typetalk/api.rb
CHANGED
@@ -28,14 +28,11 @@ module Typetalk
|
|
28
28
|
|
29
29
|
protected
|
30
30
|
def parse_response(response)
|
31
|
-
|
32
|
-
# TODO remove debug print
|
33
|
-
#require 'awesome_print'
|
34
|
-
#ap response
|
35
|
-
|
36
31
|
case response.status
|
37
|
-
when 400
|
32
|
+
when 400
|
38
33
|
raise InvalidRequest, response_values(response)
|
34
|
+
when 401
|
35
|
+
raise Unauthorized, response_values(response)
|
39
36
|
when 404
|
40
37
|
raise NotFound, response_values(response)
|
41
38
|
when 413
|
@@ -47,7 +44,7 @@ module Typetalk
|
|
47
44
|
end
|
48
45
|
|
49
46
|
def response_values(response)
|
50
|
-
{status: response.status, headers: response.headers, body: response.body}
|
47
|
+
{status: response.status, headers: response.headers, body: response.body}.to_json
|
51
48
|
end
|
52
49
|
|
53
50
|
end
|
data/lib/typetalk/error.rb
CHANGED
data/lib/typetalk/version.rb
CHANGED
@@ -25,11 +25,11 @@ describe Typetalk::Api::Auth do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should raise error when client_id is wrong' do
|
28
|
-
expect{ api.get_access_token(client_id: 'dummy_id') }.to raise_error(Typetalk::
|
28
|
+
expect{ api.get_access_token(client_id: 'dummy_id') }.to raise_error(Typetalk::Unauthorized)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should raise error when client_secret is wrong' do
|
32
|
-
expect{ api.get_access_token(client_secret: 'dummy_secret') }.to raise_error(Typetalk::
|
32
|
+
expect{ api.get_access_token(client_secret: 'dummy_secret') }.to raise_error(Typetalk::Unauthorized)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should get the correct resource by authorization_code' do
|
@@ -45,11 +45,11 @@ describe Typetalk::Api::Auth do
|
|
45
45
|
|
46
46
|
it 'should raise error when redirect_uri mismatch' do
|
47
47
|
api.authorization_code = '(AUTHORIZATION_CODE)'
|
48
|
-
expect{ api.get_access_token(grant_type: 'authorization_code', redirect_uri: 'http://dummy_mismatch/') }.to raise_error(Typetalk::
|
48
|
+
expect{ api.get_access_token(grant_type: 'authorization_code', redirect_uri: 'http://dummy_mismatch/') }.to raise_error(Typetalk::Unauthorized)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should raise error when authorization_code is wrong' do
|
52
|
-
expect{ api.get_access_token(grant_type: 'authorization_code', redirect_uri: 'http://dummy/', code:'dummy_code') }.to raise_error(Typetalk::
|
52
|
+
expect{ api.get_access_token(grant_type: 'authorization_code', redirect_uri: 'http://dummy/', code:'dummy_code') }.to raise_error(Typetalk::Unauthorized)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -71,7 +71,7 @@ describe Typetalk::Api::Auth do
|
|
71
71
|
|
72
72
|
it 'should raise error when refresh_token is wrong' do
|
73
73
|
response = api.get_access_token
|
74
|
-
expect{ api.update_access_token('dummy_token') }.to raise_error(Typetalk::
|
74
|
+
expect{ api.update_access_token('dummy_token') }.to raise_error(Typetalk::Unauthorized)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -15,12 +15,12 @@ describe Typetalk::Api::User do
|
|
15
15
|
|
16
16
|
it 'should raise error when access_token is wrong' do
|
17
17
|
api.get_access_token
|
18
|
-
expect{ api.get_profile(token: '(WRONG_ACCESS_TOKEN)') }.to raise_error(Typetalk::
|
18
|
+
expect{ api.get_profile(token: '(WRONG_ACCESS_TOKEN)') }.to raise_error(Typetalk::Unauthorized)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should raise error when scope is wrong' do
|
22
22
|
r = api.get_access_token(scope: 'topic.read,topic.post')
|
23
|
-
expect{ api.get_profile(token: r.access_token) }.to raise_error(Typetalk::
|
23
|
+
expect{ api.get_profile(token: r.access_token) }.to raise_error(Typetalk::Unauthorized)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/typetalk.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typetalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -139,22 +139,6 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: awesome_print
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
142
|
description: A Ruby wrapper for Typetalk
|
159
143
|
email:
|
160
144
|
- umakoz@gmail.com
|
@@ -277,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
261
|
version: '0'
|
278
262
|
segments:
|
279
263
|
- 0
|
280
|
-
hash:
|
264
|
+
hash: 1637806009810448064
|
281
265
|
requirements: []
|
282
266
|
rubyforge_project:
|
283
267
|
rubygems_version: 1.8.23
|