omniauth-todoist 0.3 → 0.5.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
  SHA1:
3
- metadata.gz: 0935c38d959c38bb589902becff12c1e20c4e6ce
4
- data.tar.gz: 7dd6b444a59f460265d014b8ea253e5d923a424f
3
+ metadata.gz: 2e827a084881bc92acf2dba96cbb0caa559b9365
4
+ data.tar.gz: c6ebe163145c87174cb29e86da45e044f35d1acd
5
5
  SHA512:
6
- metadata.gz: 378aedbcd5d2384513131c4c1197f97fd92bc9737761190bb19877a5ba070df3b1a943e462405b5f32ceb37d1209f462e9b382337d1e718c461d013b4904e57c
7
- data.tar.gz: 7ed8853b3c0abe5ef8b0035d38a041fe2238cbce3284fb5bfd826249e0a95e896a1d176590739b23a3d9a82d2d519eaa48b0dab678960986fd25b2868b23ca86
6
+ metadata.gz: 11171dbf3a74d836b7945237aec1f27c71eb40269ce491d8eb269186c9061119d7e1c7604139a69f077b462c4f81b08c7aa3784b679fe3b49996387cb43a45bc
7
+ data.tar.gz: f5c6d35b329301c2f6778e15610d7b52b8d26713377fd9b5f427480c02ab704f035dfa813c7c5a10f625d89e0004a4373a6b839e25843172c52e464144d8b390
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -5,39 +5,35 @@ require 'multi_json'
5
5
  module OmniAuth
6
6
  module Strategies
7
7
  class Todoist < OmniAuth::Strategies::OAuth2
8
- DEFAULT_SCOPE = 'data:read'
9
-
10
- # Give your strategy a name.
11
8
  option :name, "todoist"
12
9
 
13
- # This is where you pass the options you would pass when
14
- # initializing your consumer from the OAuth gem.
15
10
  option :client_options, {
16
- :site => "https://todoist.com",
17
- :authorize_url => "/oauth/authorize",
18
- :token_url => "/oauth/access_token"
11
+ site: "https://todoist.com",
12
+ authorize_url: "/oauth/authorize",
13
+ token_url: "/oauth/access_token"
19
14
  }
20
15
 
16
+ option :authorize_options, [:scope]
17
+
21
18
  # These are called after authentication has succeeded. If
22
19
  # possible, you should try to set the UID without making
23
20
  # additional calls (if the user id is returned with the token
24
21
  # or as a URI parameter). This may not be possible with all
25
22
  # providers.
26
- uid{ raw_info['id'] }
23
+ uid{ raw_info['id'].to_s }
27
24
 
28
25
  info do
29
- { :email => raw_info["email"],
30
- :name => raw_info["full_name"] }
26
+ prune!(
27
+ name: raw_info['full_name'],
28
+ email: raw_info['email'],
29
+ phone: raw_info['mobile_number'],
30
+ image: raw_info['avatar_big'],
31
+ time_zone: raw_info['tz_info']['timezone']
32
+ )
31
33
  end
32
-
33
- extra{ raw_info }
34
34
 
35
- def request_phase
36
- super
37
- end
38
-
39
- def callback_phase
40
- super
35
+ extra do
36
+ prune!(raw_info: raw_info)
41
37
  end
42
38
 
43
39
  # Bugfix for regression introduced after omniauth-oauth2 v1.3.1
@@ -47,25 +43,29 @@ module OmniAuth
47
43
  end
48
44
 
49
45
  def raw_info
50
- unless @raw_info
51
- user_info = access_token.post("/API/v7/sync", {
52
- body: {
53
- token: access_token.token,
54
- sync_token: "*",
55
- resource_types: '["user"]' },
46
+ @raw_info ||= begin
47
+ params = {
56
48
  headers: {
57
- "Content-Type"=>"application/x-www-form-urlencoded" }
58
- }).parsed
59
- if user_info["user"]
60
- @raw_info = user_info["user"]
61
- else
62
- @raw_info = {}
63
- end
49
+ "Content-Type" => "application/x-www-form-urlencoded"
50
+ },
51
+ body: {
52
+ token: access_token.token,
53
+ sync_token: "*",
54
+ resource_types: '["user"]'
55
+ }
56
+ }
57
+ access_token.post("https://api.todoist.com/sync/v8/sync", params).parsed.fetch('user', {})
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def prune!(hash)
64
+ hash.delete_if do |_, value|
65
+ prune!(value) if value.is_a?(Hash)
66
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
64
67
  end
65
- @raw_info
66
68
  end
67
69
  end
68
70
  end
69
71
  end
70
-
71
-
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Todoist
3
+ VERSION = "0.5.0"
4
+ end
5
+ end
@@ -1,15 +1,28 @@
1
- Gem::Specification.new do |gem|
2
- gem.name = 'omniauth-todoist'
3
- gem.version = '0.3'
4
- gem.date = Date.today.to_s
5
- gem.license = 'MIT'
6
- gem.summary = "OmniAuth strategy for Todoist"
7
- gem.description = "OmniAuth strategy for Todoist"
8
-
9
- gem.authors = ['Bethany Soule']
10
- gem.email = 'bsoule@beeminder.com'
11
- gem.homepage = 'https://github.com/beeminder/omniauth-todoist'
12
-
13
- gem.files = `git ls-files`.split("\n")
14
- gem.require_path = 'lib'
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/todoist/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "omniauth-todoist"
8
+ s.version = Omniauth::Todoist::VERSION
9
+ s.authors = ["Bethany Soule", "Joel Van Horn"]
10
+ s.email = ["bsoule@beeminder.com", "joel@joelvanhorn.com"]
11
+
12
+ s.summary = %q{OmniAuth strategy for Todoist}
13
+ s.description = %q{OmniAuth strategy for Todoist}
14
+ s.homepage = "https://github.com/beeminder/omniauth-todoist"
15
+ s.license = "MIT"
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency "omniauth", ">= 1.1.1"
23
+ s.add_runtime_dependency "omniauth-oauth2", ">= 1.3.1"
24
+
25
+ s.add_development_dependency "bundler"
26
+ s.add_development_dependency "rspec"
27
+ s.add_development_dependency "rake"
15
28
  end
metadata CHANGED
@@ -1,27 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-todoist
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Soule
8
+ - Joel Van Horn
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
12
- dependencies: []
12
+ date: 2019-09-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.1.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.3.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.3.1
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
13
84
  description: OmniAuth strategy for Todoist
14
- email: bsoule@beeminder.com
85
+ email:
86
+ - bsoule@beeminder.com
87
+ - joel@joelvanhorn.com
15
88
  executables: []
16
89
  extensions: []
17
90
  extra_rdoc_files: []
18
91
  files:
92
+ - ".gitignore"
19
93
  - Gemfile
20
94
  - LICENSE.txt
21
95
  - README.md
22
96
  - lib/omniauth-todoist.rb
23
97
  - lib/omniauth/strategies/todoist.rb
24
- - omniauth-todoist-0.1.gem
98
+ - lib/omniauth/todoist/version.rb
25
99
  - omniauth-todoist.gemspec
26
100
  homepage: https://github.com/beeminder/omniauth-todoist
27
101
  licenses:
Binary file