ps_utilities 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ps_utilities/connection.rb +29 -1
- data/lib/ps_utilities/pre_built_get.rb +14 -17
- data/lib/ps_utilities/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12612f8c4d8b6ce0ee6a52c4d30748c5ca12b1f8414478d0f2164f8aa79295e
|
4
|
+
data.tar.gz: 5e0cbd4742dd42f98679cdea0356f1714e0ae23b878adba319cc1e33c7c901f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7bca650ace01f55b015bd52db6385c0b5d9fc1bdd99eac873bc6f9f4aebde2b05d51eb65226f9eab43f379d280daf8e423d03d461660810d7ecead03ed1322
|
7
|
+
data.tar.gz: 44d0548cea631ab20b45d21667c96611321eac42f7f5ef11c21239abde10984ec1f25d013ada635a2c66fede989c11e20927b0be3ed3516dc59bc8a2344ae8e7
|
@@ -51,8 +51,18 @@ module PsUtilities
|
|
51
51
|
case command
|
52
52
|
when nil, :authenticate
|
53
53
|
# authenticate unless token_valid?
|
54
|
+
# when :get
|
55
|
+
# api(:get, api_path, options) unless api_path.empty?
|
56
|
+
# when :put
|
57
|
+
# send(:api, :put, api_path, options) unless api_path.empty?
|
58
|
+
# when :post
|
59
|
+
# api(, api_path, options) unless api_path.empty?
|
54
60
|
when :get, :put, :post
|
55
|
-
|
61
|
+
api(command, api_path, options) unless api_path.empty?
|
62
|
+
# when :get, :put, :post
|
63
|
+
# send(command, api_path, options) unless api_path.empty?
|
64
|
+
# when :get, :put, :post
|
65
|
+
# send(:api, command, api_path, options) unless api_path.empty?
|
56
66
|
else
|
57
67
|
send(command, params)
|
58
68
|
end
|
@@ -60,6 +70,24 @@ module PsUtilities
|
|
60
70
|
|
61
71
|
private
|
62
72
|
|
73
|
+
# options = {query: {}}
|
74
|
+
def api(verb, api_path, options={})
|
75
|
+
count = 0
|
76
|
+
retries = 3
|
77
|
+
ps_url = base_uri + api_path
|
78
|
+
options = options.merge(headers)
|
79
|
+
begin
|
80
|
+
HTTParty.send(verb, ps_url, options)
|
81
|
+
rescue Net::ReadTimeout, Net::OpenTimeout
|
82
|
+
if count < retries
|
83
|
+
count += 1
|
84
|
+
retry
|
85
|
+
else
|
86
|
+
{ error: "no response (timeout) from URL: #{url}" }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
63
91
|
# options = {query: {}}
|
64
92
|
def get(api_path, options={})
|
65
93
|
count = 0
|
@@ -3,32 +3,29 @@ module PsUtilities
|
|
3
3
|
module PreBuiltGet
|
4
4
|
|
5
5
|
def get_active_students_count(params={})
|
6
|
-
#
|
7
|
-
|
8
|
-
options
|
9
|
-
get(
|
6
|
+
# api_path = "/ws/v1/district/student/count?q=school_enrollment.enroll_status_code==0"
|
7
|
+
api_path = "/ws/v1/district/student/count"
|
8
|
+
options = { query: {"q" => "school_enrollment.enroll_status_code==0"} }
|
9
|
+
get(api_path, options)
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_active_students_info(params={})
|
13
|
-
#
|
14
|
-
|
13
|
+
# api_path = "/ws/v1/district/student?q=school_enrollment.enroll_status==a&pagesize=500"
|
14
|
+
api_path = "/ws/v1/district/student"
|
15
15
|
options = { query:
|
16
16
|
{"q" => "school_enrollment.enroll_status_code==0",
|
17
|
-
"pagesize" => "500"}
|
18
|
-
|
19
|
-
get(url, options)
|
17
|
+
"pagesize" => "500"} }
|
18
|
+
get(api_path, options)
|
20
19
|
end
|
21
20
|
|
22
|
-
# las-test.powerschool.com/ws/v1/district/student?expansions=school_enrollment&q=student_username==xxxxx237
|
23
21
|
# params = {username: "xxxxxxx"}
|
24
22
|
def get_one_student_record(params)
|
25
|
-
#
|
26
|
-
|
27
|
-
options
|
28
|
-
{"q" => "student_username==#{params[:username]}",
|
29
|
-
|
30
|
-
|
31
|
-
get(url, options)
|
23
|
+
# api_path = "/ws/v1/district/student?expansions=school_enrollment,contact&q=student_username==xxxxxx237"
|
24
|
+
api_path = "/ws/v1/district/student"
|
25
|
+
options = { query:
|
26
|
+
{ "q" => "student_username==#{params[:username]}",
|
27
|
+
"expansions" => "school_enrollment,contact,contact_info"} }
|
28
|
+
get(api_path, options)
|
32
29
|
end
|
33
30
|
|
34
31
|
end
|
data/lib/ps_utilities/version.rb
CHANGED