clever_sdk 0.9.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +26 -0
  3. data/.env.sample +20 -0
  4. data/.gitignore +22 -0
  5. data/.tool-versions +1 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +65 -0
  10. data/Rakefile +10 -0
  11. data/bin/console +31 -0
  12. data/bin/setup +8 -0
  13. data/bin/test +6 -0
  14. data/clever_sdk.gemspec +44 -0
  15. data/lib/clever_sdk/api/authentication.rb +38 -0
  16. data/lib/clever_sdk/api/courses.rb +54 -0
  17. data/lib/clever_sdk/api/districts.rb +23 -0
  18. data/lib/clever_sdk/api/events.rb +26 -0
  19. data/lib/clever_sdk/api/resources.rb +49 -0
  20. data/lib/clever_sdk/api/response.rb +59 -0
  21. data/lib/clever_sdk/api/schools.rb +68 -0
  22. data/lib/clever_sdk/api/sections.rb +70 -0
  23. data/lib/clever_sdk/api/terms.rb +46 -0
  24. data/lib/clever_sdk/api/users.rb +81 -0
  25. data/lib/clever_sdk/api.rb +81 -0
  26. data/lib/clever_sdk/authentication.rb +67 -0
  27. data/lib/clever_sdk/client/courses.rb +45 -0
  28. data/lib/clever_sdk/client/districts.rb +21 -0
  29. data/lib/clever_sdk/client/events.rb +22 -0
  30. data/lib/clever_sdk/client/resources.rb +40 -0
  31. data/lib/clever_sdk/client/schools.rb +54 -0
  32. data/lib/clever_sdk/client/sections.rb +59 -0
  33. data/lib/clever_sdk/client/terms.rb +40 -0
  34. data/lib/clever_sdk/client/users.rb +66 -0
  35. data/lib/clever_sdk/client.rb +41 -0
  36. data/lib/clever_sdk/configuration.rb +13 -0
  37. data/lib/clever_sdk/data/course/refs.rb +36 -0
  38. data/lib/clever_sdk/data/course.rb +44 -0
  39. data/lib/clever_sdk/data/courses.rb +79 -0
  40. data/lib/clever_sdk/data/district.rb +129 -0
  41. data/lib/clever_sdk/data/districts.rb +37 -0
  42. data/lib/clever_sdk/data/event.rb +93 -0
  43. data/lib/clever_sdk/data/events.rb +79 -0
  44. data/lib/clever_sdk/data/me.rb +34 -0
  45. data/lib/clever_sdk/data/resource/refs.rb +45 -0
  46. data/lib/clever_sdk/data/resource.rb +60 -0
  47. data/lib/clever_sdk/data/resources.rb +79 -0
  48. data/lib/clever_sdk/data/school/refs.rb +42 -0
  49. data/lib/clever_sdk/data/school.rb +88 -0
  50. data/lib/clever_sdk/data/schools.rb +79 -0
  51. data/lib/clever_sdk/data/section/refs.rb +45 -0
  52. data/lib/clever_sdk/data/section.rb +100 -0
  53. data/lib/clever_sdk/data/sections.rb +79 -0
  54. data/lib/clever_sdk/data/sso.rb +44 -0
  55. data/lib/clever_sdk/data/term/refs.rb +32 -0
  56. data/lib/clever_sdk/data/term.rb +46 -0
  57. data/lib/clever_sdk/data/terms.rb +79 -0
  58. data/lib/clever_sdk/data/token.rb +67 -0
  59. data/lib/clever_sdk/data/tokeninfo.rb +30 -0
  60. data/lib/clever_sdk/data/tokens.rb +35 -0
  61. data/lib/clever_sdk/data/user/contact_role.rb +19 -0
  62. data/lib/clever_sdk/data/user/district_admin_role.rb +19 -0
  63. data/lib/clever_sdk/data/user/refs.rb +56 -0
  64. data/lib/clever_sdk/data/user/staff_role.rb +19 -0
  65. data/lib/clever_sdk/data/user/student_role.rb +19 -0
  66. data/lib/clever_sdk/data/user/teacher_role.rb +19 -0
  67. data/lib/clever_sdk/data/user.rb +123 -0
  68. data/lib/clever_sdk/data/users.rb +79 -0
  69. data/lib/clever_sdk/error.rb +27 -0
  70. data/lib/clever_sdk/version.rb +5 -0
  71. data/lib/clever_sdk.rb +36 -0
  72. metadata +255 -0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CleverSDK
4
+ class Api
5
+ module Schools
6
+ # count - acceptable values are nil, :true, :false, :undefined
7
+ def schools(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
8
+ get(
9
+ "https://api.clever.com/v3.0/schools",
10
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
11
+ headers: bearer_headers(access_token)
12
+ )
13
+ end
14
+
15
+ def school(access_token:, id:)
16
+ get(
17
+ "https://api.clever.com/v3.0/schools/#{id}",
18
+ headers: bearer_headers(access_token)
19
+ )
20
+ end
21
+
22
+ def school_courses(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
23
+ get(
24
+ "https://api.clever.com/v3.0/schools/#{id}/courses",
25
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
26
+ headers: bearer_headers(access_token)
27
+ )
28
+ end
29
+
30
+ def school_district(access_token:, id:)
31
+ get(
32
+ "https://api.clever.com/v3.0/schools/#{id}/district",
33
+ headers: bearer_headers(access_token)
34
+ )
35
+ end
36
+
37
+ def school_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
38
+ get(
39
+ "https://api.clever.com/v3.0/schools/#{id}/sections",
40
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
41
+ headers: bearer_headers(access_token)
42
+ )
43
+ end
44
+
45
+ def school_terms(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
46
+ get(
47
+ "https://api.clever.com/v3.0/schools/#{id}/terms",
48
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
49
+ headers: bearer_headers(access_token)
50
+ )
51
+ end
52
+
53
+ # role - acceptable values are nil, :staff, :student, :teacher
54
+ # primary - acceptable values are nil, true
55
+ def school_users(access_token:, id:, role: nil, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
56
+ get(
57
+ "https://api.clever.com/v3.0/schools/#{id}/users",
58
+ params: params(role: role, primary: primary,
59
+ limit: limit, starting_after: starting_after, ending_before: ending_before),
60
+ headers: bearer_headers(access_token)
61
+ )
62
+ end
63
+ # def school_staff(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
64
+ # def school_students(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
65
+ # def school_teachers(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CleverSDK
4
+ class Api
5
+ module Sections
6
+ # count - acceptable values are nil, :true, :false, :undefined
7
+ def sections(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
8
+ get(
9
+ "https://api.clever.com/v3.0/sections",
10
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
11
+ headers: bearer_headers(access_token)
12
+ )
13
+ end
14
+
15
+ def section(access_token:, id:)
16
+ get(
17
+ "https://api.clever.com/v3.0/sections/#{id}",
18
+ headers: bearer_headers(access_token)
19
+ )
20
+ end
21
+
22
+ def section_course(access_token:, id:)
23
+ get(
24
+ "https://api.clever.com/v3.0/sections/#{id}/course",
25
+ headers: bearer_headers(access_token)
26
+ )
27
+ end
28
+
29
+ def section_district(access_token:, id:)
30
+ get(
31
+ "https://api.clever.com/v3.0/sections/#{id}/district",
32
+ headers: bearer_headers(access_token)
33
+ )
34
+ end
35
+
36
+ def section_resources(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
37
+ get(
38
+ "https://api.clever.com/v3.0/sections/#{id}/resources",
39
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
40
+ headers: bearer_headers(access_token)
41
+ )
42
+ end
43
+
44
+ def section_school(access_token:, id:)
45
+ get(
46
+ "https://api.clever.com/v3.0/sections/#{id}/school",
47
+ headers: bearer_headers(access_token)
48
+ )
49
+ end
50
+
51
+ def section_term(access_token:, id:)
52
+ get(
53
+ "https://api.clever.com/v3.0/sections/#{id}/term",
54
+ headers: bearer_headers(access_token)
55
+ )
56
+ end
57
+
58
+ # role - acceptable values are nil, :student, :teacher
59
+ def section_users(access_token:, id:, role: nil, limit: nil, starting_after: nil, ending_before: nil)
60
+ get(
61
+ "https://api.clever.com/v3.0/sections/#{id}/users",
62
+ params: params(role: role, limit: limit, starting_after: starting_after, ending_before: ending_before),
63
+ headers: bearer_headers(access_token)
64
+ )
65
+ end
66
+ # def section_students(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
67
+ # def section_teachers(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CleverSDK
4
+ class Api
5
+ module Terms
6
+ # count - acceptable values are nil, :true, :false, :undefined
7
+ def terms(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
8
+ get(
9
+ "https://api.clever.com/v3.0/terms",
10
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
11
+ headers: bearer_headers(access_token)
12
+ )
13
+ end
14
+
15
+ def term(access_token:, id:)
16
+ get(
17
+ "https://api.clever.com/v3.0/terms/#{id}",
18
+ headers: bearer_headers(access_token)
19
+ )
20
+ end
21
+
22
+ def term_district(access_token:, id:)
23
+ get(
24
+ "https://api.clever.com/v3.0/terms/#{id}/district",
25
+ headers: bearer_headers(access_token)
26
+ )
27
+ end
28
+
29
+ def term_schools(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
30
+ get(
31
+ "https://api.clever.com/v3.0/terms/#{id}/schools",
32
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
33
+ headers: bearer_headers(access_token)
34
+ )
35
+ end
36
+
37
+ def term_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
38
+ get(
39
+ "https://api.clever.com/v3.0/terms/#{id}/sections",
40
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
41
+ headers: bearer_headers(access_token)
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CleverSDK
4
+ class Api
5
+ module Users
6
+ # role - acceptable values are nil, :contact, :district_admin, :staff, :student, :teacher
7
+ # count - acceptable values are nil, :true, :false, :undefined
8
+ def users(access_token:, role: nil, limit: nil, starting_after: nil, ending_before: nil, count: nil)
9
+ get(
10
+ "https://api.clever.com/v3.0/users",
11
+ params: params(role: role, limit: limit, starting_after: starting_after, ending_before: ending_before,
12
+ count: count),
13
+ headers: bearer_headers(access_token)
14
+ )
15
+ end
16
+
17
+ def user(access_token:, id:)
18
+ get(
19
+ "https://api.clever.com/v3.0/users/#{id}",
20
+ headers: bearer_headers(access_token)
21
+ )
22
+ end
23
+
24
+ def user_district(access_token:, id:)
25
+ get(
26
+ "https://api.clever.com/v3.0/users/#{id}/district",
27
+ headers: bearer_headers(access_token)
28
+ )
29
+ end
30
+
31
+ def user_resources(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
32
+ get(
33
+ "https://api.clever.com/v3.0/users/#{id}/resources",
34
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
35
+ headers: bearer_headers(access_token)
36
+ )
37
+ end
38
+
39
+ # primary - acceptable values are nil, true
40
+ def user_schools(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
41
+ get(
42
+ "https://api.clever.com/v3.0/users/#{id}/schools",
43
+ params: params(primary: primary, limit: limit, starting_after: starting_after, ending_before: ending_before),
44
+ headers: bearer_headers(access_token)
45
+ )
46
+ end
47
+
48
+ def user_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
49
+ get(
50
+ "https://api.clever.com/v3.0/users/#{id}/sections",
51
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
52
+ headers: bearer_headers(access_token)
53
+ )
54
+ end
55
+
56
+ def user_mycontacts(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
57
+ get(
58
+ "https://api.clever.com/v3.0/users/#{id}/mycontacts",
59
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
60
+ headers: bearer_headers(access_token)
61
+ )
62
+ end
63
+
64
+ def user_mystudents(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
65
+ get(
66
+ "https://api.clever.com/v3.0/users/#{id}/mystudents",
67
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
68
+ headers: bearer_headers(access_token)
69
+ )
70
+ end
71
+
72
+ def user_myteachers(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
73
+ get(
74
+ "https://api.clever.com/v3.0/users/#{id}/myteachers",
75
+ params: params(limit: limit, starting_after: starting_after, ending_before: ending_before),
76
+ headers: bearer_headers(access_token)
77
+ )
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "base64"
4
+ require "json"
5
+ require "clever_sdk/error"
6
+ require "clever_sdk/api/response"
7
+ require "clever_sdk/api/authentication"
8
+ require "clever_sdk/api/courses"
9
+ require "clever_sdk/api/districts"
10
+ require "clever_sdk/api/resources"
11
+ require "clever_sdk/api/schools"
12
+ require "clever_sdk/api/sections"
13
+ require "clever_sdk/api/terms"
14
+ require "clever_sdk/api/users"
15
+ require "clever_sdk/api/events"
16
+
17
+ module CleverSDK
18
+ ##
19
+ # private
20
+ # CleverSDK::Api is only responsible for making requests to Clever API.
21
+ # CleverSDK::Api is not responsible for managing authentication state.
22
+ # CleverSDK::Api is not responsible for specifying/using configured values.
23
+ # CleverSDK::Api is not responsible for iterating across multiple Clever API requests.
24
+ class Api
25
+ include CleverSDK::Api::Authentication
26
+ include CleverSDK::Api::Courses
27
+ include CleverSDK::Api::Districts
28
+ include CleverSDK::Api::Resources
29
+ include CleverSDK::Api::Schools
30
+ include CleverSDK::Api::Sections
31
+ include CleverSDK::Api::Terms
32
+ include CleverSDK::Api::Users
33
+ include CleverSDK::Api::Events
34
+
35
+ # internal
36
+ def page(access_token:, path:)
37
+ get(
38
+ "https://api.clever.com#{path}",
39
+ headers: bearer_headers(access_token)
40
+ )
41
+ end
42
+
43
+ private
44
+
45
+ def get url, **kwargs
46
+ run(url, method: :get, **kwargs)
47
+ end
48
+
49
+ def post url, **kwargs
50
+ run(url, method: :post, **kwargs)
51
+ end
52
+
53
+ def run url, **kwargs
54
+ CleverSDK::Api::Response.handle(
55
+ Typhoeus::Request.new(url, **kwargs).run
56
+ )
57
+ end
58
+
59
+ def params **kwargs
60
+ kwargs.delete_if { |_k, v| v.nil? }
61
+ end
62
+
63
+ def basic_auth_token(client_id, client_secret)
64
+ Base64.strict_encode64([client_id, client_secret].join(":"))
65
+ end
66
+
67
+ def basic_auth_headers(client_id, client_secret)
68
+ {
69
+ "Accept" => "application/json",
70
+ "Authorization" => "Basic #{basic_auth_token(client_id, client_secret)}"
71
+ }
72
+ end
73
+
74
+ def bearer_headers(access_token)
75
+ {
76
+ "Accept" => "application/json",
77
+ "Authorization" => "Bearer #{access_token}"
78
+ }
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/api"
4
+ require "clever_sdk/data/tokens"
5
+ require "clever_sdk/data/tokeninfo"
6
+ require "clever_sdk/data/me"
7
+ require "clever_sdk/data/sso"
8
+
9
+ module CleverSDK
10
+ class Authentication
11
+ attr_accessor :configuration
12
+
13
+ def initialize(configuration = CleverSDK.configuration)
14
+ yield configuration if block_given?
15
+
16
+ @configuration = configuration
17
+ end
18
+
19
+ def tokens
20
+ response = Api.new.tokens(
21
+ client_id: configuration.client_id,
22
+ client_secret: configuration.client_secret
23
+ )
24
+ CleverSDK::Data::Tokens.new(response)
25
+ end
26
+
27
+ def token(district_id)
28
+ response = Api.new.tokens(
29
+ client_id: configuration.client_id,
30
+ client_secret: configuration.client_secret,
31
+ district: district_id
32
+ )
33
+ data = Array(response.body.dig("data")).first
34
+ CleverSDK::Data::Token.new(data, response)
35
+ end
36
+
37
+ def tokeninfo(access_token)
38
+ response = Api.new.tokeninfo(access_token: access_token)
39
+ CleverSDK::Data::Tokeninfo.new(response.body, response)
40
+ end
41
+
42
+ def me(access_token)
43
+ response = Api.new.me(access_token: access_token)
44
+ data = response.body.dig("data")
45
+ CleverSDK::Data::Me.new(data, response)
46
+ end
47
+
48
+ def sso(code)
49
+ response = Api.new.tokens!(
50
+ code: code,
51
+ grant_type: "authorization_code",
52
+ client_id: configuration.client_id,
53
+ client_secret: configuration.client_secret,
54
+ redirect_uri: configuration.redirect_uri
55
+ )
56
+ CleverSDK::Data::SSO.new(code, response)
57
+ end
58
+
59
+ def sso_redirect_uri
60
+ "https://clever.com/oauth/authorize?response_type=code&redirect_uri=#{configuration.redirect_uri}&client_id=#{configuration.client_id}"
61
+ end
62
+
63
+ def inspect
64
+ "#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")}>"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/courses"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Courses
8
+ # count - acceptable values are nil, :true, :false, :undefined
9
+ def courses(limit: nil, starting_after: nil, ending_before: nil, count: nil)
10
+ response = api.courses(access_token: access_token,
11
+ limit: limit, starting_after: starting_after, ending_before: ending_before, count: count)
12
+ CleverSDK::Data::Courses.new(response)
13
+ end
14
+
15
+ def course(id)
16
+ response = api.course(access_token: access_token, id: id)
17
+ data = response.body.dig("data")
18
+ CleverSDK::Data::Course.new(data, response)
19
+ end
20
+
21
+ def course_district(id)
22
+ response = api.course_district(access_token: access_token, id: id)
23
+ CleverSDK::Data::District.new(response.body.dig("data"), response)
24
+ end
25
+
26
+ def course_resources(id, limit: nil, starting_after: nil, ending_before: nil)
27
+ response = api.course_resources(access_token: access_token, id: id,
28
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
29
+ CleverSDK::Data::Resources.new(response)
30
+ end
31
+
32
+ def course_schools(id, limit: nil, starting_after: nil, ending_before: nil)
33
+ response = api.course_schools(access_token: access_token, id: id,
34
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
35
+ CleverSDK::Data::Schools.new(response)
36
+ end
37
+
38
+ def course_sections(id, limit: nil, starting_after: nil, ending_before: nil)
39
+ response = api.course_sections(access_token: access_token, id: id,
40
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
41
+ CleverSDK::Data::Sections.new(response)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/districts"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Districts
8
+ # count - acceptable values are nil, :true, :false, :undefined
9
+ def districts(count: nil)
10
+ response = api.districts(access_token: access_token, count: count)
11
+ CleverSDK::Data::Districts.new(response)
12
+ end
13
+
14
+ def district(id)
15
+ response = api.district(access_token: access_token, id: id)
16
+ data = response.body.dig("data")
17
+ CleverSDK::Data::District.new(data, response)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/events"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Events
8
+ def events(limit: nil, starting_after: nil, ending_before: nil, school: nil, record_type: nil)
9
+ response = api.events(access_token: access_token,
10
+ limit: limit, starting_after: starting_after, ending_before: ending_before,
11
+ school: school, record_type: record_type)
12
+ CleverSDK::Data::Events.new(response)
13
+ end
14
+
15
+ def event(id)
16
+ response = api.event(access_token: access_token, id: id)
17
+ data = response.body.dig("data")
18
+ CleverSDK::Data::Event.new(data, response)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/resources"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Resources
8
+ def resources(limit: nil, starting_after: nil, ending_before: nil)
9
+ response = api.resources(access_token: access_token,
10
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
11
+ CleverSDK::Data::Resources.new(response)
12
+ end
13
+
14
+ def resource(id)
15
+ response = api.resource(access_token: access_token, id: id)
16
+ data = response.body.dig("data")
17
+ CleverSDK::Data::Resources.new(data, response)
18
+ end
19
+
20
+ def resource_courses(id, limit: nil, starting_after: nil, ending_before: nil)
21
+ response = api.resource_courses(access_token: access_token, id: id,
22
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
23
+ CleverSDK::Data::Courses.new(response)
24
+ end
25
+
26
+ def resource_sections(id, limit: nil, starting_after: nil, ending_before: nil)
27
+ response = api.resource_sections(access_token: access_token, id: id,
28
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
29
+ CleverSDK::Data::Sections.new(response)
30
+ end
31
+
32
+ # role - acceptable values are nil, :student, :teacher
33
+ def resource_users(id, role: nil, limit: nil, starting_after: nil, ending_before: nil)
34
+ response = api.resource_users(access_token: access_token, id: id, role: role,
35
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
36
+ CleverSDK::Data::Users.new(response)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/schools"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Schools
8
+ # count - acceptable values are nil, :true, :false, :undefined
9
+ def schools(limit: nil, starting_after: nil, ending_before: nil, count: nil)
10
+ response = api.schools(access_token: access_token,
11
+ limit: limit, starting_after: starting_after, ending_before: ending_before, count: count)
12
+ CleverSDK::Data::Schools.new(response)
13
+ end
14
+
15
+ def school(id)
16
+ response = api.school(access_token: access_token, id: id)
17
+ data = response.body.dig("data")
18
+ CleverSDK::Data::School.new(data, response)
19
+ end
20
+
21
+ def school_courses(id, limit: nil, starting_after: nil, ending_before: nil)
22
+ response = api.school_courses(access_token: access_token, id: id,
23
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
24
+ CleverSDK::Data::Courses.new(response)
25
+ end
26
+
27
+ def school_district(id)
28
+ response = api.school_district(access_token: access_token, id: id)
29
+ data = response.body.dig("data")
30
+ CleverSDK::Data::District.new(data, response)
31
+ end
32
+
33
+ def school_sections(id, limit: nil, starting_after: nil, ending_before: nil)
34
+ response = api.school_sections(access_token: access_token, id: id,
35
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
36
+ CleverSDK::Data::Sections.new(response)
37
+ end
38
+
39
+ def school_terms(id, limit: nil, starting_after: nil, ending_before: nil)
40
+ response = api.school_terms(access_token: access_token, id: id,
41
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
42
+ CleverSDK::Data::Terms.new(response)
43
+ end
44
+
45
+ # role - acceptable values are nil, :staff, :student, :teacher
46
+ # primary - acceptable values are nil, true
47
+ def school_users(id, role: nil, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
48
+ response = api.school_users(access_token: access_token, id: id, role: role, primary: primary,
49
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
50
+ CleverSDK::Data::Users.new(response)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clever_sdk/data/sections"
4
+
5
+ module CleverSDK
6
+ class Client
7
+ module Sections
8
+ # count - acceptable values are nil, :true, :false, :undefined
9
+ def sections(limit: nil, starting_after: nil, ending_before: nil, count: nil)
10
+ response = api.sections(access_token: access_token,
11
+ limit: limit, starting_after: starting_after, ending_before: ending_before, count: count)
12
+ CleverSDK::Data::Sections.new(response)
13
+ end
14
+
15
+ def section(id)
16
+ response = api.section(access_token: access_token, id: id)
17
+ data = response.body.dig("data")
18
+ CleverSDK::Data::Section.new(data, response)
19
+ end
20
+
21
+ def section_course(id)
22
+ response = api.section_course(access_token: access_token, id: id)
23
+ data = response.body.dig("data")
24
+ CleverSDK::Data::Course.new(data, response)
25
+ end
26
+
27
+ def section_district(id)
28
+ response = api.section_district(access_token: access_token, id: id)
29
+ data = response.body.dig("data")
30
+ CleverSDK::Data::District.new(data, response)
31
+ end
32
+
33
+ def section_resources(id, limit: nil, starting_after: nil, ending_before: nil)
34
+ response = api.section_resources(access_token: access_token, id: id,
35
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
36
+ CleverSDK::Data::Resources.new(response)
37
+ end
38
+
39
+ def section_school(id)
40
+ response = api.section_district(access_token: access_token, id: id)
41
+ data = response.body.dig("data")
42
+ CleverSDK::Data::School.new(data, response)
43
+ end
44
+
45
+ def section_term(id)
46
+ response = api.section_district(access_token: access_token, id: id)
47
+ data = response.body.dig("data")
48
+ CleverSDK::Data::Term.new(data, response)
49
+ end
50
+
51
+ # role - acceptable values are nil, :student, :teacher
52
+ def section_users(id, role: nil, limit: nil, starting_after: nil, ending_before: nil)
53
+ response = api.section_users(access_token: access_token, id: id, role: role,
54
+ limit: limit, starting_after: starting_after, ending_before: ending_before)
55
+ CleverSDK::Data::Users.new(response)
56
+ end
57
+ end
58
+ end
59
+ end