spearly-sdk-ruby 0.2.3 → 0.5.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 +4 -4
- data/.gitignore +11 -10
- data/CHANGELOG.md +23 -2
- data/README.md +35 -6
- data/lib/spearly/auth/authorizer.rb +10 -2
- data/lib/spearly/auth/client.rb +128 -0
- data/lib/spearly/auth/oauth_user.rb +6 -6
- data/lib/spearly/auth/rails/helpers.rb +2 -4
- data/lib/spearly/auth/team.rb +6 -9
- data/lib/spearly/auth/token.rb +9 -13
- data/lib/spearly/auth/user.rb +12 -43
- data/lib/spearly/auth.rb +1 -0
- data/lib/spearly/version.rb +1 -1
- data/spearly.gemspec +1 -1
- metadata +4 -4
- data/Gemfile.lock +0 -93
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13ec9bdf4ea5bf140a8db9a87058c52651fe0631a78f43b1acf116b712270865
|
|
4
|
+
data.tar.gz: e496438935bfdd23172c8acf06f3c70f2407b362231d15bcd4da6908f7c87d03
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7cbe36feb66608124b4fb66afc5a7da7564a32af2464cd9bf5ebb3872aca7fe60c23c163bda107479361e4717d3596fee88c506b1160a5e4f0d584421ef0639
|
|
7
|
+
data.tar.gz: b3a9470ca734f081e49f54f2949a03bfaa52fb4c2a4f35039a2d90f50563e44c17351ec3657146efe47dc3de61ec990fe776df8da0308f21c93d41274955bdfe
|
data/.gitignore
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
/.yardoc
|
|
3
|
-
/_yardoc/
|
|
4
|
-
/coverage/
|
|
5
|
-
/doc/
|
|
6
|
-
/pkg/
|
|
7
|
-
/spec/reports/
|
|
8
|
-
/tmp/
|
|
9
|
-
|
|
10
|
-
# rspec failure tracking
|
|
1
|
+
.bundle
|
|
11
2
|
.rspec_status
|
|
3
|
+
.ruby-version
|
|
4
|
+
.yardoc
|
|
5
|
+
_yardoc/
|
|
6
|
+
coverage/
|
|
7
|
+
doc/
|
|
8
|
+
Gemfile.local
|
|
9
|
+
Gemfile.lock
|
|
10
|
+
pkg/
|
|
11
|
+
spec/reports/
|
|
12
|
+
tmp/
|
data/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
## [0.5.0] - 2021-12-13
|
|
2
|
+
|
|
3
|
+
- Spearly::Auth::Client
|
|
4
|
+
|
|
5
|
+
## [0.4.0] - 2021-09-13
|
|
6
|
+
|
|
7
|
+
- Error handling improvements
|
|
8
|
+
|
|
9
|
+
## [0.3.2] - 2021-09-13
|
|
10
|
+
|
|
11
|
+
- Use the new `Spearly API v2`
|
|
12
|
+
- Refactors parsing `JSON` data
|
|
13
|
+
|
|
14
|
+
## [0.2.4] - 2021-07-16
|
|
15
|
+
|
|
16
|
+
- Rescue `Signet::AuthorizationError` on `Spearly::Auth::Authorizer`
|
|
17
|
+
|
|
18
|
+
## [0.2.3] - 2021-06-18
|
|
19
|
+
|
|
20
|
+
- Raise `Spearly::Auth::AuthorizationError` and `Spearly::Auth::ServerError` from `Spearly::Auth::User` and `Spearly::Auth::Token`
|
|
21
|
+
|
|
1
22
|
## [0.2.2] - 2021-06-11
|
|
2
23
|
|
|
3
|
-
- Updates README and gem specs
|
|
24
|
+
- Updates `README` and gem specs
|
|
4
25
|
|
|
5
26
|
## [0.2.1] - 2021-05-31
|
|
6
27
|
|
|
7
|
-
- Initialize Spearly::Auth::User with bearer token
|
|
28
|
+
- Initialize `Spearly::Auth::User` with bearer token
|
|
8
29
|
|
|
9
30
|
## [0.2.0] - 2021-05-31
|
|
10
31
|
|
data/README.md
CHANGED
|
@@ -7,26 +7,55 @@ Spearly SDK for Ruby.
|
|
|
7
7
|
Add this line to your application's `Gemfile`:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem 'spearly-sdk-ruby', '~>
|
|
10
|
+
gem 'spearly-sdk-ruby', '~> x.y.z', require: 'spearly'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
And then execute:
|
|
14
14
|
```sh
|
|
15
|
-
|
|
15
|
+
bundle install
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Or install it
|
|
18
|
+
Or install it manually:
|
|
19
19
|
```sh
|
|
20
|
-
|
|
20
|
+
gem install spearly-sdk-ruby
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Contribute
|
|
24
|
+
### Increment version
|
|
25
|
+
```sh
|
|
26
|
+
vim lib/spearly/version.rb
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Update CHANGELOG
|
|
30
|
+
```sh
|
|
31
|
+
vim CHANGELOG.md
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Update Gemfile.lock
|
|
35
|
+
```sh
|
|
36
|
+
bundle install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### New version commit
|
|
40
|
+
```sh
|
|
41
|
+
new_version=$(ruby -e "require './lib/spearly/version'; puts Spearly::VERSION")
|
|
42
|
+
|
|
43
|
+
git commit -m "v$new_version"
|
|
44
|
+
git tag -a v$new_version -m "Release $new_version"
|
|
45
|
+
|
|
46
|
+
git push origin main
|
|
47
|
+
git push origin --tags
|
|
21
48
|
```
|
|
22
49
|
|
|
23
50
|
## Publish
|
|
24
51
|
### Build
|
|
25
52
|
```sh
|
|
26
|
-
|
|
53
|
+
rake build
|
|
27
54
|
```
|
|
28
55
|
|
|
29
56
|
### Push to RubyGems
|
|
30
57
|
```sh
|
|
31
|
-
|
|
58
|
+
new_version=$(ruby -e "require './lib/spearly/version'; puts Spearly::VERSION")
|
|
59
|
+
|
|
60
|
+
gem push pkg/spearly-sdk-ruby-$new_version.gem
|
|
32
61
|
```
|
|
@@ -12,18 +12,26 @@ module Spearly
|
|
|
12
12
|
|
|
13
13
|
def method_missing(name, *args)
|
|
14
14
|
@client.send(name, *args)
|
|
15
|
+
rescue Signet::AuthorizationError
|
|
16
|
+
raise Spearly::Auth::AuthorizationError
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
|
18
20
|
|
|
19
21
|
def initialize_client
|
|
22
|
+
Faraday.default_connection_options = {
|
|
23
|
+
headers: {
|
|
24
|
+
'Accept' => 'application/vnd.spearly.v2+json'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
client = ::Signet::OAuth2::Client.new
|
|
21
29
|
client.client_id = @params[:client_id] || @params['client_id']
|
|
22
30
|
client.client_secret = @params[:client_secret] || @params['client_secret']
|
|
23
31
|
client.code = @params[:code] || @params['code']
|
|
24
32
|
client.grant_type = @params[:grant_type] || @params['grant_type']
|
|
25
|
-
client.authorization_uri = "#{ENV['
|
|
26
|
-
client.token_credential_uri = "#{ENV['
|
|
33
|
+
client.authorization_uri = "#{ENV['SPEARLY_API_URL']}/oauth/authorize"
|
|
34
|
+
client.token_credential_uri = "#{ENV['SPEARLY_API_URL']}/oauth/token"
|
|
27
35
|
client.redirect_uri = @params[:redirect_uri] || @params['redirect_uri']
|
|
28
36
|
|
|
29
37
|
client.access_token = @params[:access_token] || @params['access_token']
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module Spearly
|
|
2
|
+
module Auth
|
|
3
|
+
class Client
|
|
4
|
+
def initialize(token)
|
|
5
|
+
@token = token
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create_team(params)
|
|
9
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams"
|
|
10
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
11
|
+
client = Faraday.default_connection
|
|
12
|
+
|
|
13
|
+
res = client.post(uri_parsed,
|
|
14
|
+
params.as_json,
|
|
15
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
16
|
+
'Authorization' => @token)
|
|
17
|
+
|
|
18
|
+
if res.status == 201
|
|
19
|
+
JSON.parse(res.body)['data']
|
|
20
|
+
else
|
|
21
|
+
{}
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_team(team_id)
|
|
26
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}"
|
|
27
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
28
|
+
client = Faraday.default_connection
|
|
29
|
+
|
|
30
|
+
res = client.get(uri_parsed,
|
|
31
|
+
nil,
|
|
32
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
33
|
+
'Authorization' => @token)
|
|
34
|
+
|
|
35
|
+
if res.status == 200
|
|
36
|
+
JSON.parse(res.body)['data']
|
|
37
|
+
else
|
|
38
|
+
{}
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_teams(params = {})
|
|
43
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams"
|
|
44
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
45
|
+
client = Faraday.default_connection
|
|
46
|
+
|
|
47
|
+
res = client.get(uri_parsed,
|
|
48
|
+
params.as_json,
|
|
49
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
50
|
+
'Authorization' => @token)
|
|
51
|
+
|
|
52
|
+
if res.status == 200
|
|
53
|
+
JSON.parse(res.body)['data']
|
|
54
|
+
else
|
|
55
|
+
[]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def update_team(team_id, params)
|
|
60
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}"
|
|
61
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
62
|
+
client = Faraday.default_connection
|
|
63
|
+
|
|
64
|
+
res = client.put(uri_parsed,
|
|
65
|
+
params.as_json,
|
|
66
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
67
|
+
'Authorization' => @token)
|
|
68
|
+
|
|
69
|
+
if res.status == 200
|
|
70
|
+
JSON.parse(res.body)['data']
|
|
71
|
+
else
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def regenerate_team_api_access_token(team_id)
|
|
77
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/regenerate_api_access_token"
|
|
78
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
79
|
+
client = Faraday.default_connection
|
|
80
|
+
|
|
81
|
+
res = client.post(uri_parsed,
|
|
82
|
+
nil,
|
|
83
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
84
|
+
'Authorization' => @token)
|
|
85
|
+
|
|
86
|
+
if res.status == 200
|
|
87
|
+
JSON.parse(res.body)['data']
|
|
88
|
+
else
|
|
89
|
+
nil
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def invite_user_to_team(team_id, params)
|
|
94
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/invite"
|
|
95
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
96
|
+
client = Faraday.default_connection
|
|
97
|
+
|
|
98
|
+
res = client.post(uri_parsed,
|
|
99
|
+
params.as_json,
|
|
100
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
101
|
+
'Authorization' => @token)
|
|
102
|
+
|
|
103
|
+
if res.status == 201
|
|
104
|
+
JSON.parse(res.body)['data']
|
|
105
|
+
else
|
|
106
|
+
nil
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def get_team_members(team_id)
|
|
111
|
+
uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/members"
|
|
112
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
|
113
|
+
client = Faraday.default_connection
|
|
114
|
+
|
|
115
|
+
res = client.get(uri_parsed,
|
|
116
|
+
nil,
|
|
117
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
118
|
+
'Authorization' => @token)
|
|
119
|
+
|
|
120
|
+
if res.status == 200
|
|
121
|
+
JSON.parse(res.body)['data']
|
|
122
|
+
else
|
|
123
|
+
[]
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -6,22 +6,22 @@ require 'faraday'
|
|
|
6
6
|
module Spearly
|
|
7
7
|
module Auth
|
|
8
8
|
class OauthUser
|
|
9
|
-
attr_reader :
|
|
9
|
+
attr_reader :data
|
|
10
10
|
|
|
11
|
-
def initialize(
|
|
12
|
-
@
|
|
11
|
+
def initialize(data)
|
|
12
|
+
@data = data
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def method_missing(name, *_args)
|
|
16
|
-
@
|
|
16
|
+
@data[name.to_s]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def to_json(*_args)
|
|
20
|
-
@
|
|
20
|
+
@data.to_json
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def as_json
|
|
24
|
-
@
|
|
24
|
+
@data.as_json
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -13,18 +13,16 @@ module Spearly
|
|
|
13
13
|
def spearly_token
|
|
14
14
|
@spearly_token ||= begin
|
|
15
15
|
token = Spearly::Auth::Token.new(request.authorization)
|
|
16
|
-
token.info
|
|
17
16
|
|
|
18
|
-
token
|
|
17
|
+
token.info ? token : nil
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
def spearly_user
|
|
23
22
|
@spearly_user ||= begin
|
|
24
23
|
user = Spearly::Auth::User.new(request.authorization)
|
|
25
|
-
user.find
|
|
26
24
|
|
|
27
|
-
user
|
|
25
|
+
user.find ? user : nil
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
end
|
data/lib/spearly/auth/team.rb
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'addressable/uri'
|
|
4
|
-
require 'faraday'
|
|
5
|
-
|
|
6
3
|
module Spearly
|
|
7
4
|
module Auth
|
|
8
5
|
class Team
|
|
9
|
-
attr_reader :
|
|
6
|
+
attr_reader :data
|
|
10
7
|
|
|
11
|
-
def initialize(
|
|
12
|
-
@
|
|
8
|
+
def initialize(data)
|
|
9
|
+
@data = data
|
|
13
10
|
end
|
|
14
11
|
|
|
15
12
|
def method_missing(name, *_args)
|
|
16
|
-
@
|
|
13
|
+
@data[name.to_s]
|
|
17
14
|
end
|
|
18
15
|
|
|
19
16
|
def to_json(*_args)
|
|
20
|
-
@
|
|
17
|
+
@data.to_json
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
def as_json
|
|
24
|
-
@
|
|
21
|
+
@data.as_json
|
|
25
22
|
end
|
|
26
23
|
end
|
|
27
24
|
end
|
data/lib/spearly/auth/token.rb
CHANGED
|
@@ -6,37 +6,33 @@ require 'faraday'
|
|
|
6
6
|
module Spearly
|
|
7
7
|
module Auth
|
|
8
8
|
class Token
|
|
9
|
-
attr_reader :
|
|
9
|
+
attr_reader :data, :token
|
|
10
10
|
|
|
11
11
|
def initialize(token)
|
|
12
12
|
@token = token
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def method_missing(name, *_args)
|
|
16
|
-
@
|
|
16
|
+
@data[name.to_s]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def info
|
|
20
|
-
token_info_uri = "#{ENV['
|
|
20
|
+
token_info_uri = "#{ENV['SPEARLY_API_URL']}/oauth/token/info"
|
|
21
21
|
url = Addressable::URI.parse(token_info_uri).normalize.to_s
|
|
22
22
|
client = Faraday.default_connection
|
|
23
23
|
|
|
24
24
|
res = client.get(url,
|
|
25
25
|
nil,
|
|
26
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
26
27
|
'Authorization' => @token)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
when 401
|
|
30
|
-
raise Spearly::Auth::AuthorizationError
|
|
31
|
-
when 500
|
|
32
|
-
raise Spearly::Auth::ServerError
|
|
33
|
-
end
|
|
29
|
+
return unless res.status == 200
|
|
34
30
|
|
|
35
|
-
@
|
|
31
|
+
@data = JSON.parse(res.body)
|
|
36
32
|
end
|
|
37
33
|
|
|
38
34
|
def revoke(params)
|
|
39
|
-
token_revoke_uri = "#{ENV['
|
|
35
|
+
token_revoke_uri = "#{ENV['SPEARLY_API_URL']}/oauth/revoke"
|
|
40
36
|
url = Addressable::URI.parse(token_revoke_uri).normalize.to_s
|
|
41
37
|
client = Faraday.default_connection
|
|
42
38
|
|
|
@@ -51,11 +47,11 @@ module Spearly
|
|
|
51
47
|
end
|
|
52
48
|
|
|
53
49
|
def to_json(*_args)
|
|
54
|
-
@
|
|
50
|
+
@data.to_json
|
|
55
51
|
end
|
|
56
52
|
|
|
57
53
|
def as_json
|
|
58
|
-
@
|
|
54
|
+
@data.as_json
|
|
59
55
|
end
|
|
60
56
|
end
|
|
61
57
|
end
|
data/lib/spearly/auth/user.rb
CHANGED
|
@@ -6,87 +6,56 @@ require 'faraday'
|
|
|
6
6
|
module Spearly
|
|
7
7
|
module Auth
|
|
8
8
|
class User
|
|
9
|
-
attr_reader :
|
|
9
|
+
attr_reader :data
|
|
10
10
|
|
|
11
11
|
def initialize(token)
|
|
12
12
|
@token = token
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def method_missing(name, *_args)
|
|
16
|
-
@
|
|
16
|
+
@data[name.to_s]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def find
|
|
20
|
-
user_profile_uri = "#{ENV['
|
|
20
|
+
user_profile_uri = "#{ENV['SPEARLY_API_URL']}/profile"
|
|
21
21
|
url = Addressable::URI.parse(user_profile_uri).normalize.to_s
|
|
22
22
|
client = Faraday.default_connection
|
|
23
23
|
|
|
24
24
|
res = client.get(url,
|
|
25
25
|
nil,
|
|
26
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
26
27
|
'Authorization' => @token)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
when 401
|
|
30
|
-
raise Spearly::Auth::AuthorizationError
|
|
31
|
-
when 500
|
|
32
|
-
raise Spearly::Auth::ServerError
|
|
33
|
-
end
|
|
29
|
+
return unless res.status == 200
|
|
34
30
|
|
|
35
|
-
@
|
|
31
|
+
@data = JSON.parse(res.body)['data']
|
|
36
32
|
end
|
|
37
33
|
|
|
38
34
|
def teams
|
|
39
|
-
teams_uri = "#{ENV['
|
|
35
|
+
teams_uri = "#{ENV['SPEARLY_API_URL']}/teams"
|
|
40
36
|
url = Addressable::URI.parse(teams_uri).normalize.to_s
|
|
41
37
|
client = Faraday.default_connection
|
|
42
38
|
|
|
43
39
|
res = client.get(url,
|
|
44
40
|
nil,
|
|
41
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
|
45
42
|
'Authorization' => @token)
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
when 401
|
|
49
|
-
raise Spearly::Auth::AuthorizationError
|
|
50
|
-
when 500
|
|
51
|
-
raise Spearly::Auth::ServerError
|
|
52
|
-
end
|
|
44
|
+
return [] unless res.status == 200
|
|
53
45
|
|
|
54
|
-
team_hashes = JSON.parse(res.body)['
|
|
46
|
+
team_hashes = JSON.parse(res.body)['data']
|
|
55
47
|
|
|
56
48
|
team_hashes.map do |team_hash|
|
|
57
49
|
Spearly::Auth::Team.new(team_hash)
|
|
58
50
|
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
|
-
def oauth_users
|
|
62
|
-
oauth_users_uri = "#{ENV['SPEARLY_AUTH_API_URL']}/api/v1/oauth_users"
|
|
63
|
-
url = Addressable::URI.parse(oauth_users_uri).normalize.to_s
|
|
64
|
-
client = Faraday.default_connection
|
|
65
|
-
|
|
66
|
-
res = client.get(url,
|
|
67
|
-
nil,
|
|
68
|
-
'Authorization' => @token)
|
|
69
|
-
|
|
70
|
-
case res.status
|
|
71
|
-
when 401
|
|
72
|
-
raise Spearly::Auth::AuthorizationError
|
|
73
|
-
when 500
|
|
74
|
-
raise Spearly::Auth::ServerError
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
oauth_user_hashes = JSON.parse(res.body)['oauth_users']
|
|
78
|
-
|
|
79
|
-
oauth_user_hashes.map do |oauth_user_hash|
|
|
80
|
-
Spearly::Auth::OauthUser.new(oauth_user_hash)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
53
|
def to_json(*_args)
|
|
85
|
-
@
|
|
54
|
+
@data.to_json
|
|
86
55
|
end
|
|
87
56
|
|
|
88
57
|
def as_json
|
|
89
|
-
@
|
|
58
|
+
@data.as_json
|
|
90
59
|
end
|
|
91
60
|
end
|
|
92
61
|
end
|
data/lib/spearly/auth.rb
CHANGED
data/lib/spearly/version.rb
CHANGED
data/spearly.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
|
13
13
|
gem.required_ruby_version = Gem::Requirement.new('>= 2.7.2')
|
|
14
14
|
gem.metadata['homepage_uri'] = gem.homepage
|
|
15
15
|
gem.metadata['source_code_uri'] = 'https://github.com/unimal-jp/spearly-sdk-ruby'
|
|
16
|
-
gem.metadata['changelog_uri'] =
|
|
16
|
+
gem.metadata['changelog_uri'] = "https://github.com/unimal-jp/spearly-sdk-ruby/blob/v#{Spearly::VERSION}/CHANGELOG.md"
|
|
17
17
|
|
|
18
18
|
gem.files = `git ls-files`.split("\n")
|
|
19
19
|
gem.executables = 'spearly'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spearly-sdk-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Spearly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -142,7 +142,6 @@ files:
|
|
|
142
142
|
- ".rubocop.yml"
|
|
143
143
|
- CHANGELOG.md
|
|
144
144
|
- Gemfile
|
|
145
|
-
- Gemfile.lock
|
|
146
145
|
- README.md
|
|
147
146
|
- Rakefile
|
|
148
147
|
- bin/console
|
|
@@ -151,6 +150,7 @@ files:
|
|
|
151
150
|
- lib/spearly.rb
|
|
152
151
|
- lib/spearly/auth.rb
|
|
153
152
|
- lib/spearly/auth/authorizer.rb
|
|
153
|
+
- lib/spearly/auth/client.rb
|
|
154
154
|
- lib/spearly/auth/engine.rb
|
|
155
155
|
- lib/spearly/auth/oauth_user.rb
|
|
156
156
|
- lib/spearly/auth/rails/helpers.rb
|
|
@@ -166,7 +166,7 @@ licenses: []
|
|
|
166
166
|
metadata:
|
|
167
167
|
homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
|
168
168
|
source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
|
169
|
-
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/CHANGELOG.md
|
|
169
|
+
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.5.0/CHANGELOG.md
|
|
170
170
|
post_install_message:
|
|
171
171
|
rdoc_options: []
|
|
172
172
|
require_paths:
|
data/Gemfile.lock
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
spearly-sdk-ruby (0.2.3)
|
|
5
|
-
addressable (~> 2.3)
|
|
6
|
-
faraday (>= 0.17.4, < 2.0)
|
|
7
|
-
rake (~> 13.0)
|
|
8
|
-
signet (~> 0.15)
|
|
9
|
-
|
|
10
|
-
GEM
|
|
11
|
-
remote: https://rubygems.org/
|
|
12
|
-
specs:
|
|
13
|
-
addressable (2.7.0)
|
|
14
|
-
public_suffix (>= 2.0.2, < 5.0)
|
|
15
|
-
ast (2.4.2)
|
|
16
|
-
coderay (1.1.3)
|
|
17
|
-
diff-lcs (1.4.4)
|
|
18
|
-
faraday (1.4.2)
|
|
19
|
-
faraday-em_http (~> 1.0)
|
|
20
|
-
faraday-em_synchrony (~> 1.0)
|
|
21
|
-
faraday-excon (~> 1.1)
|
|
22
|
-
faraday-net_http (~> 1.0)
|
|
23
|
-
faraday-net_http_persistent (~> 1.1)
|
|
24
|
-
multipart-post (>= 1.2, < 3)
|
|
25
|
-
ruby2_keywords (>= 0.0.4)
|
|
26
|
-
faraday-em_http (1.0.0)
|
|
27
|
-
faraday-em_synchrony (1.0.0)
|
|
28
|
-
faraday-excon (1.1.0)
|
|
29
|
-
faraday-net_http (1.0.1)
|
|
30
|
-
faraday-net_http_persistent (1.1.0)
|
|
31
|
-
jwt (2.2.3)
|
|
32
|
-
method_source (1.0.0)
|
|
33
|
-
multi_json (1.15.0)
|
|
34
|
-
multipart-post (2.1.1)
|
|
35
|
-
parallel (1.20.1)
|
|
36
|
-
parser (3.0.1.1)
|
|
37
|
-
ast (~> 2.4.1)
|
|
38
|
-
pry (0.13.1)
|
|
39
|
-
coderay (~> 1.1)
|
|
40
|
-
method_source (~> 1.0)
|
|
41
|
-
public_suffix (4.0.6)
|
|
42
|
-
rainbow (3.0.0)
|
|
43
|
-
rake (13.0.3)
|
|
44
|
-
regexp_parser (2.1.1)
|
|
45
|
-
rexml (3.2.5)
|
|
46
|
-
rspec (3.10.0)
|
|
47
|
-
rspec-core (~> 3.10.0)
|
|
48
|
-
rspec-expectations (~> 3.10.0)
|
|
49
|
-
rspec-mocks (~> 3.10.0)
|
|
50
|
-
rspec-core (3.10.1)
|
|
51
|
-
rspec-support (~> 3.10.0)
|
|
52
|
-
rspec-expectations (3.10.1)
|
|
53
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
|
-
rspec-support (~> 3.10.0)
|
|
55
|
-
rspec-mocks (3.10.2)
|
|
56
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
57
|
-
rspec-support (~> 3.10.0)
|
|
58
|
-
rspec-support (3.10.2)
|
|
59
|
-
rubocop (1.15.0)
|
|
60
|
-
parallel (~> 1.10)
|
|
61
|
-
parser (>= 3.0.0.0)
|
|
62
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
63
|
-
regexp_parser (>= 1.8, < 3.0)
|
|
64
|
-
rexml
|
|
65
|
-
rubocop-ast (>= 1.5.0, < 2.0)
|
|
66
|
-
ruby-progressbar (~> 1.7)
|
|
67
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
|
68
|
-
rubocop-ast (1.5.0)
|
|
69
|
-
parser (>= 3.0.1.1)
|
|
70
|
-
rubocop-rspec (2.3.0)
|
|
71
|
-
rubocop (~> 1.0)
|
|
72
|
-
rubocop-ast (>= 1.1.0)
|
|
73
|
-
ruby-progressbar (1.11.0)
|
|
74
|
-
ruby2_keywords (0.0.4)
|
|
75
|
-
signet (0.15.0)
|
|
76
|
-
addressable (~> 2.3)
|
|
77
|
-
faraday (>= 0.17.3, < 2.0)
|
|
78
|
-
jwt (>= 1.5, < 3.0)
|
|
79
|
-
multi_json (~> 1.10)
|
|
80
|
-
unicode-display_width (2.0.0)
|
|
81
|
-
|
|
82
|
-
PLATFORMS
|
|
83
|
-
x86_64-darwin-20
|
|
84
|
-
|
|
85
|
-
DEPENDENCIES
|
|
86
|
-
pry (~> 0.13.1)
|
|
87
|
-
rspec (~> 3.0)
|
|
88
|
-
rubocop (~> 1.15)
|
|
89
|
-
rubocop-rspec (~> 2.3)
|
|
90
|
-
spearly-sdk-ruby!
|
|
91
|
-
|
|
92
|
-
BUNDLED WITH
|
|
93
|
-
2.2.15
|