clever_sdk 0.9.0.pre.pre → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +12 -6
- data/clever_sdk.gemspec +1 -1
- data/lib/clever_sdk/api/authentication.rb +8 -6
- data/lib/clever_sdk/api/courses.rb +12 -10
- data/lib/clever_sdk/api/districts.rb +4 -3
- data/lib/clever_sdk/api/events.rb +4 -3
- data/lib/clever_sdk/api/resources.rb +10 -9
- data/lib/clever_sdk/api/response.rb +8 -8
- data/lib/clever_sdk/api/schools.rb +14 -12
- data/lib/clever_sdk/api/sections.rb +16 -11
- data/lib/clever_sdk/api/terms.rb +10 -8
- data/lib/clever_sdk/api/users.rb +18 -16
- data/lib/clever_sdk/api.rb +8 -9
- data/lib/clever_sdk/data/resource/refs.rb +2 -2
- data/lib/clever_sdk/error.rb +4 -4
- data/lib/clever_sdk/version.rb +1 -1
- data/lib/clever_sdk.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3d4b692dc44fe2330c065131b5e341d84b63fa9bfb69605a96c7f86918891d5
|
4
|
+
data.tar.gz: 06f0f0ecf22ba83ebbb11d7d8b57b1e82644d734189131ea794285dd9ab8edfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad15dd2969bb455fd948e06f6a2d1d11ac1cfce9936f69987258917dffde3d137d5f3022e30fd673d2c4cf2a16a57ef642fd9a3e69ac24cec678352e1ac18a7
|
7
|
+
data.tar.gz: 1c6a4d518f39e52f80a44917067dee81152796be2b7f5cee0e43b693a838aec3b1d63062256394c9bec02f0c3f091c2b8e3c0d3cd86caeaee29b6bcf90384256
|
data/.circleci/config.yml
CHANGED
@@ -5,22 +5,28 @@ version: 2.1
|
|
5
5
|
# Define a job to be invoked later in a workflow.
|
6
6
|
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
7
7
|
jobs:
|
8
|
-
|
8
|
+
tests:
|
9
9
|
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
|
10
10
|
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
|
11
11
|
docker:
|
12
|
-
- image: cimg/
|
12
|
+
- image: cimg/ruby:3.3
|
13
13
|
# Add steps to the job
|
14
14
|
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
15
15
|
steps:
|
16
16
|
- checkout
|
17
17
|
- run:
|
18
|
-
name:
|
19
|
-
command:
|
18
|
+
name: Install Bundler Version
|
19
|
+
command: gem install bundler:2.4.10
|
20
|
+
- run:
|
21
|
+
name: Install Gem Dependencies
|
22
|
+
command: bundle install
|
23
|
+
- run:
|
24
|
+
name: Run tests
|
25
|
+
command: "bin/test"
|
20
26
|
|
21
27
|
# Invoke jobs via workflows
|
22
28
|
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
23
29
|
workflows:
|
24
|
-
|
30
|
+
ci:
|
25
31
|
jobs:
|
26
|
-
-
|
32
|
+
- tests
|
data/clever_sdk.gemspec
CHANGED
@@ -7,30 +7,32 @@ module CleverSDK
|
|
7
7
|
def tokens(client_id:, client_secret:, district: nil)
|
8
8
|
get(
|
9
9
|
"https://clever.com/oauth/tokens",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(owner_type: :district, district: district),
|
11
|
+
basic_auth_headers(client_id, client_secret)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def tokens!(client_id:, client_secret:, code: nil, grant_type: nil, redirect_uri: nil)
|
16
16
|
post(
|
17
17
|
"https://clever.com/oauth/tokens",
|
18
|
-
|
19
|
-
|
18
|
+
JSON.dump(params(code: code, grant_type: grant_type, redirect_uri: redirect_uri)),
|
19
|
+
basic_auth_headers(client_id, client_secret).merge({"Content-Type" => "application/json"})
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
23
|
def tokeninfo(access_token:)
|
24
24
|
get(
|
25
25
|
"https://clever.com/oauth/tokeninfo",
|
26
|
-
|
26
|
+
{},
|
27
|
+
bearer_headers(access_token)
|
27
28
|
)
|
28
29
|
end
|
29
30
|
|
30
31
|
def me(access_token:)
|
31
32
|
get(
|
32
33
|
"https://api.clever.com/v3.0/me",
|
33
|
-
|
34
|
+
{},
|
35
|
+
bearer_headers(access_token)
|
34
36
|
)
|
35
37
|
end
|
36
38
|
end
|
@@ -7,46 +7,48 @@ module CleverSDK
|
|
7
7
|
def courses(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
|
8
8
|
get(
|
9
9
|
"https://api.clever.com/v3.0/courses",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
|
11
|
+
bearer_headers(access_token)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def course(access_token:, id:)
|
16
16
|
get(
|
17
17
|
"https://api.clever.com/v3.0/courses/#{id}",
|
18
|
-
|
18
|
+
{},
|
19
|
+
bearer_headers(access_token)
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|
22
23
|
def course_district(access_token:, id:)
|
23
24
|
get(
|
24
25
|
"https://api.clever.com/v3.0/courses/#{id}/district",
|
25
|
-
|
26
|
+
{},
|
27
|
+
bearer_headers(access_token)
|
26
28
|
)
|
27
29
|
end
|
28
30
|
|
29
31
|
def course_resources(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
30
32
|
get(
|
31
33
|
"https://api.clever.com/v3.0/courses/#{id}/resources",
|
32
|
-
params
|
33
|
-
|
34
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
35
|
+
bearer_headers(access_token)
|
34
36
|
)
|
35
37
|
end
|
36
38
|
|
37
39
|
def course_schools(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
38
40
|
get(
|
39
41
|
"https://api.clever.com/v3.0/courses/#{id}/schools",
|
40
|
-
params
|
41
|
-
|
42
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
43
|
+
bearer_headers(access_token)
|
42
44
|
)
|
43
45
|
end
|
44
46
|
|
45
47
|
def course_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
46
48
|
get(
|
47
49
|
"https://api.clever.com/v3.0/courses/#{id}/sections",
|
48
|
-
params
|
49
|
-
|
50
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
51
|
+
bearer_headers(access_token)
|
50
52
|
)
|
51
53
|
end
|
52
54
|
end
|
@@ -7,15 +7,16 @@ module CleverSDK
|
|
7
7
|
def districts(access_token:, count: nil)
|
8
8
|
get(
|
9
9
|
"https://api.clever.com/v3.0/districts",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(count: count),
|
11
|
+
bearer_headers(access_token)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def district(access_token:, id:)
|
16
16
|
get(
|
17
17
|
"https://api.clever.com/v3.0/districts/#{id}",
|
18
|
-
|
18
|
+
{},
|
19
|
+
bearer_headers(access_token)
|
19
20
|
)
|
20
21
|
end
|
21
22
|
end
|
@@ -9,16 +9,17 @@ module CleverSDK
|
|
9
9
|
|
10
10
|
get(
|
11
11
|
"https://api.clever.com/v3.0/events",
|
12
|
-
params
|
12
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before,
|
13
13
|
school: school, record_type: record_type),
|
14
|
-
|
14
|
+
bearer_headers(access_token)
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
18
18
|
def event(access_token:, id:)
|
19
19
|
get(
|
20
20
|
"https://api.clever.com/v3.0/events/#{id}",
|
21
|
-
|
21
|
+
{},
|
22
|
+
bearer_headers(access_token)
|
22
23
|
)
|
23
24
|
end
|
24
25
|
end
|
@@ -6,31 +6,32 @@ module CleverSDK
|
|
6
6
|
def resources(access_token:, limit: nil, starting_after: nil, ending_before: nil)
|
7
7
|
get(
|
8
8
|
"https://api.clever.com/v3.0/resources",
|
9
|
-
params
|
10
|
-
|
9
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
10
|
+
bearer_headers(access_token)
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
14
|
def resource(access_token:, id:)
|
15
15
|
get(
|
16
16
|
"https://api.clever.com/v3.0/resources/#{id}",
|
17
|
-
|
17
|
+
{},
|
18
|
+
bearer_headers(access_token)
|
18
19
|
)
|
19
20
|
end
|
20
21
|
|
21
22
|
def resource_courses(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
22
23
|
get(
|
23
24
|
"https://api.clever.com/v3.0/resources/#{id}/courses",
|
24
|
-
params
|
25
|
-
|
25
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
26
|
+
bearer_headers(access_token)
|
26
27
|
)
|
27
28
|
end
|
28
29
|
|
29
30
|
def resource_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
30
31
|
get(
|
31
32
|
"https://api.clever.com/v3.0/resources/#{id}/sections",
|
32
|
-
params
|
33
|
-
|
33
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
34
|
+
bearer_headers(access_token)
|
34
35
|
)
|
35
36
|
end
|
36
37
|
|
@@ -38,8 +39,8 @@ module CleverSDK
|
|
38
39
|
def resource_users(access_token:, id:, role: nil, limit: nil, starting_after: nil, ending_before: nil)
|
39
40
|
get(
|
40
41
|
"https://api.clever.com/v3.0/resources/#{id}/users",
|
41
|
-
params
|
42
|
-
|
42
|
+
params(role: role, limit: limit, starting_after: starting_after, ending_before: ending_before),
|
43
|
+
bearer_headers(access_token)
|
43
44
|
)
|
44
45
|
end
|
45
46
|
# def resource_students(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module CleverSDK
|
4
4
|
class Api
|
5
5
|
class Response
|
6
|
-
def self.handle(
|
7
|
-
return CleverSDK::Api::Response.new(
|
6
|
+
def self.handle(faraday_response)
|
7
|
+
return CleverSDK::Api::Response.new(faraday_response) if faraday_response.success?
|
8
8
|
|
9
|
-
raise CleverSDK::Error.handle(
|
9
|
+
raise CleverSDK::Error.handle(faraday_response)
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.status_code_explanations
|
@@ -25,12 +25,12 @@ module CleverSDK
|
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
|
-
def initialize(
|
29
|
-
@_response =
|
28
|
+
def initialize(faraday_response)
|
29
|
+
@_response = faraday_response
|
30
30
|
end
|
31
31
|
|
32
32
|
def raw_request
|
33
|
-
@_response.request
|
33
|
+
@_response.env.request
|
34
34
|
end
|
35
35
|
|
36
36
|
def raw_response
|
@@ -38,7 +38,7 @@ module CleverSDK
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def code
|
41
|
-
@_response.
|
41
|
+
@_response.status
|
42
42
|
end
|
43
43
|
|
44
44
|
def headers
|
@@ -52,7 +52,7 @@ module CleverSDK
|
|
52
52
|
|
53
53
|
def access_token
|
54
54
|
# Dig the access token out of the response object.
|
55
|
-
@_response.
|
55
|
+
@_response.env.request_headers["Authorization"].split(" ").last
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -7,46 +7,48 @@ module CleverSDK
|
|
7
7
|
def schools(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
|
8
8
|
get(
|
9
9
|
"https://api.clever.com/v3.0/schools",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
|
11
|
+
bearer_headers(access_token)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def school(access_token:, id:)
|
16
16
|
get(
|
17
17
|
"https://api.clever.com/v3.0/schools/#{id}",
|
18
|
-
|
18
|
+
{},
|
19
|
+
bearer_headers(access_token)
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|
22
23
|
def school_courses(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
23
24
|
get(
|
24
25
|
"https://api.clever.com/v3.0/schools/#{id}/courses",
|
25
|
-
params
|
26
|
-
|
26
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
27
|
+
bearer_headers(access_token)
|
27
28
|
)
|
28
29
|
end
|
29
30
|
|
30
31
|
def school_district(access_token:, id:)
|
31
32
|
get(
|
32
33
|
"https://api.clever.com/v3.0/schools/#{id}/district",
|
33
|
-
|
34
|
+
{},
|
35
|
+
bearer_headers(access_token)
|
34
36
|
)
|
35
37
|
end
|
36
38
|
|
37
39
|
def school_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
38
40
|
get(
|
39
41
|
"https://api.clever.com/v3.0/schools/#{id}/sections",
|
40
|
-
params
|
41
|
-
|
42
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
43
|
+
bearer_headers(access_token)
|
42
44
|
)
|
43
45
|
end
|
44
46
|
|
45
47
|
def school_terms(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
46
48
|
get(
|
47
49
|
"https://api.clever.com/v3.0/schools/#{id}/terms",
|
48
|
-
params
|
49
|
-
|
50
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
51
|
+
bearer_headers(access_token)
|
50
52
|
)
|
51
53
|
end
|
52
54
|
|
@@ -55,9 +57,9 @@ module CleverSDK
|
|
55
57
|
def school_users(access_token:, id:, role: nil, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
|
56
58
|
get(
|
57
59
|
"https://api.clever.com/v3.0/schools/#{id}/users",
|
58
|
-
params
|
60
|
+
params(role: role, primary: primary,
|
59
61
|
limit: limit, starting_after: starting_after, ending_before: ending_before),
|
60
|
-
|
62
|
+
bearer_headers(access_token)
|
61
63
|
)
|
62
64
|
end
|
63
65
|
# def school_staff(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
|
@@ -7,51 +7,56 @@ module CleverSDK
|
|
7
7
|
def sections(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
|
8
8
|
get(
|
9
9
|
"https://api.clever.com/v3.0/sections",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
|
11
|
+
bearer_headers(access_token)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def section(access_token:, id:)
|
16
16
|
get(
|
17
17
|
"https://api.clever.com/v3.0/sections/#{id}",
|
18
|
-
|
18
|
+
{},
|
19
|
+
bearer_headers(access_token)
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|
22
23
|
def section_course(access_token:, id:)
|
23
24
|
get(
|
24
25
|
"https://api.clever.com/v3.0/sections/#{id}/course",
|
25
|
-
|
26
|
+
{},
|
27
|
+
bearer_headers(access_token)
|
26
28
|
)
|
27
29
|
end
|
28
30
|
|
29
31
|
def section_district(access_token:, id:)
|
30
32
|
get(
|
31
33
|
"https://api.clever.com/v3.0/sections/#{id}/district",
|
32
|
-
|
34
|
+
{},
|
35
|
+
bearer_headers(access_token)
|
33
36
|
)
|
34
37
|
end
|
35
38
|
|
36
39
|
def section_resources(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
37
40
|
get(
|
38
41
|
"https://api.clever.com/v3.0/sections/#{id}/resources",
|
39
|
-
params
|
40
|
-
|
42
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
43
|
+
bearer_headers(access_token)
|
41
44
|
)
|
42
45
|
end
|
43
46
|
|
44
47
|
def section_school(access_token:, id:)
|
45
48
|
get(
|
46
49
|
"https://api.clever.com/v3.0/sections/#{id}/school",
|
47
|
-
|
50
|
+
{},
|
51
|
+
bearer_headers(access_token)
|
48
52
|
)
|
49
53
|
end
|
50
54
|
|
51
55
|
def section_term(access_token:, id:)
|
52
56
|
get(
|
53
57
|
"https://api.clever.com/v3.0/sections/#{id}/term",
|
54
|
-
|
58
|
+
{},
|
59
|
+
bearer_headers(access_token)
|
55
60
|
)
|
56
61
|
end
|
57
62
|
|
@@ -59,8 +64,8 @@ module CleverSDK
|
|
59
64
|
def section_users(access_token:, id:, role: nil, limit: nil, starting_after: nil, ending_before: nil)
|
60
65
|
get(
|
61
66
|
"https://api.clever.com/v3.0/sections/#{id}/users",
|
62
|
-
params
|
63
|
-
|
67
|
+
params(role: role, limit: limit, starting_after: starting_after, ending_before: ending_before),
|
68
|
+
bearer_headers(access_token)
|
64
69
|
)
|
65
70
|
end
|
66
71
|
# def section_students(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
data/lib/clever_sdk/api/terms.rb
CHANGED
@@ -7,38 +7,40 @@ module CleverSDK
|
|
7
7
|
def terms(access_token:, limit: nil, starting_after: nil, ending_before: nil, count: nil)
|
8
8
|
get(
|
9
9
|
"https://api.clever.com/v3.0/terms",
|
10
|
-
params
|
11
|
-
|
10
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before, count: count),
|
11
|
+
bearer_headers(access_token)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def term(access_token:, id:)
|
16
16
|
get(
|
17
17
|
"https://api.clever.com/v3.0/terms/#{id}",
|
18
|
-
|
18
|
+
{},
|
19
|
+
bearer_headers(access_token)
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|
22
23
|
def term_district(access_token:, id:)
|
23
24
|
get(
|
24
25
|
"https://api.clever.com/v3.0/terms/#{id}/district",
|
25
|
-
|
26
|
+
{},
|
27
|
+
bearer_headers(access_token)
|
26
28
|
)
|
27
29
|
end
|
28
30
|
|
29
31
|
def term_schools(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
30
32
|
get(
|
31
33
|
"https://api.clever.com/v3.0/terms/#{id}/schools",
|
32
|
-
params
|
33
|
-
|
34
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
35
|
+
bearer_headers(access_token)
|
34
36
|
)
|
35
37
|
end
|
36
38
|
|
37
39
|
def term_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
38
40
|
get(
|
39
41
|
"https://api.clever.com/v3.0/terms/#{id}/sections",
|
40
|
-
params
|
41
|
-
|
42
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
43
|
+
bearer_headers(access_token)
|
42
44
|
)
|
43
45
|
end
|
44
46
|
end
|
data/lib/clever_sdk/api/users.rb
CHANGED
@@ -8,31 +8,33 @@ module CleverSDK
|
|
8
8
|
def users(access_token:, role: nil, limit: nil, starting_after: nil, ending_before: nil, count: nil)
|
9
9
|
get(
|
10
10
|
"https://api.clever.com/v3.0/users",
|
11
|
-
params
|
11
|
+
params(role: role, limit: limit, starting_after: starting_after, ending_before: ending_before,
|
12
12
|
count: count),
|
13
|
-
|
13
|
+
bearer_headers(access_token)
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def user(access_token:, id:)
|
18
18
|
get(
|
19
19
|
"https://api.clever.com/v3.0/users/#{id}",
|
20
|
-
|
20
|
+
{},
|
21
|
+
bearer_headers(access_token)
|
21
22
|
)
|
22
23
|
end
|
23
24
|
|
24
25
|
def user_district(access_token:, id:)
|
25
26
|
get(
|
26
27
|
"https://api.clever.com/v3.0/users/#{id}/district",
|
27
|
-
|
28
|
+
{},
|
29
|
+
bearer_headers(access_token)
|
28
30
|
)
|
29
31
|
end
|
30
32
|
|
31
33
|
def user_resources(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
32
34
|
get(
|
33
35
|
"https://api.clever.com/v3.0/users/#{id}/resources",
|
34
|
-
params
|
35
|
-
|
36
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
37
|
+
bearer_headers(access_token)
|
36
38
|
)
|
37
39
|
end
|
38
40
|
|
@@ -40,40 +42,40 @@ module CleverSDK
|
|
40
42
|
def user_schools(access_token:, id:, primary: nil, limit: nil, starting_after: nil, ending_before: nil)
|
41
43
|
get(
|
42
44
|
"https://api.clever.com/v3.0/users/#{id}/schools",
|
43
|
-
params
|
44
|
-
|
45
|
+
params(primary: primary, limit: limit, starting_after: starting_after, ending_before: ending_before),
|
46
|
+
bearer_headers(access_token)
|
45
47
|
)
|
46
48
|
end
|
47
49
|
|
48
50
|
def user_sections(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
49
51
|
get(
|
50
52
|
"https://api.clever.com/v3.0/users/#{id}/sections",
|
51
|
-
params
|
52
|
-
|
53
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
54
|
+
bearer_headers(access_token)
|
53
55
|
)
|
54
56
|
end
|
55
57
|
|
56
58
|
def user_mycontacts(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
57
59
|
get(
|
58
60
|
"https://api.clever.com/v3.0/users/#{id}/mycontacts",
|
59
|
-
params
|
60
|
-
|
61
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
62
|
+
bearer_headers(access_token)
|
61
63
|
)
|
62
64
|
end
|
63
65
|
|
64
66
|
def user_mystudents(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
65
67
|
get(
|
66
68
|
"https://api.clever.com/v3.0/users/#{id}/mystudents",
|
67
|
-
params
|
68
|
-
|
69
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
70
|
+
bearer_headers(access_token)
|
69
71
|
)
|
70
72
|
end
|
71
73
|
|
72
74
|
def user_myteachers(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
73
75
|
get(
|
74
76
|
"https://api.clever.com/v3.0/users/#{id}/myteachers",
|
75
|
-
params
|
76
|
-
|
77
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
78
|
+
bearer_headers(access_token)
|
77
79
|
)
|
78
80
|
end
|
79
81
|
end
|
data/lib/clever_sdk/api.rb
CHANGED
@@ -36,23 +36,22 @@ module CleverSDK
|
|
36
36
|
def page(access_token:, path:)
|
37
37
|
get(
|
38
38
|
"https://api.clever.com#{path}",
|
39
|
-
|
39
|
+
{},
|
40
|
+
bearer_headers(access_token)
|
40
41
|
)
|
41
42
|
end
|
42
43
|
|
43
44
|
private
|
44
45
|
|
45
|
-
def get url,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
def post url, **kwargs
|
50
|
-
run(url, method: :post, **kwargs)
|
46
|
+
def get url, params = nil, headers = nil
|
47
|
+
CleverSDK::Api::Response.handle(
|
48
|
+
Faraday.get url, params, headers
|
49
|
+
)
|
51
50
|
end
|
52
51
|
|
53
|
-
def
|
52
|
+
def post url, body = nil, headers = nil
|
54
53
|
CleverSDK::Api::Response.handle(
|
55
|
-
|
54
|
+
Faraday.post url, body, headers
|
56
55
|
)
|
57
56
|
end
|
58
57
|
|
@@ -29,8 +29,8 @@ module CleverSDK
|
|
29
29
|
def resource_courses(access_token:, id:, limit: nil, starting_after: nil, ending_before: nil)
|
30
30
|
get(
|
31
31
|
"https://api.clever.com/v3.0/resources/#{id}/courses",
|
32
|
-
params
|
33
|
-
|
32
|
+
params(limit: limit, starting_after: starting_after, ending_before: ending_before),
|
33
|
+
bearer_headers(access_token)
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
data/lib/clever_sdk/error.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module CleverSDK
|
4
4
|
class Error < StandardError
|
5
|
-
def self.handle(
|
6
|
-
explanation = CleverSDK::Api::Response.status_code_explanations[
|
5
|
+
def self.handle(faraday_response)
|
6
|
+
explanation = CleverSDK::Api::Response.status_code_explanations[faraday_response.status]
|
7
7
|
|
8
8
|
error_obj = if explanation.nil?
|
9
9
|
new
|
@@ -11,8 +11,8 @@ module CleverSDK
|
|
11
11
|
new([explanation[:meaning], explanation[:action_to_take]].join(": "))
|
12
12
|
end
|
13
13
|
|
14
|
-
error_obj.response =
|
15
|
-
error_obj.code =
|
14
|
+
error_obj.response = faraday_response
|
15
|
+
error_obj.code = faraday_response.status
|
16
16
|
error_obj.meaning = explanation[:meaning] if explanation
|
17
17
|
error_obj.action_to_take = explanation[:action_to_take] if explanation
|
18
18
|
error_obj
|
data/lib/clever_sdk/version.rb
CHANGED
data/lib/clever_sdk.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clever_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Eggett
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -138,19 +138,19 @@ dependencies:
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: faraday
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - "
|
144
|
+
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
146
|
+
version: '1.8'
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "
|
151
|
+
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
153
|
+
version: '1.8'
|
154
154
|
description: Provides an SDK for interacting wth the Clever API in Ruby
|
155
155
|
email:
|
156
156
|
- beneggett@gmail.com
|
@@ -244,11 +244,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
246
|
requirements:
|
247
|
-
- - "
|
247
|
+
- - ">="
|
248
248
|
- !ruby/object:Gem::Version
|
249
|
-
version:
|
249
|
+
version: '0'
|
250
250
|
requirements: []
|
251
|
-
rubygems_version: 3.
|
251
|
+
rubygems_version: 3.2.22
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: Clever API ruby wrapper
|