omniauth-calendly 0.0.1.alpha → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a47a1210cb70e91c44bf8f42907b44c292f101baf5ad93dc5fac58d873b0d473
4
- data.tar.gz: 5c1cb8c3b4b170cd622b80412926f97d318565d1c97ffab73dd730cc517445c0
3
+ metadata.gz: 07db7da420c059a9aad8a228031254fca84856d76654cfe65985d02a4c5e6e8a
4
+ data.tar.gz: ad34222ebfcce6696565943487e2aeef521bf7171e17600011ec9e28d7b857e4
5
5
  SHA512:
6
- metadata.gz: f5dc0d3b3778a0851cb0248a7e82c7d8f58186c729b855c18175c56a4c2b01679047b3dd91a6fa71142b36f421ae7cca194d0c5fb0aff58b0c685b8df922acf1
7
- data.tar.gz: f5e645cfd64c4f95caa3bf9c271cd294117a08d47706fae35b4e9f3e8c262471772fcdce07ef4dced8e746113b754a859dd212438d0e5fe82fd9dd7539e65d06
6
+ metadata.gz: c8cb083df5432b150c61d044c9e4c0b868776bceada4371562a83c43373d294914833f83c88f61f07dd196138312cca39f6a69cbd0acefa1789176615f4acc25
7
+ data.tar.gz: 6c25a690bace4d4c4944a4f8ca7dddb44f35ba740c2b059c1492169e4dd1886d240ac12f71d65b98815b12cb2ecaf12798a198c07eb312050e3c55ae40f0b928
@@ -1,3 +1,8 @@
1
+ # 0.1.0
2
+
3
+ - #1 extract uid from user api response.
4
+ - #2 make coverage 100%.
5
+
1
6
  # 0.0.1.alpha
2
7
 
3
8
  - Initial release
data/README.md CHANGED
@@ -47,7 +47,34 @@ end
47
47
  The auth hash `request.env['omniauth.auth']` would look like this:
48
48
 
49
49
  ```js
50
- TODO
50
+ {
51
+ "result": {
52
+ "provider": "calendly",
53
+ "uid": "U12345678",
54
+ "info": {},
55
+ "credentials": {
56
+ "token": "ACCESS_TOKEN",
57
+ "refresh_token": "REFRESH_TOKEN",
58
+ "expires_at": 1596529477,
59
+ "expires": true
60
+ },
61
+ "extra": {
62
+ "raw_info": {
63
+ "resource": {
64
+ "avatar_url": "https://xxx.cloudfront.net/uploads/user/avatar/xxx/xxx.gif",
65
+ "created_at": "2020-07-17T05:36:18.596606Z",
66
+ "email": "hoge@example.com",
67
+ "name": "USER_NAME",
68
+ "scheduling_url": "https://calendly.com/hogehoge",
69
+ "slug": "hogehoge",
70
+ "timezone": "Asia/Tokyo",
71
+ "updated_at": "2020-08-03T15:28:55.101449Z",
72
+ "uri": "https://api.calendly.com/users/U12345678"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
51
78
  ```
52
79
 
53
80
  ## Contributing
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Calendly
5
- VERSION = '0.0.1.alpha'
5
+ VERSION = '0.1.0'
6
6
  end
7
7
  end
@@ -9,7 +9,9 @@ module OmniAuth
9
9
  option :name, 'calendly'
10
10
  option :client_options, :site => 'https://auth.calendly.com'
11
11
 
12
- uid { raw_info['id'] }
12
+ USER_API_URL = 'https://api.calendly.com/users/'
13
+
14
+ uid { extract_uid }
13
15
  extra { {:raw_info => raw_info} }
14
16
 
15
17
  private
@@ -17,16 +19,26 @@ module OmniAuth
17
19
  def raw_info
18
20
  return @raw_info if defined?(@raw_info)
19
21
 
20
- endpoint = 'https://api.calendly.com/users/me'
21
- @raw_info = access_token.get(endpoint).parsed
22
- rescue ::OAuth2::Error => e
23
- log(:error, "#{e.class} occured. message:#{e.message}")
24
- @raw_info = {}
22
+ @raw_info = access_token.get("#{USER_API_URL}me").parsed
25
23
  end
26
24
 
27
25
  def callback_url
28
26
  full_host + script_name + callback_path
29
27
  end
28
+
29
+ def extract_uid
30
+ user_info = raw_info
31
+ return unless user_info
32
+ return unless raw_info['resource']
33
+ return unless raw_info['resource']['uri']
34
+
35
+ uri = raw_info['resource']['uri']
36
+ re = /\A#{USER_API_URL}(.+)\z/
37
+ m = re.match uri
38
+ return if m.nil?
39
+
40
+ m[1]
41
+ end
30
42
  end
31
43
  end
32
44
  end
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'minitest', '~> 5.14.1'
36
36
  spec.add_development_dependency 'minitest-reporters', '~> 1.4.2'
37
37
  spec.add_development_dependency 'omniauth', '~> 1.9.1'
38
+ spec.add_development_dependency 'rack-test', '~> 1.1.0'
38
39
  spec.add_development_dependency 'rake', '~> 13.0'
39
40
  spec.add_development_dependency 'simplecov', '~> 0.18.5'
40
41
  spec.add_development_dependency 'webmock', '~> 3.7.6'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-calendly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Koshikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.9.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +180,7 @@ metadata:
166
180
  homepage_uri: https://github.com/koshilife/omniauth-calendly
167
181
  source_code_uri: https://github.com/koshilife/omniauth-calendly
168
182
  changelog_uri: https://github.com/koshilife/omniauth-calendly/blob/master/CHANGELOG.md
169
- documentation_uri: https://www.rubydoc.info/gems/omniauth-calendly/0.0.1.alpha
183
+ documentation_uri: https://www.rubydoc.info/gems/omniauth-calendly/0.1.0
170
184
  post_install_message:
171
185
  rdoc_options: []
172
186
  require_paths:
@@ -178,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
192
  version: 2.4.0
179
193
  required_rubygems_version: !ruby/object:Gem::Requirement
180
194
  requirements:
181
- - - ">"
195
+ - - ">="
182
196
  - !ruby/object:Gem::Version
183
- version: 1.3.1
197
+ version: '0'
184
198
  requirements: []
185
199
  rubygems_version: 3.0.3
186
200
  signing_key: