bright 2.0 → 2.1

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: d2478a62cb11741cb1406e3f38bd2e387beb5f042c2c8e170d455e7d531d779b
4
- data.tar.gz: 507582c1502e2894e470236fedeba7efcd906d9a29d15a5c4d6218b1468666ca
3
+ metadata.gz: cecf72fc184d3cdf9aabf35502de293d80fd66ebf89d1f7e54a26ed9b8eb3bc3
4
+ data.tar.gz: 195907040f1522459af343ca88d19bec678678112ac312ad6b40ce0710a1033a
5
5
  SHA512:
6
- metadata.gz: 1b07d3fee51e60da6f25f84cb2ba4a275d7597da0fc481866e5c838a7bbdeb63b4c80c22de44f145f91becc22e53ea5ee50d888aa931517c142fb199f277d32c
7
- data.tar.gz: 934e5d22043fc74251b2321532897cbff7d06e63b722321e99fb00ca2711d23abfc853234642bb6c72db2dddcafad58d324a5e0251c9f36a42e2755df18eb765
6
+ metadata.gz: cef10a48aaf47c282d87c2b18d23ad39b0747667e21c2841f698a4ef22ba35f7c83dd2b407cc16a27333b0e16923648b8f8ad5d623633898e5fbb40714e441e5
7
+ data.tar.gz: 99da5c90309415481bf7eabd7b08a12e5836b127aee8e0ed6835956bffa1833ff000bb82b596fa8921c288a1105d2fd56b44fe0e4911d55e6ddabf116b88ad05
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bright
2
2
 
3
- TODO: Write a gem description
3
+ The `bright` gem provides a framework and tools for interacting with various Student Information Systems (SIS). It supports multiple SIS platforms, including Infinite Campus, Skyward, TSIS, Aeries, and PowerSchool, offering functionalities to retrieve and manage student and school data.
4
4
 
5
5
  ## Installation
6
6
 
@@ -40,7 +40,7 @@ module Bright
40
40
  {roles: "student"}.merge(params)
41
41
  end
42
42
  st_hsh = request(:get, "users/#{api_id}", params)
43
- Student.new(convert_to_user_data(st_hsh["user"])) if st_hsh and st_hsh["user"]
43
+ Student.new(convert_to_user_data(st_hsh["user"])) if st_hsh && st_hsh["user"]
44
44
  end
45
45
 
46
46
  def get_student(params = {}, options = {})
@@ -56,7 +56,7 @@ module Bright
56
56
  params[:limit] = params[:limit] || options[:limit] || 100
57
57
  students_response_hash = request(:get, "users", map_search_params(params))
58
58
  total_results = students_response_hash[:response_headers]["x-total-count"].to_i
59
- if students_response_hash and students_response_hash["users"]
59
+ if students_response_hash && students_response_hash["users"]
60
60
  students_hash = [students_response_hash["users"]].flatten
61
61
 
62
62
  students = students_hash.compact.collect { |st_hsh|
@@ -92,7 +92,7 @@ module Bright
92
92
 
93
93
  def get_school_by_api_id(api_id, params = {})
94
94
  sc_hsh = request(:get, "schools/#{api_id}", params)
95
- School.new(convert_to_school_data(sc_hsh["org"])) if sc_hsh and sc_hsh["org"]
95
+ School.new(convert_to_school_data(sc_hsh["org"])) if sc_hsh && sc_hsh["org"]
96
96
  end
97
97
 
98
98
  def get_school(params = {}, options = {})
@@ -103,7 +103,7 @@ module Bright
103
103
  params[:limit] = params[:limit] || options[:limit] || 100
104
104
  schools_response_hash = request(:get, "schools", map_school_search_params(params))
105
105
  total_results = schools_response_hash[:response_headers]["x-total-count"].to_i
106
- if schools_response_hash and schools_response_hash["orgs"]
106
+ if schools_response_hash && schools_response_hash["orgs"]
107
107
  schools_hash = [schools_response_hash["orgs"]].flatten
108
108
 
109
109
  schools = schools_hash.compact.collect { |sc_hsh|
@@ -131,7 +131,7 @@ module Bright
131
131
 
132
132
  def get_contact_by_api_id(api_id, params = {})
133
133
  contact_hsh = request(:get, "users/#{api_id}", params)
134
- Contact.new(convert_to_user_data(contact_hsh["user"], bright_type: "Contact")) if contact_hsh and contact_hsh["user"]
134
+ Contact.new(convert_to_user_data(contact_hsh["user"], bright_type: "Contact")) if contact_hsh && contact_hsh["user"]
135
135
  end
136
136
 
137
137
  def request(method, path, params = {})
@@ -154,8 +154,8 @@ module Bright
154
154
  response_hash = JSON.parse(response.body)
155
155
  response_hash[:response_headers] = response.headers
156
156
  else
157
- puts "#{response.inspect}"
158
- puts "#{response.body}"
157
+ puts response.inspect
158
+ puts response.body
159
159
  end
160
160
  response_hash
161
161
  end
@@ -163,15 +163,8 @@ module Bright
163
163
  protected
164
164
 
165
165
  def headers_for_auth(uri)
166
- case api_version
167
- when Gem::Version.new("1.1")
168
- site = URI.parse(connection_options[:uri])
169
- site = "#{site.scheme}://#{site.host}"
170
- consumer = OAuth::Consumer.new(connection_options[:client_id], connection_options[:client_secret], {site: site, scheme: :header})
171
- options = {timestamp: Time.now.to_i, nonce: SecureRandom.uuid}
172
- {"Authorization" => consumer.create_signed_request(:get, uri, nil, options)["Authorization"]}
173
- when Gem::Version.new("1.2")
174
- if connection_options[:access_token].nil? or connection_options[:access_token_expires] < Time.now
166
+ if api_version >= Gem::Version.new("1.2") || connection_options[:token_uri].present?
167
+ if connection_options[:access_token].nil? || (connection_options[:access_token_expires] < Time.now)
175
168
  retrieve_access_token
176
169
  end
177
170
  {
@@ -179,6 +172,12 @@ module Bright
179
172
  "Accept" => "application/json",
180
173
  "Content-Type" => "application/json"
181
174
  }
175
+ else
176
+ site = URI.parse(connection_options[:uri])
177
+ site = "#{site.scheme}://#{site.host}"
178
+ consumer = OAuth::Consumer.new(connection_options[:client_id], connection_options[:client_secret], {site: site, scheme: :header})
179
+ options = {timestamp: Time.now.to_i, nonce: SecureRandom.uuid}
180
+ {"Authorization" => consumer.create_signed_request(:get, uri, nil, options)["Authorization"]}
182
181
  end
183
182
  end
184
183
 
@@ -314,7 +313,7 @@ module Bright
314
313
  user_data_hsh.merge!(demographics_hash) unless demographics_hash.blank?
315
314
 
316
315
  # if you're a student, build the contacts too
317
- if bright_type == "Student" and !user_params["agents"].blank?
316
+ if (bright_type == "Student") && !user_params["agents"].blank?
318
317
  user_data_hsh[:contacts] = user_params["agents"].collect do |agent_hsh|
319
318
  get_contact_by_api_id(agent_hsh["sourcedId"])
320
319
  rescue Bright::ResponseError => e
@@ -1,3 +1,3 @@
1
1
  module Bright
2
- VERSION = "2.0"
2
+ VERSION = "2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bright
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arux Software
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-27 00:00:00.000000000 Z
10
+ date: 2025-01-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: httpi
@@ -141,7 +140,6 @@ homepage: https://github.com/Arux-Software/Bright
141
140
  licenses:
142
141
  - MIT
143
142
  metadata: {}
144
- post_install_message:
145
143
  rdoc_options: []
146
144
  require_paths:
147
145
  - lib
@@ -156,8 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
154
  - !ruby/object:Gem::Version
157
155
  version: '0'
158
156
  requirements: []
159
- rubygems_version: 3.5.16
160
- signing_key:
157
+ rubygems_version: 3.6.3
161
158
  specification_version: 4
162
159
  summary: Framework and tools for dealing with Student Information Systems
163
160
  test_files: []