bearcat 1.5.2 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bearcat.gemspec +2 -2
- data/lib/badgrcat/api_array.rb +25 -0
- data/lib/badgrcat/client/methods.rb +54 -0
- data/lib/badgrcat/client.rb +53 -0
- data/lib/badgrcat/version.rb +3 -0
- data/lib/bearcat/client.rb +15 -0
- data/lib/bearcat/version.rb +1 -1
- data/lib/catalogcat/client/orders.rb +4 -0
- data/lib/catalogcat/client.rb +0 -13
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8928f17ff035763ed794fff4b22a8add153060527af6c4f9f1d7df5e975fefdb
|
4
|
+
data.tar.gz: 4c038af3f5df07456b6c30a3b7a5973cb6c6190dce31fca9b870244240127bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f8bbeaf624b5a37620f3747a0bab0822d77bb31ec1a7f0d11388d51f50f6bf20189fad95b09162c95b7e6fc6f3c12b7efe70e9823d725e38349972ae4bd2940
|
7
|
+
data.tar.gz: 9cb3524bafeb83f3b6f86d9fdc855d58a47684153ea3ec4d700b4f77072a782c48874da11f8ac7f31af8e012d78bc7109f6857a0f7332eee38f952fdfb264dc3
|
data/bearcat.gemspec
CHANGED
@@ -11,8 +11,8 @@ rescue LoadError
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Gem::Specification.new do |gem|
|
14
|
-
gem.authors = ["
|
15
|
-
gem.email = ["
|
14
|
+
gem.authors = ["Instructure CustomDev"]
|
15
|
+
gem.email = ["pseng@instructure.com"]
|
16
16
|
gem.description = %q{Ruby interface for interacting with the canvas API}
|
17
17
|
gem.summary = %q{Canvas API}
|
18
18
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bearcat/api_array'
|
2
|
+
|
3
|
+
module Badgrcat
|
4
|
+
class ApiArray < Bearcat::ApiArray
|
5
|
+
def [](key)
|
6
|
+
if key.is_a?(Numeric)
|
7
|
+
super
|
8
|
+
else
|
9
|
+
@raw_response.body[key]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def status
|
14
|
+
self["status"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.array_key(response)
|
18
|
+
if response.body.is_a?(Hash) && response.body.key?("result")
|
19
|
+
"result"
|
20
|
+
else
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Badgrcat
|
2
|
+
class Client < Footrest::Client
|
3
|
+
module Methods
|
4
|
+
extend Bearcat::Client::ClientModule
|
5
|
+
|
6
|
+
prefix "/v2/issuers" do
|
7
|
+
get :issuers
|
8
|
+
post :create_issuer
|
9
|
+
|
10
|
+
prefix "/:issuer" do
|
11
|
+
get :issuer
|
12
|
+
put :update_issuer
|
13
|
+
delete :delete_issuer
|
14
|
+
|
15
|
+
prefix "/assertions" do
|
16
|
+
get :issuer_assertions
|
17
|
+
post :create_issuer_assertion
|
18
|
+
end
|
19
|
+
|
20
|
+
prefix "/badgeclasses" do
|
21
|
+
get :issuer_badgeclasses
|
22
|
+
post :create_issuer_badgeclass
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
prefix "/v2/badgeclasses" do
|
28
|
+
get :badgeclasses
|
29
|
+
post :create_badgeclass
|
30
|
+
|
31
|
+
prefix "/:badgeclass" do
|
32
|
+
get :badgeclass
|
33
|
+
put :update_badgeclass
|
34
|
+
delete :delete_badgeclass
|
35
|
+
|
36
|
+
prefix "/assertions" do
|
37
|
+
get :badgeclass_assertions
|
38
|
+
post :create_badgeclass_assertion
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
prefix "/v2/assertions" do
|
44
|
+
post :revoke_assertions, "/revoke"
|
45
|
+
|
46
|
+
prefix "/v2/assertions/:assertion" do
|
47
|
+
get :assertion
|
48
|
+
put :update_assertion
|
49
|
+
delete :delete_assertion
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'footrest/client'
|
2
|
+
|
3
|
+
module Badgrcat
|
4
|
+
class Client < Footrest::Client
|
5
|
+
require 'badgrcat/api_array' # monkey patch
|
6
|
+
|
7
|
+
Dir[File.join(__dir__, 'client', '*.rb')].each do |mod|
|
8
|
+
mname = File.basename(mod, '.*').camelize
|
9
|
+
require mod
|
10
|
+
include "Badgrcat::Client::#{mname}".constantize
|
11
|
+
end
|
12
|
+
|
13
|
+
# Override Footrest request for ApiArray support
|
14
|
+
def request(method, &block)
|
15
|
+
begin
|
16
|
+
response = connection.send(method, &block)
|
17
|
+
rescue Footrest::HttpError::Unauthorized
|
18
|
+
# Reauthenticate and retry
|
19
|
+
authenticate!
|
20
|
+
response = connection.send(method, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
Badgrcat::ApiArray.process_response(response, self)
|
24
|
+
end
|
25
|
+
|
26
|
+
def authenticate!
|
27
|
+
connection.headers[:authorization] = nil
|
28
|
+
|
29
|
+
tok_params = {
|
30
|
+
scope: config[:scope],
|
31
|
+
client_id: config[:client_id],
|
32
|
+
}
|
33
|
+
|
34
|
+
if @refresh_token
|
35
|
+
tok_params.merge!({
|
36
|
+
grant_type: "refresh_token",
|
37
|
+
refresh_token: @refresh_token,
|
38
|
+
})
|
39
|
+
else
|
40
|
+
tok_params.merge!({
|
41
|
+
username: config[:username],
|
42
|
+
password: config[:password],
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
authresp = connection.send(:post, "o/token", tok_params)
|
47
|
+
authdata = authresp.body
|
48
|
+
|
49
|
+
@refresh_token = authdata["refresh_token"].presence || @refresh_token
|
50
|
+
connection.headers[:authorization] = "#{authdata['token_type']} #{authdata['access_token']}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/bearcat/client.rb
CHANGED
@@ -32,6 +32,12 @@ module Bearcat
|
|
32
32
|
ApiArray.process_response(response, self)
|
33
33
|
end
|
34
34
|
|
35
|
+
def set_connection(config)
|
36
|
+
super
|
37
|
+
connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors)
|
38
|
+
connection.builder.delete(Footrest::RaiseFootrestErrors)
|
39
|
+
end
|
40
|
+
|
35
41
|
protected
|
36
42
|
|
37
43
|
def rate_limited_request
|
@@ -101,4 +107,13 @@ module Bearcat
|
|
101
107
|
Digest::SHA1.hexdigest(config[:token])
|
102
108
|
end
|
103
109
|
end
|
110
|
+
|
111
|
+
# Overridden response error middleware that, if an error code doesn't map to an exception, raises a more generic exception
|
112
|
+
class ExtendedRaiseFootrestErrors < Footrest::RaiseFootrestErrors
|
113
|
+
def on_complete(response)
|
114
|
+
super
|
115
|
+
key = response[:status].to_i
|
116
|
+
raise ERROR_MAP[key.floor(-2)], response if key >= 400
|
117
|
+
end
|
118
|
+
end
|
104
119
|
end
|
data/lib/bearcat/version.rb
CHANGED
data/lib/catalogcat/client.rb
CHANGED
@@ -11,29 +11,16 @@ module Catalogcat
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Override Footrest connection to use Token authorization
|
14
|
-
# rubocop:disable Naming/AccessorMethodName
|
15
14
|
def set_connection(config)
|
16
15
|
super
|
17
|
-
connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors)
|
18
|
-
connection.builder.delete(Footrest::RaiseFootrestErrors)
|
19
16
|
connection.headers[:authorization].sub! 'Bearer', 'Token'
|
20
17
|
end
|
21
|
-
# rubocop:enable Naming/AccessorMethodName
|
22
18
|
|
23
19
|
# Override Footrest request for ApiArray support
|
24
20
|
def request(method, &block)
|
25
21
|
response = connection.send(method, &block)
|
26
|
-
raise Footrest::HttpError::ErrorBase, response if response.status >= 400
|
27
22
|
|
28
23
|
Catalogcat::ApiArray.process_response(response, self)
|
29
24
|
end
|
30
25
|
end
|
31
|
-
|
32
|
-
class ExtendedRaiseFootrestErrors < Footrest::RaiseFootrestErrors
|
33
|
-
def on_complete(response)
|
34
|
-
super
|
35
|
-
key = response[:status].to_i
|
36
|
-
raise ERROR_MAP[key.floor(-2)], response if key >= 400
|
37
|
-
end
|
38
|
-
end
|
39
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bearcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Instructure CustomDev
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -124,13 +124,17 @@ dependencies:
|
|
124
124
|
version: 0.2.2
|
125
125
|
description: Ruby interface for interacting with the canvas API
|
126
126
|
email:
|
127
|
-
-
|
127
|
+
- pseng@instructure.com
|
128
128
|
executables: []
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- Rakefile
|
133
133
|
- bearcat.gemspec
|
134
|
+
- lib/badgrcat/api_array.rb
|
135
|
+
- lib/badgrcat/client.rb
|
136
|
+
- lib/badgrcat/client/methods.rb
|
137
|
+
- lib/badgrcat/version.rb
|
134
138
|
- lib/bearcat.rb
|
135
139
|
- lib/bearcat/api_array.rb
|
136
140
|
- lib/bearcat/client.rb
|
@@ -385,10 +389,10 @@ files:
|
|
385
389
|
- spec/fixtures/user_page_views.json
|
386
390
|
- spec/fixtures/user_profile.json
|
387
391
|
- spec/helper.rb
|
388
|
-
homepage:
|
392
|
+
homepage:
|
389
393
|
licenses: []
|
390
394
|
metadata: {}
|
391
|
-
post_install_message:
|
395
|
+
post_install_message:
|
392
396
|
rdoc_options: []
|
393
397
|
require_paths:
|
394
398
|
- lib
|
@@ -404,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
404
408
|
version: '0'
|
405
409
|
requirements: []
|
406
410
|
rubygems_version: 3.1.6
|
407
|
-
signing_key:
|
411
|
+
signing_key:
|
408
412
|
specification_version: 4
|
409
413
|
summary: Canvas API
|
410
414
|
test_files:
|