plurall 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,185 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of school directors that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.directors(school_id: 123456).each do |director|
|
8
|
+
# puts director.name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class Directors
|
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 directors as an Integer.
|
28
|
+
def total_count
|
29
|
+
school_node.directors.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of directors as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Returns the school id for list of directors as a String.
|
40
|
+
def school_id
|
41
|
+
school_node.id
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Public: Iterates the list of directors.
|
46
|
+
#
|
47
|
+
# Examples
|
48
|
+
#
|
49
|
+
# Plurall.directors(school_id: 123456).each do |director|
|
50
|
+
# puts director.name
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# Yields a director 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.directors.edges.lazy.map(&:node).each(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Public: Iterates all directors.
|
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.directors(school_id: 123456).all do |director|
|
71
|
+
# puts director.name
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# Yields a director 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 directors available.
|
91
|
+
#
|
92
|
+
# Examples
|
93
|
+
#
|
94
|
+
# directors = Plurall.directors school_id: 123456
|
95
|
+
# directors.next?
|
96
|
+
#
|
97
|
+
# Returns true or false.
|
98
|
+
#
|
99
|
+
def next?
|
100
|
+
directors_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
|
+
directors_page_info.end_cursor
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Public: Retrieve the next page of directors.
|
116
|
+
#
|
117
|
+
# Returns the next page as Plurall::Directors, or nil.
|
118
|
+
#
|
119
|
+
def next
|
120
|
+
return nil unless next?
|
121
|
+
|
122
|
+
next_response = Plurall::Api.directors school_id: school_id, after: next_cursor
|
123
|
+
self.class.new next_response
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Public: Whether there are previous directors available.
|
128
|
+
#
|
129
|
+
# Examples
|
130
|
+
#
|
131
|
+
# directors = Plurall.directors school_id: 123456
|
132
|
+
# directors.prev?
|
133
|
+
#
|
134
|
+
# Returns true or false.
|
135
|
+
#
|
136
|
+
def prev?
|
137
|
+
directors_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
|
+
directors_page_info.start_cursor
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Public: Retrieve the previous page of directors.
|
153
|
+
#
|
154
|
+
# Examples
|
155
|
+
#
|
156
|
+
# directors = Plurall.directors school_id: 123456
|
157
|
+
# prev_directors = directors.prev
|
158
|
+
#
|
159
|
+
# Returns the previous page as Plurall::Directors, or nil.
|
160
|
+
#
|
161
|
+
def prev
|
162
|
+
return nil unless prev?
|
163
|
+
|
164
|
+
prev_response = Plurall::Api.directors 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")} directors:#{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 directors_page_info
|
182
|
+
school_node.directors.page_info
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of school managers that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.managers(school_id: 123456).each do |manager|
|
8
|
+
# puts manager.name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class Managers
|
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 managers as an Integer.
|
28
|
+
def total_count
|
29
|
+
school_node.managers.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of managers as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Returns the school id for list of managers as a String.
|
40
|
+
def school_id
|
41
|
+
school_node.id
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Public: Iterates the list of managers.
|
46
|
+
#
|
47
|
+
# Examples
|
48
|
+
#
|
49
|
+
# Plurall.managers(school_id: 123456).each do |manager|
|
50
|
+
# puts manager.name
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# Yields a manager 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.managers.edges.lazy.map(&:node).each(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Public: Iterates all managers.
|
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.managers(school_id: 123456).all do |manager|
|
71
|
+
# puts manager.name
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# Yields a manager 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 managers available.
|
91
|
+
#
|
92
|
+
# Examples
|
93
|
+
#
|
94
|
+
# managers = Plurall.managers school_id: 123456
|
95
|
+
# managers.next?
|
96
|
+
#
|
97
|
+
# Returns true or false.
|
98
|
+
#
|
99
|
+
def next?
|
100
|
+
managers_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
|
+
managers_page_info.end_cursor
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Public: Retrieve the next page of managers.
|
116
|
+
#
|
117
|
+
# Returns the next page as Plurall::Managers, or nil.
|
118
|
+
#
|
119
|
+
def next
|
120
|
+
return nil unless next?
|
121
|
+
|
122
|
+
next_response = Plurall::Api.managers school_id: school_id, after: next_cursor
|
123
|
+
self.class.new next_response
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Public: Whether there are previous managers available.
|
128
|
+
#
|
129
|
+
# Examples
|
130
|
+
#
|
131
|
+
# managers = Plurall.managers school_id: 123456
|
132
|
+
# managers.prev?
|
133
|
+
#
|
134
|
+
# Returns true or false.
|
135
|
+
#
|
136
|
+
def prev?
|
137
|
+
managers_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
|
+
managers_page_info.start_cursor
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Public: Retrieve the previous page of managers.
|
153
|
+
#
|
154
|
+
# Examples
|
155
|
+
#
|
156
|
+
# managers = Plurall.managers school_id: 123456
|
157
|
+
# prev_managers = managers.prev
|
158
|
+
#
|
159
|
+
# Returns the previous page as Plurall::Managers, or nil.
|
160
|
+
#
|
161
|
+
def prev
|
162
|
+
return nil unless prev?
|
163
|
+
|
164
|
+
prev_response = Plurall::Api.managers 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")} managers:#{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 managers_page_info
|
182
|
+
school_node.managers.page_info
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
module Plurall
|
2
|
+
##
|
3
|
+
# Public: A list of schools that supports pagination.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# Plurall.schools.each do |school|
|
8
|
+
# puts school.legal_name
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
class Schools
|
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 schools as an Integer.
|
28
|
+
def total_count
|
29
|
+
response.data.schools.first.total_count
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Public: Returns the list of schools as a Hash.
|
34
|
+
def data
|
35
|
+
response.data.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Public: Iterates the list of schools.
|
40
|
+
#
|
41
|
+
# Examples
|
42
|
+
#
|
43
|
+
# Plurall.schools.each do |school|
|
44
|
+
# puts school.legal_name
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# Yields a school object to the block.
|
48
|
+
#
|
49
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
50
|
+
#
|
51
|
+
def each &block
|
52
|
+
return enum_for :each unless block
|
53
|
+
|
54
|
+
response.data.schools.first.edges.lazy.map(&:node).each(&block)
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Public: Iterates all schools.
|
59
|
+
#
|
60
|
+
# Several API calls may be made to retrieve all by repeatedly calling #next until #next? returns `false`.
|
61
|
+
#
|
62
|
+
# Examples
|
63
|
+
#
|
64
|
+
# Plurall.schools.all do |school|
|
65
|
+
# puts school.legal_name
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# Yields a school object to the block.
|
69
|
+
#
|
70
|
+
# Returns an Enumerator when no block argument is given, or nothing when when a block argument is given.
|
71
|
+
#
|
72
|
+
def all &block
|
73
|
+
return enum_for :all unless block
|
74
|
+
|
75
|
+
page = self
|
76
|
+
loop do
|
77
|
+
page.each(&block)
|
78
|
+
page = page.next
|
79
|
+
break if page.nil?
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Public: Whether there are more schools available.
|
85
|
+
#
|
86
|
+
# Examples
|
87
|
+
#
|
88
|
+
# schools = Plurall.schools school_id: 123456
|
89
|
+
# schools.next?
|
90
|
+
#
|
91
|
+
# Returns true or false.
|
92
|
+
#
|
93
|
+
def next?
|
94
|
+
response.data.schools.first.page_info.has_next_page
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Internal: The next cursor used for pagination.
|
99
|
+
#
|
100
|
+
# Returns the next cursor as a String, or nil.
|
101
|
+
#
|
102
|
+
def next_cursor
|
103
|
+
return nil unless next?
|
104
|
+
|
105
|
+
response.data.schools.first.page_info.end_cursor
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Public: Retrieve the next page of schools.
|
110
|
+
#
|
111
|
+
# Returns the next page as Plurall::Schools, or nil.
|
112
|
+
#
|
113
|
+
def next
|
114
|
+
return nil unless next?
|
115
|
+
|
116
|
+
next_response = Plurall::Api.schools after: next_cursor
|
117
|
+
self.class.new next_response
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Public: Whether there are previous schools available.
|
122
|
+
#
|
123
|
+
# Examples
|
124
|
+
#
|
125
|
+
# schools = Plurall.schools school_id: 123456
|
126
|
+
# schools.prev?
|
127
|
+
#
|
128
|
+
# Returns true or false.
|
129
|
+
#
|
130
|
+
def prev?
|
131
|
+
response.data.schools.first.page_info.has_previous_page
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Internal: The previous cursor used for pagination.
|
136
|
+
#
|
137
|
+
# Returns the previous cursor as a String, or nil.
|
138
|
+
#
|
139
|
+
def prev_cursor
|
140
|
+
return nil unless prev?
|
141
|
+
|
142
|
+
response.data.schools.first.page_info.start_cursor
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Public: Retrieve the previous page of schools.
|
147
|
+
#
|
148
|
+
# Examples
|
149
|
+
#
|
150
|
+
# schools = Plurall.schools school_id: 123456
|
151
|
+
# prev_schools = schools.prev
|
152
|
+
#
|
153
|
+
# Returns the previous page as Plurall::Schools, or nil.
|
154
|
+
#
|
155
|
+
def prev
|
156
|
+
return nil unless prev?
|
157
|
+
|
158
|
+
prev_response = Plurall::Api.schools before: prev_cursor
|
159
|
+
self.class.new prev_response
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Internal: Returns a string representation of the list.
|
164
|
+
#
|
165
|
+
def inspect
|
166
|
+
"#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} schools:#{total_count}>"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|