lms-api 1.23.0 → 1.25.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 +4 -4
- data/lib/canvas_api/go_helpers.rb +5 -1
- data/lib/canvas_api/helpers.rb +9 -2
- data/lib/canvas_api/rb_graphql_helpers.rb +31 -7
- data/lib/canvas_api/render.rb +5 -0
- data/lib/canvas_api/templates/rb_graphql_input_type.erb +1 -1
- data/lib/lms/canvas_urls.rb +270 -144
- data/lib/lms/course_ids_required.rb +71 -7
- data/lib/lms/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4a340e8e6ed8b2baf43b7a275c35e3d4e777130895a840190ff18321cdca1e
|
4
|
+
data.tar.gz: 644ed220c47505d3c4a461f23685b43ae1f2692f5c5ed855962d59e13ccead29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2be066c4b249bf0c0bff5f62cd00cc4efbeb750d899292c10b5e6d84079e11c0edd25bc07658548d7aea55f6b1f486154c62e8811cb668a940a0edbc87e4de93
|
7
|
+
data.tar.gz: 859e9954053f6f14d27ff98cceced7bcfbbbcca12261ebe93eae53f5dcf5f9293c3e6a0a04cae025c2ce7336d7088d68bec6171d2955c3a582e4ddc86ac37346
|
@@ -327,7 +327,9 @@ module CanvasApi
|
|
327
327
|
puts "Using string type for '#{name}' ('#{property}') of type object."
|
328
328
|
"map[string](interface{})"
|
329
329
|
else
|
330
|
-
if property["type"] == "
|
330
|
+
if property["type"] == "array of outcome ids"
|
331
|
+
"[]string"
|
332
|
+
elsif property["type"] == "list of content items"
|
331
333
|
# HACK There's no list of content items object so we return an array of string
|
332
334
|
"[]string"
|
333
335
|
elsif property["type"].include?('{ "unread_count": "integer" }')
|
@@ -366,6 +368,8 @@ module CanvasApi
|
|
366
368
|
"no-op" # this is handled further up the stack
|
367
369
|
elsif property["type"] == "URL"
|
368
370
|
"string"
|
371
|
+
elsif property["type"] == "uuid"
|
372
|
+
"string"
|
369
373
|
else
|
370
374
|
raise "Unable to match '#{name}' requested property '#{property}' to Go Type."
|
371
375
|
end
|
data/lib/canvas_api/helpers.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
module CanvasApi
|
2
2
|
def nested_arg(str)
|
3
|
+
# update_list_of_blackout_dates has a parameter named 'blackout_dates:'
|
4
|
+
# This results in a parameter in the resolver named 'blackout_dates::'
|
5
|
+
# which causes a syntax error.
|
6
|
+
if str[str.length() - 1] == ":"
|
7
|
+
str = str.chop
|
8
|
+
end
|
9
|
+
|
3
10
|
# TODO/HACK we are replacing values from the string here to get things to work for now.
|
4
11
|
# However, removing these symbols means that the methods that use the arguments
|
5
12
|
# generated herein will have bugs and be unusable.
|
@@ -9,9 +16,9 @@ module CanvasApi
|
|
9
16
|
gsub("<", "_").
|
10
17
|
gsub(">", "_").
|
11
18
|
gsub("`", "").
|
12
|
-
gsub("https://canvas.instructure.com/lti/", "").
|
19
|
+
gsub("https://canvas.instructure.com/lti/", "lti_").
|
13
20
|
gsub("https://www.instructure.com/", "").
|
14
|
-
gsub("https://purl.imsglobal.org/spec/lti/claim/", "").
|
21
|
+
gsub("https://purl.imsglobal.org/spec/lti/claim/", "lti_claim_").
|
15
22
|
gsub(".", "")
|
16
23
|
end
|
17
24
|
end
|
@@ -6,7 +6,11 @@ module CanvasApi
|
|
6
6
|
CONFLICTING_NAMES = ["end", "context", "next", "module"]
|
7
7
|
|
8
8
|
def graphql_type(name, property, return_type = false, model = nil, input_type = false)
|
9
|
-
if property["
|
9
|
+
if property["nickname"] == "get_bulk_user_progress"
|
10
|
+
# custom type specific to the get_bulk_user_progress endpoint. The type from canvas is void but
|
11
|
+
# we have to use a custom type in order to return data.
|
12
|
+
"LMSGraphQL::Types::CanvasBespoke::CanvasModuleUser"
|
13
|
+
elsif property["$ref"]
|
10
14
|
canvas_name(property['$ref'], input_type)
|
11
15
|
elsif property["allowableValues"]
|
12
16
|
enum_class_name(model, name, input_type)
|
@@ -28,7 +32,7 @@ module CanvasApi
|
|
28
32
|
elsif property["items"]["$ref"] == "[String]"
|
29
33
|
"[String]"
|
30
34
|
elsif property["items"]["$ref"] == "DateTime" || property["items"]["$ref"] == "Date"
|
31
|
-
"[
|
35
|
+
"[GraphQL::Types::ISO8601DateTime]"
|
32
36
|
elsif property["items"]["$ref"]
|
33
37
|
# HACK on https://canvas.instructure.com/doc/api/submissions.json
|
34
38
|
# the ref value is set to a full sentence rather than a
|
@@ -54,15 +58,23 @@ module CanvasApi
|
|
54
58
|
puts "Using string type for '#{name}' ('#{property}') of type object."
|
55
59
|
"String"
|
56
60
|
else
|
57
|
-
if property["type"] == "
|
61
|
+
if property["type"] == "array of outcome ids"
|
62
|
+
"[String]"
|
63
|
+
elsif property["type"] == "TermsOfService"
|
58
64
|
# HACK There's no TermsOfService object so we return a string
|
59
65
|
"String"
|
60
66
|
elsif property["type"] == "list of content items"
|
61
67
|
# HACK There's no list of content items object so we return an array of string
|
62
68
|
"[String]"
|
69
|
+
elsif property["type"] == "uuid"
|
70
|
+
# uuid is a string
|
71
|
+
"String"
|
63
72
|
elsif property["type"].include?('{ "unread_count": "integer" }')
|
64
73
|
# HACK TODO this should probably be a different type.
|
65
74
|
"Int"
|
75
|
+
elsif property["type"].include?('{ "count": "integer" }')
|
76
|
+
# HACK TODO this should probably be a different type.
|
77
|
+
"Int"
|
66
78
|
elsif return_type
|
67
79
|
canvas_name(property["type"], input_type)
|
68
80
|
else
|
@@ -76,6 +88,12 @@ module CanvasApi
|
|
76
88
|
def canvas_name(type, input_type = false)
|
77
89
|
# Remove chars and fix spelling errors
|
78
90
|
name = type.split('|').first.strip.gsub(" ", "_").singularize.gsub("MediaTrackk", "MediaTrack")
|
91
|
+
|
92
|
+
# Handle comment in type
|
93
|
+
if name.include?("BlackoutDate_The_result_(which_should_match_the_input_with_maybe_some_different_IDs).")
|
94
|
+
name = "BlackoutDate"
|
95
|
+
end
|
96
|
+
|
79
97
|
"LMSGraphQL::Types::Canvas::Canvas#{name}#{input_type ? 'Input' : ''}"
|
80
98
|
end
|
81
99
|
|
@@ -98,9 +116,9 @@ module CanvasApi
|
|
98
116
|
when "boolean"
|
99
117
|
"Boolean"
|
100
118
|
when "datetime"
|
101
|
-
"
|
119
|
+
"GraphQL::Types::ISO8601DateTime"
|
102
120
|
when "date"
|
103
|
-
"
|
121
|
+
"GraphQL::Types::ISO8601DateTime"
|
104
122
|
else
|
105
123
|
raise "Unable to match requested primitive '#{type}' to GraphQL Type."
|
106
124
|
end
|
@@ -192,7 +210,7 @@ field :#{name.underscore}, #{type}, "#{description}", resolver_method: :resolve_
|
|
192
210
|
end
|
193
211
|
|
194
212
|
def is_basic_type(type)
|
195
|
-
["Int", "String", "Boolean", "
|
213
|
+
["Int", "String", "Boolean", "GraphQL::Types::ISO8601DateTime", "Float", "ID"].include?(type)
|
196
214
|
end
|
197
215
|
|
198
216
|
def no_brackets_period(str)
|
@@ -203,9 +221,15 @@ field :#{name.underscore}, #{type}, "#{description}", resolver_method: :resolve_
|
|
203
221
|
str.underscore.split("/").last.split("|").first.gsub(/^canvas_?/, "").gsub(" ", "_").strip.singularize
|
204
222
|
end
|
205
223
|
|
224
|
+
def make_bespoke_file_name(str)
|
225
|
+
str.underscore.split("/").last.split("|").first.gsub(" ", "_").strip.singularize
|
226
|
+
end
|
227
|
+
|
206
228
|
def require_from_operation(operation)
|
207
229
|
type = no_brackets_period(type_from_operation(@operation))
|
208
|
-
if
|
230
|
+
if type.include?("CanvasBespoke")
|
231
|
+
"require_relative \"../../types/canvas_bespoke/#{make_bespoke_file_name(type)}\""
|
232
|
+
elsif !is_basic_type(type)
|
209
233
|
"require_relative \"../../types/canvas/#{make_file_name(type)}\""
|
210
234
|
end
|
211
235
|
end
|
data/lib/canvas_api/render.rb
CHANGED
@@ -37,6 +37,11 @@ module CanvasApi
|
|
37
37
|
end
|
38
38
|
if operation
|
39
39
|
nickname = operation["nickname"]
|
40
|
+
|
41
|
+
if nickname == "save_enabled_account_calendars_creates_and_updates_enabled_account_calendars_and_mark_feature_as_seen_user_preferences_argument_mark_feature_as_seen_optional_boolean_flag_to_mark_account_calendars_feature_as_seen_argument_enabled_account_calendars_optional_array_array_of_account_ids_to_remember_in_calendars_list_of_user_curl_https_canvas_api_v_calendar_events_save_enabled_account_calendars_x_post_f_mark_feature_as_seen_true_f_enabled_account_calendars_f_enabled_account_calendars_h_authorization_bearer_token"
|
42
|
+
nickname = "save_enabled_account_calendars"
|
43
|
+
end
|
44
|
+
|
40
45
|
nickname = "#{@name}_#{nickname}" if [
|
41
46
|
"upload_file",
|
42
47
|
"query_by_course",
|
@@ -7,7 +7,7 @@ module LMSGraphQL
|
|
7
7
|
class Canvas<%=@model['id'].singularize%>Input < BaseInputObject
|
8
8
|
<%=graphql_field_enums(@model, true)-%>
|
9
9
|
description "<%=@description%>. API Docs: https://canvas.instructure.com/doc/api/<%=@name%>.html"
|
10
|
-
|
10
|
+
<%=graphql_fields(@model, @resource_name, true, true).join(" ")%>
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|