oneroster 2.3.6 → 2.3.9

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
2
  SHA256:
3
- metadata.gz: 12d6aa35d7eac60a9e611302845be1ed8072e0dca2bedd11282e6bcc23cc1dfc
4
- data.tar.gz: af958aebb8a105f98eb17ab33a42cd065ced816917a76245591f01634a3909cd
3
+ metadata.gz: 40d5e334a53e3d8a02137968318000bdaf7604a02a54291b7fd334552893ec5d
4
+ data.tar.gz: 94a198a0065ce9c615824acf25f4326fe7159b9a87b397aca640a48df6c3df81
5
5
  SHA512:
6
- metadata.gz: 9d297d5100333fefe6749270f6e44620ad38b0dde3ae3cc399d73aa51c4c933eb9a87796262a0f6c93844dd8c71451f60964ac31a3ffff02734dc4c82287277e
7
- data.tar.gz: 45d8e0c74996efe2b1e75de72a9ba57a6282ebaaf315a5bf274067a82614b935124c0aa02b9b0b0c581f53e7b2956c330cdfecb4687442e76a6969ec2e596469
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.6)
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
 
@@ -134,9 +134,9 @@ module OneRoster
134
134
  scope: 'https://purl.imsglobal.org/spec/or/v1p1/scope/roster-core.readonly' }
135
135
 
136
136
  if roster_app == 'infinite_campus'
137
- connection.execute(url, :post, credential_params)
137
+ connection.execute(url, :post, credential_params, nil, token_content_type)
138
138
  elsif roster_app == 'synergy'
139
- connection.execute(url, :post, nil, credential_params)
139
+ connection.execute(url, :post, nil, credential_params, token_content_type)
140
140
  else
141
141
  connection.execute(url, :post)
142
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,31 +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['Content-Type'] = content_type
47
+ request.headers['Content-Type'] = content_type || set_content_type
48
48
  request.headers['Cookie'] = @cookie
49
- request.body = render_body(body)
49
+ request.body = render_body(body, content_type)
50
50
  end
51
51
  end
52
52
 
53
- def content_type
53
+ def set_content_type
54
54
  return 'application/x-www-form-urlencoded' if @client.roster_app == 'synergy'
55
55
 
56
56
  'application/json'
57
57
  end
58
58
 
59
- def render_body(body)
60
- return URI.encode_www_form(body) if !body.nil? && @client.roster_app == 'synergy'
59
+ def render_body(body, content_type)
60
+ return URI.encode_www_form(body) if should_encode_body?(body, content_type)
61
61
 
62
62
  body
63
63
  end
64
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
+
65
71
  def oauth_connection
66
72
  Faraday.new(@client.api_url) do |connection|
67
73
  connection.request :oauth,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneRoster
4
- VERSION = '2.3.6'
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.6
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-08-28 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