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
@@ -1,7 +1,6 @@
|
|
1
1
|
module Bright
|
2
2
|
module SisApi
|
3
3
|
class BrightSis < Base
|
4
|
-
|
5
4
|
@@description = "Connects to the Bright SIS Data Store"
|
6
5
|
@@doc_url = ""
|
7
6
|
@@api_version = "v1"
|
@@ -9,12 +8,12 @@ module Bright
|
|
9
8
|
attr_accessor :connection_options
|
10
9
|
|
11
10
|
DEMOGRAPHICS_CONVERSION = {
|
12
|
-
"I"=>"American Indian Or Alaska Native",
|
13
|
-
"A"=>"Asian",
|
14
|
-
"B"=>"Black Or African American",
|
15
|
-
"P"=>"Native Hawaiian Or Other Pacific Islander",
|
16
|
-
"W"=>"White",
|
17
|
-
"M"=>"Other"
|
11
|
+
"I" => "American Indian Or Alaska Native",
|
12
|
+
"A" => "Asian",
|
13
|
+
"B" => "Black Or African American",
|
14
|
+
"P" => "Native Hawaiian Or Other Pacific Islander",
|
15
|
+
"W" => "White",
|
16
|
+
"M" => "Other"
|
18
17
|
}
|
19
18
|
|
20
19
|
def initialize(options = {})
|
@@ -26,21 +25,21 @@ module Bright
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def get_student_by_api_id(api_id, options = {})
|
29
|
-
|
28
|
+
get_students({"uuid" => api_id}, options.merge(limit: 1, wrap_in_collection: false)).first
|
30
29
|
end
|
31
30
|
|
32
31
|
def get_student(params = {}, options = {})
|
33
|
-
|
32
|
+
get_students(params, options.merge(limit: 1, wrap_in_collection: false)).first
|
34
33
|
end
|
35
34
|
|
36
35
|
def get_students(params = {}, options = {})
|
37
36
|
params[:limit] = params[:limit] || options[:limit] || 100
|
38
|
-
students_response_hash =
|
37
|
+
students_response_hash = request(:get, "students", map_student_search_params(params))
|
39
38
|
total_results = students_response_hash[:response_headers]["total"].to_i
|
40
39
|
if students_response_hash and students_response_hash["students"]
|
41
40
|
students_hash = [students_response_hash["students"]].flatten
|
42
41
|
|
43
|
-
students = students_hash.compact.collect {|st_hsh|
|
42
|
+
students = students_hash.compact.collect { |st_hsh|
|
44
43
|
Student.new(convert_to_student_data(st_hsh))
|
45
44
|
}
|
46
45
|
end
|
@@ -49,14 +48,14 @@ module Bright
|
|
49
48
|
load_more_call = proc { |page|
|
50
49
|
# pages start at one, so add a page here
|
51
50
|
params[:offset] = (params[:limit].to_i * page)
|
52
|
-
api.get_students(params, {:
|
51
|
+
api.get_students(params, {wrap_in_collection: false})
|
53
52
|
}
|
54
53
|
ResponseCollection.new({
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
54
|
+
seed_page: students,
|
55
|
+
total: total_results,
|
56
|
+
per_page: params[:limit],
|
57
|
+
load_more_call: load_more_call,
|
58
|
+
no_threads: options[:no_threads]
|
60
59
|
})
|
61
60
|
else
|
62
61
|
students
|
@@ -73,12 +72,12 @@ module Bright
|
|
73
72
|
|
74
73
|
def get_schools(params = {}, options = {})
|
75
74
|
params[:limit] = params[:limit] || options[:limit] || 100
|
76
|
-
schools_response_hash =
|
75
|
+
schools_response_hash = request(:get, "schools", map_school_search_params(params))
|
77
76
|
total_results = schools_response_hash[:response_headers]["total"].to_i
|
78
77
|
if schools_response_hash and schools_response_hash["schools"]
|
79
78
|
schools_hash = [schools_response_hash["schools"]].flatten
|
80
79
|
|
81
|
-
schools = schools_hash.compact.collect {|st_hsh|
|
80
|
+
schools = schools_hash.compact.collect { |st_hsh|
|
82
81
|
School.new(convert_to_school_data(st_hsh))
|
83
82
|
}
|
84
83
|
end
|
@@ -87,14 +86,14 @@ module Bright
|
|
87
86
|
load_more_call = proc { |page|
|
88
87
|
# pages start at one, so add a page here
|
89
88
|
params[:offset] = (params[:limit].to_i * page)
|
90
|
-
api.get_schools(params, {:
|
89
|
+
api.get_schools(params, {wrap_in_collection: false})
|
91
90
|
}
|
92
91
|
ResponseCollection.new({
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
92
|
+
seed_page: schools,
|
93
|
+
total: total_results,
|
94
|
+
per_page: params[:limit],
|
95
|
+
load_more_call: load_more_call,
|
96
|
+
no_threads: options[:no_threads]
|
98
97
|
})
|
99
98
|
else
|
100
99
|
schools
|
@@ -102,7 +101,7 @@ module Bright
|
|
102
101
|
end
|
103
102
|
|
104
103
|
def request(method, path, params = {})
|
105
|
-
uri
|
104
|
+
uri = "#{connection_options[:uri]}/#{path}"
|
106
105
|
body = nil
|
107
106
|
if method == :get
|
108
107
|
query = URI.encode_www_form(params)
|
@@ -113,7 +112,7 @@ module Bright
|
|
113
112
|
|
114
113
|
response = connection_retry_wrapper {
|
115
114
|
connection = Bright::Connection.new(uri)
|
116
|
-
headers =
|
115
|
+
headers = headers_for_auth
|
117
116
|
connection.request(method, body, headers)
|
118
117
|
}
|
119
118
|
|
@@ -130,12 +129,12 @@ module Bright
|
|
130
129
|
protected
|
131
130
|
|
132
131
|
def headers_for_auth(uri)
|
133
|
-
{"Authorization" => "Token token=#{
|
132
|
+
{"Authorization" => "Token token=#{connection_options[:access_token]}"}
|
134
133
|
end
|
135
134
|
|
136
135
|
def map_student_search_params(attrs)
|
137
136
|
filter_params = {}
|
138
|
-
attrs.each do |k,v|
|
137
|
+
attrs.each do |k, v|
|
139
138
|
case k.to_s
|
140
139
|
when "api_id"
|
141
140
|
filter_params["uuid"] = v
|
@@ -147,27 +146,27 @@ module Bright
|
|
147
146
|
filter_params[k] = v
|
148
147
|
end
|
149
148
|
end
|
150
|
-
|
149
|
+
filter_params
|
151
150
|
end
|
152
151
|
|
153
152
|
def convert_to_student_data(student_params)
|
154
153
|
return {} if student_params.nil?
|
155
154
|
student_data_hsh = {
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
166
|
-
:
|
167
|
-
:
|
168
|
-
:
|
169
|
-
:
|
170
|
-
}.reject{|k,v| v.blank?}
|
155
|
+
api_id: student_params["uuid"],
|
156
|
+
first_name: student_params["first_name"],
|
157
|
+
middle_name: student_params["middle_name"],
|
158
|
+
last_name: student_params["last_name"],
|
159
|
+
sis_student_id: student_params["student_number"],
|
160
|
+
state_student_id: student_params["state_id"],
|
161
|
+
grade: student_params["grade"],
|
162
|
+
grade_school_year: student_params["grade_school_year"],
|
163
|
+
projected_graduation_year: student_params["graduation_year"],
|
164
|
+
sex: student_params["sex"],
|
165
|
+
frl_status: student_params["frl_status"],
|
166
|
+
image: student_params["picture"],
|
167
|
+
hispanic_ethnicity: student_params["hispanic_latino"],
|
168
|
+
last_modified: student_params["updated_at"]
|
169
|
+
}.reject { |k, v| v.blank? }
|
171
170
|
unless student_params["birthdate"].blank?
|
172
171
|
student_data_hsh[:birth_date] = Date.parse(student_params["birthdate"]).to_s
|
173
172
|
end
|
@@ -193,7 +192,7 @@ module Bright
|
|
193
192
|
|
194
193
|
unless student_params["email_addresses"].blank?
|
195
194
|
student_data_hsh[:email_address] = {
|
196
|
-
:
|
195
|
+
email_address: student_params["email_addresses"].first["email_address"]
|
197
196
|
}
|
198
197
|
end
|
199
198
|
|
@@ -204,13 +203,13 @@ module Bright
|
|
204
203
|
unless student_params["contacts"].blank?
|
205
204
|
student_data_hsh[:contacts] = student_params["contacts"].collect do |contact_params|
|
206
205
|
contact_data_hsh = {
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
206
|
+
api_id: contact_params["uuid"],
|
207
|
+
first_name: contact_params["first_name"],
|
208
|
+
middle_name: contact_params["middle_name"],
|
209
|
+
last_name: contact_params["last_name"],
|
210
|
+
relationship_type: contact_params["relationship"],
|
211
|
+
sis_student_id: contact_params["sis_id"],
|
212
|
+
last_modified: contact_params["updated_at"]
|
214
213
|
}
|
215
214
|
unless contact_params["addresses"].blank?
|
216
215
|
contact_data_hsh[:addresses] = contact_params["addresses"].collect do |address_params|
|
@@ -224,19 +223,19 @@ module Bright
|
|
224
223
|
end
|
225
224
|
unless contact_params["email_addresses"].blank?
|
226
225
|
contact_data_hsh[:email_address] = {
|
227
|
-
:
|
226
|
+
email_address: contact_params["email_addresses"].first["email_address"]
|
228
227
|
}
|
229
228
|
end
|
230
|
-
contact_data_hsh.reject{|k,v| v.blank?}
|
229
|
+
contact_data_hsh.reject { |k, v| v.blank? }
|
231
230
|
end
|
232
231
|
end
|
233
232
|
|
234
|
-
|
233
|
+
student_data_hsh
|
235
234
|
end
|
236
235
|
|
237
236
|
def map_school_search_params(attrs)
|
238
237
|
filter_params = {}
|
239
|
-
attrs.each do |k,v|
|
238
|
+
attrs.each do |k, v|
|
240
239
|
case k.to_s
|
241
240
|
when "api_id"
|
242
241
|
filter_params["id"] = v
|
@@ -244,62 +243,61 @@ module Bright
|
|
244
243
|
filter_params[k] = v
|
245
244
|
end
|
246
245
|
end
|
247
|
-
|
246
|
+
filter_params
|
248
247
|
end
|
249
248
|
|
250
249
|
def convert_to_phone_number_data(phone_number_params)
|
251
250
|
return {} if phone_number_params.nil?
|
252
251
|
{
|
253
|
-
:
|
254
|
-
:
|
255
|
-
}.reject{|k,v| v.blank?}
|
252
|
+
phone_number: phone_number_params["phone_number"],
|
253
|
+
type: phone_number_params["phone_type"]
|
254
|
+
}.reject { |k, v| v.blank? }
|
256
255
|
end
|
257
256
|
|
258
257
|
def convert_to_address_data(address_params)
|
259
258
|
return {} if address_params.nil?
|
260
259
|
{
|
261
|
-
:
|
262
|
-
:
|
263
|
-
:
|
264
|
-
:
|
265
|
-
:
|
266
|
-
:
|
267
|
-
:
|
268
|
-
:
|
269
|
-
}.reject{|k,v| v.blank?}
|
260
|
+
street: address_params["street"],
|
261
|
+
apt: address_params["street_line_2"],
|
262
|
+
city: address_params["city"],
|
263
|
+
state: address_params["state"],
|
264
|
+
postal_code: address_params["zip"],
|
265
|
+
lattitude: address_params["latitude"],
|
266
|
+
longitude: address_params["longitude"],
|
267
|
+
type: address_params["address_type"]
|
268
|
+
}.reject { |k, v| v.blank? }
|
270
269
|
end
|
271
270
|
|
272
271
|
def convert_to_school_data(school_params)
|
273
272
|
return {} if school_params.nil?
|
274
273
|
|
275
274
|
school_data_hsh = {
|
276
|
-
:
|
277
|
-
:
|
278
|
-
:
|
279
|
-
:
|
280
|
-
:
|
281
|
-
:
|
282
|
-
:
|
275
|
+
api_id: school_params["id"],
|
276
|
+
name: school_params["name"],
|
277
|
+
number: school_params["number"],
|
278
|
+
state_id: school_params["state_id"],
|
279
|
+
low_grade: school_params["low_grade"],
|
280
|
+
high_grade: school_params["high_grade"],
|
281
|
+
last_modified: school_params["updated_at"]
|
283
282
|
}
|
284
283
|
|
285
284
|
unless school_params["school_address"].blank?
|
286
285
|
school_data_hsh[:address] = {
|
287
|
-
:
|
288
|
-
:
|
289
|
-
:
|
290
|
-
:
|
286
|
+
street: school_params["school_address"],
|
287
|
+
city: school_params["school_city"],
|
288
|
+
state: school_params["school_state"],
|
289
|
+
postal_code: school_params["school_zip"]
|
291
290
|
}
|
292
291
|
end
|
293
292
|
|
294
293
|
unless school_params["school_phone"].blank?
|
295
294
|
school_data_hsh[:phone_number] = {
|
296
|
-
:
|
295
|
+
phone_number: school_params["school_phone"]
|
297
296
|
}
|
298
297
|
end
|
299
298
|
|
300
|
-
|
299
|
+
school_data_hsh
|
301
300
|
end
|
302
|
-
|
303
301
|
end
|
304
302
|
end
|
305
303
|
end
|