safie 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/safie/access_token.rb +30 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d51306af691333c0dbabc183f743423b5b57e95dd25780ebbb4eaa815836b08e
4
- data.tar.gz: 19253ab2bab74b84b9db97cedb6e29b0ee726e7c64ffb606f970fd2af5747785
3
+ metadata.gz: c322e6bbb628507a172dcfc47d18d0b0a235e5360cd3e2437a78f931548c67a2
4
+ data.tar.gz: bc16514d4641816bb8d09c36de3a148fe4878fbdd843479094fbd7df692fb103
5
5
  SHA512:
6
- metadata.gz: 79775c99ad4ede0af6486aaa16bc8238dbe33cfa1c90b1406b1f4557382c7c0121141b05aff6f14b630df0943b018a0ba77aebbdb11d8e2a6d2e446ef4996c8f
7
- data.tar.gz: 6e6c332f7f83157ce369f75070d530cf3ad839c3afbee6ef8c218cfe57f1aac9919238fbb58afd6bd66c14c403342ef4a4fe3f4b4d6651c2ce3f12a4b867a709
6
+ metadata.gz: 8368d23b5456a5c98227bcc53e9bf40be9141916229671021348e700cb07e80abab1c4243919f7ceca10ae83ea63ac77e5c87546a28ec16890f1ea446780e777
7
+ data.tar.gz: 659cb03e5750197c76d7f7e65e948c4626a86567a188919cac430e60b7e75c93fa428a555aace554b8952ffa0e00cdd12ee170a892f6122be3cc063d96504348
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -6,8 +6,36 @@ module Safie
6
6
  super attributes.merge(access_token: access_token)
7
7
  end
8
8
 
9
- def token_info!
10
- get File.join(ISSUER, '/auth/tokeninfo')
9
+ def token_info!(params = {})
10
+ resource_request do
11
+ get File.join(ISSUER, '/auth/tokeninfo'), params
12
+ end
13
+ end
14
+
15
+ def user_info!(params = {})
16
+ token_info = token_info! params
17
+ {
18
+ sub: token_info[:user_id],
19
+ email: token_info[:mail_address]
20
+ }
21
+ end
22
+
23
+ private
24
+
25
+ def resource_request
26
+ res = yield
27
+ case res.status
28
+ when 200
29
+ JSON.parse(res.body).with_indifferent_access
30
+ when 400
31
+ raise BadRequest.new('API Access Faild', res)
32
+ when 401
33
+ raise Unauthorized.new('Access Token Invalid or Expired', res)
34
+ when 403
35
+ raise Forbidden.new('Insufficient Scope', res)
36
+ else
37
+ raise HttpError.new(res.status, 'Unknown HttpError', res)
38
+ end
11
39
  end
12
40
  end
13
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov