plurall 0.1.0
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 +7 -0
- data/.env.sample +14 -0
- data/.gitignore +12 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/plurall/administrators.rb +185 -0
- data/lib/plurall/api/administrators_query.rb +49 -0
- data/lib/plurall/api/attendants_query.rb +49 -0
- data/lib/plurall/api/classes_query.rb +60 -0
- data/lib/plurall/api/client.rb +5 -0
- data/lib/plurall/api/coordinators_query.rb +53 -0
- data/lib/plurall/api/directors_query.rb +49 -0
- data/lib/plurall/api/http.rb +9 -0
- data/lib/plurall/api/managers_query.rb +53 -0
- data/lib/plurall/api/person_query.rb +30 -0
- data/lib/plurall/api/schema.rb +5 -0
- data/lib/plurall/api/schools_query.rb +67 -0
- data/lib/plurall/api/student_classes_query.rb +71 -0
- data/lib/plurall/api/students_query.rb +83 -0
- data/lib/plurall/api/teachers_query.rb +75 -0
- data/lib/plurall/api.rb +139 -0
- data/lib/plurall/attendants.rb +185 -0
- data/lib/plurall/classes.rb +185 -0
- data/lib/plurall/configuration.rb +41 -0
- data/lib/plurall/coordinators.rb +185 -0
- data/lib/plurall/directors.rb +185 -0
- data/lib/plurall/errors.rb +11 -0
- data/lib/plurall/managers.rb +185 -0
- data/lib/plurall/schools.rb +169 -0
- data/lib/plurall/student_classes.rb +197 -0
- data/lib/plurall/students.rb +185 -0
- data/lib/plurall/teachers.rb +185 -0
- data/lib/plurall/version.rb +6 -0
- data/lib/plurall.rb +273 -0
- data/plurall.gemspec +45 -0
- data/schema/friendly.json +14653 -0
- data/schema/graphql.json +11907 -0
- data/sig/plurall.rbs +4 -0
- metadata +269 -0
@@ -0,0 +1,197 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of school classes that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.classes(school_id: 123456).each do |school_class|
|
8
|
+
# puts school_class.name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class StudentClasses
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# Internal: Returns the GraphQL API response as a GraphQL::Client::Response.
|
15
|
+
attr_reader :response
|
16
|
+
|
17
|
+
##
|
18
|
+
# Internal: Create a new object from a GraphQL API response.
|
19
|
+
#
|
20
|
+
# response - The GraphQL API response as a GraphQL::Client::Response.
|
21
|
+
#
|
22
|
+
def initialize response
|
23
|
+
@response = response
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Public: Returns the number of classes as an Integer.
|
28
|
+
def total_count
|
29
|
+
student_node.classes.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of classes as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Returns the school id for list of classes as a String.
|
40
|
+
def school_id
|
41
|
+
school_node.id
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Public: Returns the student uuid for list of classes as a String.
|
46
|
+
def student_uuid
|
47
|
+
student_node.uuid
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Public: Returns the student id for list of classes as a String.
|
52
|
+
def student_id
|
53
|
+
student_node.id
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Public: Iterates the list of student classes.
|
58
|
+
#
|
59
|
+
# Examples
|
60
|
+
#
|
61
|
+
# Plurall.classes(school_id: 123456).each do |school_class|
|
62
|
+
# puts school_class.name
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# Yields a school class object to the block.
|
66
|
+
#
|
67
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
68
|
+
#
|
69
|
+
def each &block
|
70
|
+
return enum_for :each unless block
|
71
|
+
|
72
|
+
student_node.classes.edges.lazy.map(&:node).each(&block)
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Public: Iterates all student classes.
|
77
|
+
#
|
78
|
+
# Several API calls may be made to retrieve all by repeatedly calling #next until #next? returns `false`.
|
79
|
+
#
|
80
|
+
# Examples
|
81
|
+
#
|
82
|
+
# Plurall.classes(school_id: 123456).all do |school_class|
|
83
|
+
# puts school_class.name
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# Yields a school class object to the block.
|
87
|
+
#
|
88
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
89
|
+
#
|
90
|
+
def all &block
|
91
|
+
return enum_for :all unless block
|
92
|
+
|
93
|
+
page = self
|
94
|
+
loop do
|
95
|
+
page.each(&block)
|
96
|
+
page = page.next
|
97
|
+
break if page.nil?
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Public: Whether there are more classes available.
|
103
|
+
#
|
104
|
+
# Examples
|
105
|
+
#
|
106
|
+
# classes = Plurall.classes school_id: 123456
|
107
|
+
# classes.next?
|
108
|
+
#
|
109
|
+
# Returns true or false.
|
110
|
+
#
|
111
|
+
def next?
|
112
|
+
student_node.classes.page_info.has_next_page
|
113
|
+
end
|
114
|
+
|
115
|
+
##
|
116
|
+
# Internal: The next cursor used for pagination.
|
117
|
+
#
|
118
|
+
# Returns the next cursor as a String, or nil.
|
119
|
+
#
|
120
|
+
def next_cursor
|
121
|
+
return nil unless next?
|
122
|
+
|
123
|
+
student_node.classes.page_info.end_cursor
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Public: Retrieve the next page of classes.
|
128
|
+
#
|
129
|
+
# Returns the next page as Plurall::Classes, or nil.
|
130
|
+
#
|
131
|
+
def next
|
132
|
+
return nil unless next?
|
133
|
+
|
134
|
+
next_response = Plurall::Api.classes school_id: school_id, after: next_cursor
|
135
|
+
self.class.new next_response
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Public: Whether there are previous classes available.
|
140
|
+
#
|
141
|
+
# Examples
|
142
|
+
#
|
143
|
+
# classes = Plurall.classes school_id: 123456
|
144
|
+
# classes.prev?
|
145
|
+
#
|
146
|
+
# Returns true or false.
|
147
|
+
#
|
148
|
+
def prev?
|
149
|
+
student_node.classes.page_info.has_previous_page
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Internal: The previous cursor used for pagination.
|
154
|
+
#
|
155
|
+
# Returns the previous cursor as a String, or nil.
|
156
|
+
#
|
157
|
+
def prev_cursor
|
158
|
+
return nil unless prev?
|
159
|
+
|
160
|
+
student_node.classes.page_info.start_cursor
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Public: Retrieve the previous page of classes.
|
165
|
+
#
|
166
|
+
# Examples
|
167
|
+
#
|
168
|
+
# classes = Plurall.classes school_id: 123456
|
169
|
+
# prev_classes = classes.prev
|
170
|
+
#
|
171
|
+
# Returns the previous page as Plurall::Classes, or nil.
|
172
|
+
#
|
173
|
+
def prev
|
174
|
+
return nil unless prev?
|
175
|
+
|
176
|
+
prev_response = Plurall::Api.classes school_id: school_id, before: prev_cursor
|
177
|
+
self.class.new prev_response
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# Internal: Returns a string representation of the list.
|
182
|
+
#
|
183
|
+
def inspect
|
184
|
+
"#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} classes:#{total_count}>"
|
185
|
+
end
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
def school_node
|
190
|
+
response.data.schools.first.edges.first.node
|
191
|
+
end
|
192
|
+
|
193
|
+
def student_node
|
194
|
+
school_node.students.edges.first.node
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of school students that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.students(school_id: 123456).each do |student|
|
8
|
+
# puts student.name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class Students
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# Internal: Returns the GraphQL API response as a GraphQL::Client::Response.
|
15
|
+
attr_reader :response
|
16
|
+
|
17
|
+
##
|
18
|
+
# Internal: Create a new object from a GraphQL API response.
|
19
|
+
#
|
20
|
+
# response - The GraphQL API response as a GraphQL::Client::Response.
|
21
|
+
#
|
22
|
+
def initialize response
|
23
|
+
@response = response
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Public: Returns the number of students as an Integer.
|
28
|
+
def total_count
|
29
|
+
school_node.students.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of students as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Returns the school id for list of students as a String.
|
40
|
+
def school_id
|
41
|
+
school_node.id
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Public: Iterates the list of students.
|
46
|
+
#
|
47
|
+
# Examples
|
48
|
+
#
|
49
|
+
# Plurall.students(school_id: 123456).each do |student|
|
50
|
+
# puts student.name
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# Yields a student object to the block.
|
54
|
+
#
|
55
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
56
|
+
#
|
57
|
+
def each &block
|
58
|
+
return enum_for :each unless block
|
59
|
+
|
60
|
+
school_node.students.edges.lazy.map(&:node).each(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Public: Iterates all students.
|
65
|
+
#
|
66
|
+
# Several API calls may be made to retrieve all by repeatedly calling #next until #next? returns `false`.
|
67
|
+
#
|
68
|
+
# Examples
|
69
|
+
#
|
70
|
+
# Plurall.students(school_id: 123456).all do |student|
|
71
|
+
# puts student.name
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# Yields a student object to the block.
|
75
|
+
#
|
76
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
77
|
+
#
|
78
|
+
def all &block
|
79
|
+
return enum_for :all unless block
|
80
|
+
|
81
|
+
page = self
|
82
|
+
loop do
|
83
|
+
page.each(&block)
|
84
|
+
page = page.next
|
85
|
+
break if page.nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Public: Whether there are more students available.
|
91
|
+
#
|
92
|
+
# Examples
|
93
|
+
#
|
94
|
+
# students = Plurall.students school_id: 123456
|
95
|
+
# students.next?
|
96
|
+
#
|
97
|
+
# Returns true or false.
|
98
|
+
#
|
99
|
+
def next?
|
100
|
+
students_page_info.has_next_page
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Internal: The next cursor used for pagination.
|
105
|
+
#
|
106
|
+
# Returns the next cursor as a String, or nil.
|
107
|
+
#
|
108
|
+
def next_cursor
|
109
|
+
return nil unless next?
|
110
|
+
|
111
|
+
students_page_info.end_cursor
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Public: Retrieve the next page of students.
|
116
|
+
#
|
117
|
+
# Returns the next page as Plurall::Students, or nil.
|
118
|
+
#
|
119
|
+
def next
|
120
|
+
return nil unless next?
|
121
|
+
|
122
|
+
next_response = Plurall::Api.students school_id: school_id, after: next_cursor
|
123
|
+
self.class.new next_response
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Public: Whether there are previous students available.
|
128
|
+
#
|
129
|
+
# Examples
|
130
|
+
#
|
131
|
+
# students = Plurall.students school_id: 123456
|
132
|
+
# students.prev?
|
133
|
+
#
|
134
|
+
# Returns true or false.
|
135
|
+
#
|
136
|
+
def prev?
|
137
|
+
students_page_info.has_previous_page
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Internal: The previous cursor used for pagination.
|
142
|
+
#
|
143
|
+
# Returns the previous cursor as a String, or nil.
|
144
|
+
#
|
145
|
+
def prev_cursor
|
146
|
+
return nil unless prev?
|
147
|
+
|
148
|
+
students_page_info.start_cursor
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Public: Retrieve the previous page of students.
|
153
|
+
#
|
154
|
+
# Examples
|
155
|
+
#
|
156
|
+
# students = Plurall.students school_id: 123456
|
157
|
+
# prev_students = students.prev
|
158
|
+
#
|
159
|
+
# Returns the previous page as Plurall::Students, or nil.
|
160
|
+
#
|
161
|
+
def prev
|
162
|
+
return nil unless prev?
|
163
|
+
|
164
|
+
prev_response = Plurall::Api.students school_id: school_id, before: prev_cursor
|
165
|
+
self.class.new prev_response
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Internal: Returns a string representation of the list.
|
170
|
+
#
|
171
|
+
def inspect
|
172
|
+
"#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} students:#{total_count}>"
|
173
|
+
end
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
def school_node
|
178
|
+
response.data.schools.first.edges.first.node
|
179
|
+
end
|
180
|
+
|
181
|
+
def students_page_info
|
182
|
+
school_node.students.page_info
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of school teachers that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.teachers(school_id: 123456).each do |teacher|
|
8
|
+
# puts teacher.name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class Teachers
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# Internal: Returns the GraphQL API response as a GraphQL::Client::Response.
|
15
|
+
attr_reader :response
|
16
|
+
|
17
|
+
##
|
18
|
+
# Internal: Create a new object from a GraphQL API response.
|
19
|
+
#
|
20
|
+
# response - The GraphQL API response as a GraphQL::Client::Response.
|
21
|
+
#
|
22
|
+
def initialize response
|
23
|
+
@response = response
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Public: Returns the number of teachers as an Integer.
|
28
|
+
def total_count
|
29
|
+
school_node.teachers.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of teachers as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Returns the school id for list of teachers as a String.
|
40
|
+
def school_id
|
41
|
+
school_node.id
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Public: Iterates the list of teachers.
|
46
|
+
#
|
47
|
+
# Examples
|
48
|
+
#
|
49
|
+
# Plurall.teachers(school_id: 123456).each do |teacher|
|
50
|
+
# puts teacher.name
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# Yields a teacher object to the block.
|
54
|
+
#
|
55
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
56
|
+
#
|
57
|
+
def each &block
|
58
|
+
return enum_for :each unless block
|
59
|
+
|
60
|
+
school_node.teachers.edges.lazy.map(&:node).each(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Public: Iterates all teachers.
|
65
|
+
#
|
66
|
+
# Several API calls may be made to retrieve all by repeatedly calling #next until #next? returns `false`.
|
67
|
+
#
|
68
|
+
# Examples
|
69
|
+
#
|
70
|
+
# Plurall.teachers(school_id: 123456).all do |teacher|
|
71
|
+
# puts teacher.name
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# Yields a teacher object to the block.
|
75
|
+
#
|
76
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
77
|
+
#
|
78
|
+
def all &block
|
79
|
+
return enum_for :all unless block
|
80
|
+
|
81
|
+
page = self
|
82
|
+
loop do
|
83
|
+
page.each(&block)
|
84
|
+
page = page.next
|
85
|
+
break if page.nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Public: Whether there are more teachers available.
|
91
|
+
#
|
92
|
+
# Examples
|
93
|
+
#
|
94
|
+
# teachers = Plurall.teachers school_id: 123456
|
95
|
+
# teachers.next?
|
96
|
+
#
|
97
|
+
# Returns true or false.
|
98
|
+
#
|
99
|
+
def next?
|
100
|
+
teachers_page_info.has_next_page
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Internal: The next cursor used for pagination.
|
105
|
+
#
|
106
|
+
# Returns the next cursor as a String, or nil.
|
107
|
+
#
|
108
|
+
def next_cursor
|
109
|
+
return nil unless next?
|
110
|
+
|
111
|
+
teachers_page_info.end_cursor
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Public: Retrieve the next page of teachers.
|
116
|
+
#
|
117
|
+
# Returns the next page as Plurall::Teachers, or nil.
|
118
|
+
#
|
119
|
+
def next
|
120
|
+
return nil unless next?
|
121
|
+
|
122
|
+
next_response = Plurall::Api.teachers school_id: school_id, after: next_cursor
|
123
|
+
self.class.new next_response
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Public: Whether there are previous teachers available.
|
128
|
+
#
|
129
|
+
# Examples
|
130
|
+
#
|
131
|
+
# teachers = Plurall.teachers school_id: 123456
|
132
|
+
# teachers.prev?
|
133
|
+
#
|
134
|
+
# Returns true or false.
|
135
|
+
#
|
136
|
+
def prev?
|
137
|
+
teachers_page_info.has_previous_page
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Internal: The previous cursor used for pagination.
|
142
|
+
#
|
143
|
+
# Returns the previous cursor as a String, or nil.
|
144
|
+
#
|
145
|
+
def prev_cursor
|
146
|
+
return nil unless prev?
|
147
|
+
|
148
|
+
teachers_page_info.start_cursor
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Public: Retrieve the previous page of teachers.
|
153
|
+
#
|
154
|
+
# Examples
|
155
|
+
#
|
156
|
+
# teachers = Plurall.teachers school_id: 123456
|
157
|
+
# prev_teachers = teachers.prev
|
158
|
+
#
|
159
|
+
# Returns the previous page as Plurall::Teachers, or nil.
|
160
|
+
#
|
161
|
+
def prev
|
162
|
+
return nil unless prev?
|
163
|
+
|
164
|
+
prev_response = Plurall::Api.teachers school_id: school_id, before: prev_cursor
|
165
|
+
self.class.new prev_response
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Internal: Returns a string representation of the list.
|
170
|
+
#
|
171
|
+
def inspect
|
172
|
+
"#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} teachers:#{total_count}>"
|
173
|
+
end
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
def school_node
|
178
|
+
response.data.schools.first.edges.first.node
|
179
|
+
end
|
180
|
+
|
181
|
+
def teachers_page_info
|
182
|
+
school_node.teachers.page_info
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|