bright 1.3 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +0 -1
- data/bright.gemspec +12 -14
- data/lib/bright/address.rb +5 -5
- data/lib/bright/connection.rb +7 -9
- data/lib/bright/contact.rb +7 -9
- data/lib/bright/cursor_response_collection.rb +8 -10
- data/lib/bright/email_address.rb +1 -2
- data/lib/bright/enrollment.rb +2 -2
- data/lib/bright/errors.rb +0 -1
- data/lib/bright/helpers/blank_helper.rb +0 -2
- data/lib/bright/model.rb +13 -13
- data/lib/bright/phone_number.rb +1 -2
- data/lib/bright/response_collection.rb +8 -8
- data/lib/bright/school.rb +1 -4
- data/lib/bright/sis_apis/aeries.rb +18 -19
- data/lib/bright/sis_apis/base.rb +3 -5
- data/lib/bright/sis_apis/bright_sis.rb +82 -84
- data/lib/bright/sis_apis/focus.rb +78 -84
- data/lib/bright/sis_apis/one_roster/infinite_campus.rb +15 -0
- data/lib/bright/sis_apis/one_roster/skyward.rb +6 -0
- data/lib/bright/sis_apis/{infinite_campus.rb → one_roster.rb} +91 -100
- data/lib/bright/sis_apis/power_school.rb +105 -107
- data/lib/bright/sis_apis/synergy.rb +6 -8
- data/lib/bright/sis_apis/tsis.rb +54 -54
- data/lib/bright/student.rb +15 -19
- data/lib/bright/version.rb +1 -1
- data/lib/bright.rb +14 -12
- metadata +6 -5
- data/lib/bright/sis_apis/skyward.rb +0 -277
data/lib/bright/sis_apis/tsis.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "base64"
|
2
|
+
require "json"
|
3
3
|
|
4
4
|
module Bright
|
5
5
|
module SisApi
|
6
6
|
class TSIS < Base
|
7
|
-
DATE_FORMAT =
|
7
|
+
DATE_FORMAT = "%m/%d/%Y"
|
8
8
|
|
9
9
|
@@description = "Connects to the TIES API for accessing TIES TSIS student information"
|
10
10
|
@@doc_url = "#unkown"
|
@@ -22,54 +22,54 @@ module Bright
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def get_student_by_api_id(api_id, params = {})
|
25
|
-
|
25
|
+
get_student(params.merge({sis_student_id: api_id}))
|
26
26
|
end
|
27
27
|
|
28
28
|
def get_student(params = {}, options = {})
|
29
|
-
params =
|
29
|
+
params = apply_options(params, options.merge({per_page: 1}))
|
30
30
|
|
31
31
|
# Students only gets you students that are enrolled in a school for a given school year.
|
32
|
-
students_response_hash =
|
32
|
+
students_response_hash = request(:get, "Students/", map_search_params(params))
|
33
33
|
found_student = nil
|
34
34
|
if students_response_hash["Return"] and students_response_hash["Return"].first
|
35
|
-
found_student =
|
35
|
+
found_student = Student.new(convert_to_student_data(students_response_hash["Return"].first))
|
36
36
|
end
|
37
37
|
if found_student.nil?
|
38
38
|
# Students/Family can get you students that are not enrolled in a school for a given school year.
|
39
|
-
family_response_hash =
|
39
|
+
family_response_hash = request(:get, "Students/Family/", map_search_params(params))
|
40
40
|
if family_response_hash["Return"] and family_response_hash["Return"].first
|
41
|
-
found_student =
|
41
|
+
found_student = Student.new(convert_to_student_data(family_response_hash["Return"].first))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
found_student
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_students(params = {}, options = {})
|
48
|
-
params =
|
48
|
+
params = apply_options(params, options)
|
49
49
|
|
50
|
-
if params[:schoolyear]
|
50
|
+
response_hash = if params[:schoolyear]
|
51
51
|
# Students only gets you students that are enrolled in a school for a given school year.
|
52
|
-
|
52
|
+
request(:get, apply_page_to_url("Students/", options[:page]), map_search_params(params))
|
53
53
|
else
|
54
54
|
# Students/Family can get you students that are not enrolled in a school for a given school year.
|
55
|
-
|
55
|
+
request(:get, apply_page_to_url("Students/Family/", options[:page]), map_search_params(params))
|
56
56
|
end
|
57
57
|
|
58
|
-
students = response_hash["Return"].collect{|hsh| Student.new(convert_to_student_data(hsh))}
|
58
|
+
students = response_hash["Return"].collect { |hsh| Student.new(convert_to_student_data(hsh)) }
|
59
59
|
total_results = response_hash["TotalCount"].to_i
|
60
60
|
|
61
61
|
if options[:wrap_in_collection] != false
|
62
62
|
api = self
|
63
63
|
load_more_call = proc { |page|
|
64
64
|
# pages start at one, so add a page here
|
65
|
-
api.get_students(params, {:
|
65
|
+
api.get_students(params, {wrap_in_collection: false, page: (page + 1)})
|
66
66
|
}
|
67
67
|
|
68
68
|
ResponseCollection.new({
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
69
|
+
seed_page: students,
|
70
|
+
total: total_results,
|
71
|
+
per_page: options[:per_page],
|
72
|
+
load_more_call: load_more_call
|
73
73
|
})
|
74
74
|
else
|
75
75
|
students
|
@@ -85,26 +85,26 @@ module Bright
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def get_schools(params = {}, options = {})
|
88
|
-
params =
|
88
|
+
params = apply_options(params, options)
|
89
89
|
|
90
90
|
# schools api end point takes page # in the url itself for some reason
|
91
|
-
schools_response_hash =
|
91
|
+
schools_response_hash = request(:get, apply_page_to_url("Schools/", options[:page]), params)
|
92
92
|
|
93
|
-
schools = schools_response_hash["Return"].collect{|hsh| School.new(convert_to_school_data(hsh))}
|
93
|
+
schools = schools_response_hash["Return"].collect { |hsh| School.new(convert_to_school_data(hsh)) }
|
94
94
|
total_results = schools_response_hash["TotalCount"].to_i
|
95
95
|
|
96
96
|
if options[:wrap_in_collection] != false
|
97
97
|
api = self
|
98
98
|
load_more_call = proc { |page|
|
99
99
|
# pages start at one, so add a page here
|
100
|
-
api.get_schools(params, {:
|
100
|
+
api.get_schools(params, {wrap_in_collection: false, page: (page + 1)})
|
101
101
|
}
|
102
102
|
|
103
103
|
ResponseCollection.new({
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
104
|
+
seed_page: schools,
|
105
|
+
total: total_results,
|
106
|
+
per_page: options[:per_page],
|
107
|
+
load_more_call: load_more_call
|
108
108
|
})
|
109
109
|
else
|
110
110
|
schools
|
@@ -112,9 +112,9 @@ module Bright
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def request(method, path, params = {})
|
115
|
-
uri
|
115
|
+
uri = "#{connection_options[:uri]}/#{path}"
|
116
116
|
body = nil
|
117
|
-
query = URI.encode(params.map{|k,v| "#{k}=#{v}"}.join("&"))
|
117
|
+
query = URI.encode(params.map { |k, v| "#{k}=#{v}" }.join("&"))
|
118
118
|
if method == :get
|
119
119
|
uri += "?#{query}"
|
120
120
|
else
|
@@ -123,7 +123,7 @@ module Bright
|
|
123
123
|
|
124
124
|
response = connection_retry_wrapper {
|
125
125
|
connection = Bright::Connection.new(uri)
|
126
|
-
headers =
|
126
|
+
headers = headers_for_auth
|
127
127
|
connection.request(method, body, headers)
|
128
128
|
}
|
129
129
|
|
@@ -142,15 +142,15 @@ module Bright
|
|
142
142
|
params["studentname"] ||= "#{params.delete(:last_name)}, #{params.delete(:first_name)} #{params.delete(:middle_name)}".strip
|
143
143
|
params["studentids"] = params.delete(:sis_student_id)
|
144
144
|
|
145
|
-
params =
|
145
|
+
params = params.collect do |k, v|
|
146
146
|
if v.is_a?(Array)
|
147
147
|
v = v.join(",")
|
148
148
|
end
|
149
149
|
k = k.to_s.gsub(/[^A-Za-z]/, "").downcase
|
150
|
-
[k,v]
|
151
|
-
end
|
150
|
+
[k, v]
|
151
|
+
end.to_h
|
152
152
|
|
153
|
-
params.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
153
|
+
params.reject { |k, v| v.respond_to?(:empty?) ? v.empty? : v.nil? }
|
154
154
|
end
|
155
155
|
|
156
156
|
def convert_to_student_data(attrs)
|
@@ -160,23 +160,23 @@ module Bright
|
|
160
160
|
if split_name[1]
|
161
161
|
split_first_name = split_name[1].to_s.strip.split(" ")
|
162
162
|
if split_first_name.size > 1
|
163
|
-
catt[:first_name]
|
164
|
-
catt[:middle_name]
|
163
|
+
catt[:first_name] = split_first_name[0...-1].join(" ").strip
|
164
|
+
catt[:middle_name] = split_first_name[-1].strip
|
165
165
|
else
|
166
166
|
catt[:first_name] = split_first_name.first.strip
|
167
167
|
end
|
168
168
|
end
|
169
|
-
catt[:last_name]
|
169
|
+
catt[:last_name] = split_name[0].to_s.strip
|
170
170
|
else
|
171
|
-
catt[:first_name]
|
172
|
-
catt[:middle_name]
|
173
|
-
catt[:last_name]
|
171
|
+
catt[:first_name] = attrs["FirstName"].strip
|
172
|
+
catt[:middle_name] = attrs["MiddleName"].strip
|
173
|
+
catt[:last_name] = (attrs["LastName"] || attrs["SurName"]).strip
|
174
174
|
end
|
175
175
|
|
176
176
|
catt[:state_student_id] = (attrs["StateId"] || attrs["StudentStateId"]).to_s
|
177
|
-
catt[:sis_student_id]
|
178
|
-
catt[:api_id]
|
179
|
-
catt[:homeless_code]
|
177
|
+
catt[:sis_student_id] = attrs["StudentId"].to_s
|
178
|
+
catt[:api_id] = attrs["StudentId"].to_s
|
179
|
+
catt[:homeless_code] = attrs["HomelessCode"]
|
180
180
|
|
181
181
|
# "Economic\":{\"Description\":\"\",\"EconomicIndicatorId\":\"0\"}
|
182
182
|
|
@@ -189,9 +189,9 @@ module Bright
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
-
catt[:addresses] = [
|
192
|
+
catt[:addresses] = [convert_to_address_data(attrs["Address"])] if attrs["Address"]
|
193
193
|
|
194
|
-
catt.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
194
|
+
catt.reject { |k, v| v.respond_to?(:empty?) ? v.empty? : v.nil? }
|
195
195
|
end
|
196
196
|
|
197
197
|
def convert_to_address_data(attrs)
|
@@ -207,7 +207,7 @@ module Bright
|
|
207
207
|
cattrs[:postal_code] = attrs["Zip"]
|
208
208
|
cattrs[:type] = attrs["Type"].to_s.downcase
|
209
209
|
|
210
|
-
cattrs.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
210
|
+
cattrs.reject { |k, v| v.respond_to?(:empty?) ? v.empty? : v.nil? }
|
211
211
|
end
|
212
212
|
|
213
213
|
def convert_to_school_data(attrs)
|
@@ -217,7 +217,7 @@ module Bright
|
|
217
217
|
cattrs[:api_id] = cattrs[:number] = attrs["SchoolId"]
|
218
218
|
cattrs[:address] = convert_to_address_data(attrs)
|
219
219
|
|
220
|
-
cattrs.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
220
|
+
cattrs.reject { |k, v| v.respond_to?(:empty?) ? v.empty? : v.nil? }
|
221
221
|
end
|
222
222
|
|
223
223
|
def apply_options(params, options)
|
@@ -228,21 +228,21 @@ module Bright
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def apply_page_to_url(url, page)
|
231
|
-
"#{url}#{url[-1] == "/" ? "" : "/"}#{page}"
|
231
|
+
"#{url}#{(url[-1] == "/") ? "" : "/"}#{page}"
|
232
232
|
end
|
233
233
|
|
234
234
|
def headers_for_auth(uri)
|
235
235
|
t = Time.now.utc.httpdate
|
236
236
|
string_to_sign = "GET\n#{t}\n#{uri}"
|
237
237
|
|
238
|
-
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new(
|
239
|
-
authorization = "TIES" + " " +
|
238
|
+
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha1"), connection_options[:secret], string_to_sign)).strip
|
239
|
+
authorization = "TIES" + " " + connection_options[:key] + ":" + signature
|
240
240
|
|
241
241
|
{
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
"Authorization" => authorization,
|
243
|
+
"DistrictNumber" => connection_options[:district_id],
|
244
|
+
"ties-date" => t,
|
245
|
+
"Content-Type" => "application/json"
|
246
246
|
}
|
247
247
|
end
|
248
248
|
end
|
data/lib/bright/student.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "securerandom"
|
2
2
|
|
3
3
|
module Bright
|
4
4
|
class Student < Model
|
5
5
|
@attribute_names = [:client_id, :api_id, :first_name, :middle_name, :last_name, :nick_name,
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor
|
6
|
+
:birth_date, :grade, :grade_school_year, :projected_graduation_year, :sex,
|
7
|
+
:hispanic_ethnicity, :race, :image, :primary_language, :secondary_language,
|
8
|
+
:homeless_code, :frl_status, :sis_student_id,
|
9
|
+
:state_student_id, :last_modified]
|
10
|
+
attr_accessor(*@attribute_names)
|
11
11
|
|
12
12
|
def self.attribute_names
|
13
13
|
@attribute_names
|
@@ -19,27 +19,26 @@ module Bright
|
|
19
19
|
def initialize(*args)
|
20
20
|
super
|
21
21
|
self.client_id ||= SecureRandom.uuid
|
22
|
-
self
|
23
22
|
end
|
24
23
|
|
25
24
|
def name
|
26
|
-
"#{
|
25
|
+
"#{first_name} #{middle_name} #{last_name}".gsub(/\s+/, " ").strip
|
27
26
|
end
|
28
27
|
|
29
28
|
def <=>(other)
|
30
|
-
(
|
31
|
-
|
32
|
-
|
29
|
+
(sis_student_id && sis_student_id == other.sis_student_id) ||
|
30
|
+
(state_student_id && state_student_id == other.state_student_id) ||
|
31
|
+
(first_name == other.first_name && middle_name == other.middle_name && last_name == other.last_name && birth_date == other.birth_date)
|
33
32
|
end
|
34
33
|
|
35
|
-
|
34
|
+
alias_method :id, :client_id
|
36
35
|
|
37
36
|
def addresses=(array)
|
38
37
|
if array.size <= 0 or array.first.is_a?(Address)
|
39
38
|
@addresses = array
|
40
|
-
@addresses.each{|a| a.student = self}
|
39
|
+
@addresses.each { |a| a.student = self }
|
41
40
|
elsif array.first.is_a?(Hash)
|
42
|
-
@addresses = array.collect{|a| Address.new(a)}
|
41
|
+
@addresses = array.collect { |a| Address.new(a) }
|
43
42
|
end
|
44
43
|
@addresses ||= []
|
45
44
|
end
|
@@ -52,7 +51,7 @@ module Bright
|
|
52
51
|
if array.size <= 0 or array.first.is_a?(PhoneNumber)
|
53
52
|
@phone_numbers = array
|
54
53
|
elsif array.first.is_a?(Hash)
|
55
|
-
@phone_numbers = array.collect{|a| PhoneNumber.new(a)}
|
54
|
+
@phone_numbers = array.collect { |a| PhoneNumber.new(a) }
|
56
55
|
end
|
57
56
|
@phone_numbers ||= []
|
58
57
|
end
|
@@ -67,7 +66,6 @@ module Bright
|
|
67
66
|
elsif email.is_a?(Hash)
|
68
67
|
@email_address = EmailAddress.new(email)
|
69
68
|
end
|
70
|
-
@email_address
|
71
69
|
end
|
72
70
|
|
73
71
|
def school=(school_val)
|
@@ -76,14 +74,13 @@ module Bright
|
|
76
74
|
elsif school_val.is_a?(Hash)
|
77
75
|
@school = School.new(school_val)
|
78
76
|
end
|
79
|
-
@school
|
80
77
|
end
|
81
78
|
|
82
79
|
def contacts=(array)
|
83
80
|
if array.size <= 0 or array.first.is_a?(Contact)
|
84
81
|
@contacts = array
|
85
82
|
elsif array.first.is_a?(Hash)
|
86
|
-
@contacts = array.collect{|a| Contact.new(a)}
|
83
|
+
@contacts = array.collect { |a| Contact.new(a) }
|
87
84
|
end
|
88
85
|
@contacts ||= []
|
89
86
|
end
|
@@ -91,6 +88,5 @@ module Bright
|
|
91
88
|
def contacts
|
92
89
|
@contacts ||= []
|
93
90
|
end
|
94
|
-
|
95
91
|
end
|
96
92
|
end
|
data/lib/bright/version.rb
CHANGED
data/lib/bright.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require_relative "bright/version"
|
2
2
|
require_relative "bright/errors"
|
3
3
|
|
4
|
-
require_relative "bright/helpers/blank_helper
|
5
|
-
require_relative "bright/helpers/boolean_parser_helper
|
4
|
+
require_relative "bright/helpers/blank_helper"
|
5
|
+
require_relative "bright/helpers/boolean_parser_helper"
|
6
6
|
|
7
7
|
require_relative "bright/model"
|
8
8
|
require_relative "bright/student"
|
@@ -13,20 +13,22 @@ require_relative "bright/enrollment"
|
|
13
13
|
require_relative "bright/school"
|
14
14
|
require_relative "bright/contact"
|
15
15
|
|
16
|
-
|
17
16
|
require_relative "bright/connection"
|
18
17
|
require_relative "bright/response_collection"
|
19
18
|
require_relative "bright/cursor_response_collection"
|
20
19
|
|
21
|
-
require_relative "bright/sis_apis/base
|
22
|
-
require_relative "bright/sis_apis/tsis
|
23
|
-
require_relative "bright/sis_apis/power_school
|
24
|
-
require_relative "bright/sis_apis/aeries
|
25
|
-
|
26
|
-
require_relative "bright/sis_apis/
|
27
|
-
require_relative "bright/sis_apis/
|
28
|
-
require_relative "bright/sis_apis/
|
29
|
-
|
20
|
+
require_relative "bright/sis_apis/base"
|
21
|
+
require_relative "bright/sis_apis/tsis"
|
22
|
+
require_relative "bright/sis_apis/power_school"
|
23
|
+
require_relative "bright/sis_apis/aeries"
|
24
|
+
|
25
|
+
require_relative "bright/sis_apis/bright_sis"
|
26
|
+
require_relative "bright/sis_apis/synergy"
|
27
|
+
require_relative "bright/sis_apis/focus"
|
28
|
+
|
29
|
+
require_relative "bright/sis_apis/one_roster"
|
30
|
+
require_relative "bright/sis_apis/one_roster/infinite_campus"
|
31
|
+
require_relative "bright/sis_apis/one_roster/skyward"
|
30
32
|
|
31
33
|
module Bright
|
32
34
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bright
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arux Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -129,9 +129,10 @@ files:
|
|
129
129
|
- lib/bright/sis_apis/base.rb
|
130
130
|
- lib/bright/sis_apis/bright_sis.rb
|
131
131
|
- lib/bright/sis_apis/focus.rb
|
132
|
-
- lib/bright/sis_apis/
|
132
|
+
- lib/bright/sis_apis/one_roster.rb
|
133
|
+
- lib/bright/sis_apis/one_roster/infinite_campus.rb
|
134
|
+
- lib/bright/sis_apis/one_roster/skyward.rb
|
133
135
|
- lib/bright/sis_apis/power_school.rb
|
134
|
-
- lib/bright/sis_apis/skyward.rb
|
135
136
|
- lib/bright/sis_apis/synergy.rb
|
136
137
|
- lib/bright/sis_apis/tsis.rb
|
137
138
|
- lib/bright/student.rb
|
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
- !ruby/object:Gem::Version
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.5.16
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: Framework and tools for dealing with Student Information Systems
|