@@ -35,6 +35,8 @@ def __init__(self, base_url, access_token):
35
35
# Preserve the original base url and add "/api/v1" to it
36
36
self .original_url = base_url
37
37
self .base_url = base_url + "/api/v1/"
38
+ self .new_quizzes_url = base_url + "/api/quiz/v1/"
39
+ self .graphql = base_url + "/api/graphql"
38
40
self .access_token = access_token
39
41
self ._session = requests .Session ()
40
42
self ._cache = []
@@ -145,10 +147,16 @@ def request(
145
147
:param use_auth: Optional flag to remove the authentication
146
148
header from the request.
147
149
:type use_auth: bool
148
- :param _url: Optional argument to send a request to a URL
149
- outside of the Canvas API. If this is selected and an
150
- endpoint is provided, the endpoint will be ignored and
151
- only the _url argument will be used.
150
+ :param _url: Optional argument to specify a request type to Canvas
151
+ or to send a request to a URL outside of the Canvas API.
152
+ If set to "new_quizzes", the new quizzes endpoint will be used.
153
+ If set to "graphql", a graphql POST request will be sent.
154
+ If any string URL is provided, it will be used instead of the
155
+ base REST URL.
156
+ If omitted or set to None, the base_url for the instance REST
157
+ endpoint will be used.
158
+ If this is selected and an endpoint is provided, the endpoint
159
+ will be ignored and only the `_url` argument will be used..
152
160
:type _url: str
153
161
:param _kwargs: A list of 2-tuples representing processed
154
162
keyword arguments to be sent to Canvas as params or data.
@@ -159,7 +167,16 @@ def request(
159
167
:type json: `bool`
160
168
:rtype: :class:`requests.Response`
161
169
"""
162
- full_url = _url if _url else "{}{}" .format (self .base_url , endpoint )
170
+ # Check for specific URL endpoints available from Canvas. If not
171
+ # specified, pass the given URL and move on.
172
+ if not _url :
173
+ full_url = "{}{}" .format (self .base_url , endpoint )
174
+ elif _url == "new_quizzes" :
175
+ full_url = "{}{}" .format (self .new_quizzes_url , endpoint )
176
+ elif _url == "graphql" :
177
+ full_url = self .graphql
178
+ else :
179
+ full_url = _url
163
180
164
181
if not headers :
165
182
headers = {}
0 commit comments