omniauth-kounta 0.0.23 → 0.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
- SHA1:
3
- metadata.gz: 1b3d16e79826532dd90f32eca3478b56aafca88d
4
- data.tar.gz: 0cb04b46623be3fa9ca478a8b45dc05a31cab795
2
+ SHA256:
3
+ metadata.gz: ee654160f876796fbaf9eea1da42c51211bd0cc0a265ceb837c754e0ba48ac7b
4
+ data.tar.gz: c82d976db4b13e0a6760b2646499b0cde73bcce9142c339eff9c5972cfa7e888
5
5
  SHA512:
6
- metadata.gz: b6b91e8bdbdfe158cece280ee179a1e24770d2aaa9034bafb1036ab96f423ff7d278b0fb9be60d53297404c91f807b31c18e6b9bbbf5c13b89150e8e5102273a
7
- data.tar.gz: 512b1cf2facfd49571dd3b19afcaebdb280ab833ad508d2ab3ed45d35e7a529ce515d491d4da4ede949573141df8f03dda2ff09a3fac0d8dfb8bdd7b9330d8cf
6
+ metadata.gz: 8b9303a283251cc4a875921191f31c2f3ae2a4a1ec4141a15dabd11e7d58b4a8c35d5244926512c9b7dfb010db962d732d512fac1ba2cc0ad935562cb3374957
7
+ data.tar.gz: 76a0d3c19179c5aa2001b061acf6b8276c6cb2eda0f26ebc8d5bd897d8fa90c8e0ba135a4bd75ac8644b0e411369201fb572e027234c91e6f7258b3865037249
data/README.md CHANGED
@@ -0,0 +1,6 @@
1
+
2
+ Be sure to set a redirect URI e.g.
3
+
4
+ option :token_params, {
5
+ :redirect_uri => "https://goodtucker-dev.ngrok.io/auth/kounta/callback"
6
+ }
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Kounta
3
- VERSION = '0.0.23'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'omniauth-oauth2'
2
- require 'openssl'
3
- require 'base64'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
4
 
5
5
  module OmniAuth
6
6
  module Strategies
@@ -14,15 +14,32 @@ module OmniAuth
14
14
  :token_url => "#{ApiUrl}/v1/token.json"
15
15
  }
16
16
 
17
- option :token_params, {
18
- :redirect_uri => "https://rhys-kounta.ngrok.io/auth/kounta/callback"
19
- }
17
+ info do
18
+ {
19
+ company: company_info,
20
+ user: user_info
21
+ }
22
+ end
23
+
24
+ def company_info
25
+ @company_info ||= MultiJson.decode(kounta_api.get("/v1/companies/me.json").body)
26
+ end
27
+
28
+ def user_info
29
+ company_id = company_info.dig("id")
30
+ @user_info ||= MultiJson.decode(kounta_api.get("/v1/companies/#{company_id}/staff/me.json").body)
31
+ end
20
32
 
21
- def token_params
22
- params = super
23
- p callback_url
24
- p params
25
- params
33
+ def kounta_api
34
+ @kounta_api ||= Faraday.new(
35
+ url: ApiUrl,
36
+ headers: {
37
+ "Accept" => "application/json",
38
+ "Authorization" => "Bearer #{access_token.token}",
39
+ }) { |b|
40
+ b.use FaradayMiddleware::FollowRedirects
41
+ b.adapter :net_http
42
+ }
26
43
  end
27
44
  end
28
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-kounta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhys Elsmore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-28 00:00:00.000000000 Z
11
+ date: 2019-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rack-test
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -125,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
139
  - !ruby/object:Gem::Version
126
140
  version: '0'
127
141
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.6.11
142
+ rubygems_version: 3.0.3
130
143
  signing_key:
131
144
  specification_version: 4
132
145
  summary: OmniAuth strategy for Kounta.