oneroster 2.3.5 → 2.3.9

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: f0eb863f19f9722d3c2f53f0f66d822aa8fd198914de2dd191d1de5e90eea0a9
4
- data.tar.gz: b7915d245392cf5a4a184212093138cb4d336aa77ef106296f8936ef3ccea669
3
+ metadata.gz: 40d5e334a53e3d8a02137968318000bdaf7604a02a54291b7fd334552893ec5d
4
+ data.tar.gz: 94a198a0065ce9c615824acf25f4326fe7159b9a87b397aca640a48df6c3df81
5
5
  SHA512:
6
- metadata.gz: 5cfde8ae36c6226dc0646ba58ba5070bc06c9be1fc6439a51b2f5070284985be5e1bc89515684efe604199d8746b94278046fac593c0598a5b967260570c89e4
7
- data.tar.gz: 594b2daf5595fff0122b2797acdec30a8599c86e10aa75dcb6369a1a2022bcf5526ee377836fe8bd63c7c02c26f1fb0e6c00499dca6bd0f2fa8d7a5bbca2efb7
6
+ metadata.gz: 2528744a79bf3570e061d9c6c1f81345428be201f9d6b1dd79bfa649ea5b55f6a010f575df8e29ff944ed172be6a5a2983aaad95233ba687844aad88df45ea46
7
+ data.tar.gz: dc653c3c64ed67ed9546b9be9ba6e00b104829656fcde796d6be43a37c731de6eaaaa1ab50adf361f8bfb5fd28f30dd910eb8286d1bb5a087e2dc4ad0de6b852
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oneroster (2.3.5)
4
+ oneroster (2.3.9)
5
5
  dry-inflector
6
6
  faraday
7
7
  faraday_middleware
@@ -4,7 +4,7 @@ module OneRoster
4
4
  class Client
5
5
  attr_accessor :app_id, :app_token, :api_url, :token_url, :roster_app,
6
6
  :app_secret, :logger, :vendor_key,
7
- :username_source, :oauth_strategy, :staff_username_source
7
+ :username_source, :oauth_strategy, :staff_username_source, :token_content_type
8
8
 
9
9
  attr_reader :authenticated
10
10
 
@@ -130,9 +130,13 @@ module OneRoster
130
130
  def token
131
131
  url = token_url || "#{api_url}/token"
132
132
 
133
+ credential_params = { grant_type: 'client_credentials',
134
+ scope: 'https://purl.imsglobal.org/spec/or/v1p1/scope/roster-core.readonly' }
135
+
133
136
  if roster_app == 'infinite_campus'
134
- connection.execute(url, :post, { grant_type: 'client_credentials',
135
- scope: 'https://purl.imsglobal.org/spec/or/v1p1/scope/roster-core.readonly' })
137
+ connection.execute(url, :post, credential_params, nil, token_content_type)
138
+ elsif roster_app == 'synergy'
139
+ connection.execute(url, :post, nil, credential_params, token_content_type)
136
140
  else
137
141
  connection.execute(url, :post)
138
142
  end
@@ -10,8 +10,8 @@ module OneRoster
10
10
  @oauth_strategy = oauth_strategy
11
11
  end
12
12
 
13
- def execute(path, method = :get, params = nil, body = nil)
14
- Response.new(raw_request(path, method, params, body))
13
+ def execute(path, method = :get, params = nil, body = nil, content_type = nil)
14
+ Response.new(raw_request(path, method, params, body, content_type))
15
15
  end
16
16
 
17
17
  def set_auth_headers(token, cookie)
@@ -37,19 +37,37 @@ module OneRoster
37
37
 
38
38
  private
39
39
 
40
- def raw_request(path, method, params, body)
40
+ def raw_request(path, method, params, body, content_type = nil)
41
41
  p "request #{path} #{params}"
42
42
 
43
43
  connection.public_send(method) do |request|
44
44
  request.options.open_timeout = OPEN_TIMEOUT
45
45
  request.options.timeout = TIMEOUT
46
46
  request.url path, params
47
- request.headers['Accept-Header'] = 'application/json'
47
+ request.headers['Content-Type'] = content_type || set_content_type
48
48
  request.headers['Cookie'] = @cookie
49
- request.body = body
49
+ request.body = render_body(body, content_type)
50
50
  end
51
51
  end
52
52
 
53
+ def set_content_type
54
+ return 'application/x-www-form-urlencoded' if @client.roster_app == 'synergy'
55
+
56
+ 'application/json'
57
+ end
58
+
59
+ def render_body(body, content_type)
60
+ return URI.encode_www_form(body) if should_encode_body?(body, content_type)
61
+
62
+ body
63
+ end
64
+
65
+ def should_encode_body?(body, content_type)
66
+ return false if body.nil?
67
+
68
+ @client.roster_app == 'synergy' || content_type == 'application/x-www-form-urlencoded'
69
+ end
70
+
53
71
  def oauth_connection
54
72
  Faraday.new(@client.api_url) do |connection|
55
73
  connection.request :oauth,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneRoster
4
- VERSION = '2.3.5'
4
+ VERSION = '2.3.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneroster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Julius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday