bearcat 1.5.28 → 1.5.30

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: be5f900048edb3be390f3c36ad38c23da1605bdc164cffc2056f0f16f959de8e
4
- data.tar.gz: cc1e4b0fa57bf2ce326f278ab0f855cdebd7f4a1d943f661aaf61a766eee5e13
3
+ metadata.gz: c8f8b63caed1ff5f931ed35d4d7612cc95b1a55ef320b2ea62d6c37cd58d7961
4
+ data.tar.gz: e4d46c06cc72391ca389cd8e988aea15daab9d849d34b43f8da836cea7baa0d0
5
5
  SHA512:
6
- metadata.gz: 7f51b3b96e155b3684aa019cfe75f30fff3e84947cbe13bac43a7277a9ed5d13ceafbb5ff7bd3fb4ed16ab07814343fb435c4e92e4ac17173ee3e9aa26fc108e
7
- data.tar.gz: b24a814fefd13793b6931621019397db41588b45604f16cfcb2c7305a79b0d3847351f64c21e4425ceb936f8fa6d7568895491c1ae54e3463c00ee56152e8871
6
+ metadata.gz: 4692fb709e0bda0e0e7090bc58173be51a7583f540b1da2d725215f0254733fd62fdc376790cbc09fdcbec4d47765cdd3a83e4ad1e67bc5ad63193acf8fa330a
7
+ data.tar.gz: 6898bcfbb4f30848164b1ea84588821f4a3736378df6e50fd20037f36e3d8e008d9ebb43e75cc67728df84f5230ca59c985246a806a03f4b5676dc0f5adab12b
@@ -3,6 +3,28 @@ module Badgrcat
3
3
  module Methods
4
4
  extend Bearcat::Client::ClientModule
5
5
 
6
+ prefix "v1" do
7
+ prefix "/orgs" do
8
+ prefix "/:organization" do
9
+ prefix "/pathways" do
10
+ get :pathways
11
+ end
12
+ end
13
+ end
14
+
15
+ prefix "/pathways" do
16
+ prefix "/:pathway" do
17
+ get :pathway
18
+
19
+ prefix "/progress" do
20
+ prefix "/recipient?recipientId=:recepientId" do
21
+ get :user_pathway_progress
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
6
28
  prefix "/v2/issuers" do
7
29
  get :issuers
8
30
  post :create_issuer
@@ -12,25 +12,45 @@ module Badgrcat
12
12
 
13
13
  # Override Footrest request for ApiArray support
14
14
  def request(method, &block)
15
- begin
16
- response = connection.send(method, &block)
15
+ response = begin
16
+ connection.send(method, &block)
17
+ rescue Footrest::HttpError::NotFound => e
18
+ raise e unless connection.headers[:authorization].nil?
19
+
20
+ # Reauthenticate and retry if authorization header is nil
21
+ authenticate!
22
+ connection.send(method, &block)
17
23
  rescue Footrest::HttpError::Unauthorized
18
24
  # Reauthenticate and retry
19
25
  authenticate!
20
- response = connection.send(method, &block)
26
+ connection.send(method, &block)
21
27
  end
22
28
 
23
29
  Badgrcat::ApiArray.process_response(response, self)
24
30
  end
25
31
 
32
+ # Override Footrest request for sending params in body as json
33
+ def request_with_params_in_body(method, path, options)
34
+ request(method) do |r|
35
+ r.path = fullpath(path)
36
+ r.body = options.to_json unless options.empty?
37
+ end
38
+ end
39
+
26
40
  def authenticate!
27
41
  connection.headers[:authorization] = nil
28
42
 
43
+ auth_url = config[:auth_url]
44
+
29
45
  tok_params = {
30
46
  scope: config[:scope],
31
47
  client_id: config[:client_id],
48
+ client_secret: config[:client_secret],
49
+ grant_type: config[:grant_type],
32
50
  }
33
51
 
52
+ tok_params.reject! { |_k, v| v.nil? }
53
+
34
54
  if @refresh_token
35
55
  tok_params.merge!({
36
56
  grant_type: "refresh_token",
@@ -43,11 +63,14 @@ module Badgrcat
43
63
  })
44
64
  end
45
65
 
46
- authresp = connection.send(:post, "o/token", tok_params)
66
+ authresp = connection.send(:post, auth_url, tok_params)
47
67
  authdata = authresp.body
48
68
 
49
69
  @refresh_token = authdata["refresh_token"].presence || @refresh_token
50
70
  connection.headers[:authorization] = "#{authdata['token_type']} #{authdata['access_token']}"
71
+
72
+ # Set content type as application/json
73
+ connection.headers['Content-Type'] = "application/json"
51
74
  end
52
75
  end
53
76
  end
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '1.5.28' unless defined?(Bearcat::VERSION)
2
+ VERSION = '1.5.30' unless defined?(Bearcat::VERSION)
3
3
  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.28
4
+ version: 1.5.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-02 00:00:00.000000000 Z
11
+ date: 2024-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake