Skip to content

Commit

Permalink
Add graphql and new_quizzes keywords
Browse files Browse the repository at this point in the history
Based on #612 and as an issue in #619, this adds the `new_quizzes` and
`graphql` keyword endpoints in the requester module. Methods which
specify these locations will have the correct URL supplied by the
library in the `_url` parameter for the requester.
  • Loading branch information
bennettscience committed May 10, 2024
1 parent 93e7a43 commit 4b85189
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion canvasapi/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ def graphql(self, query, variables=None, **kwargs):
_kwargs=combine_kwargs(**kwargs)
+ [("query", query), ("variables", variables)],
# Needs to call special endpoint without api/v1
_url=self.__requester.original_url + "/api/graphql",
_url="graphql",
json=True,
)

Expand Down
6 changes: 3 additions & 3 deletions canvasapi/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def create_new_quiz(self, **kwargs):
response = self._requester.request(
"POST",
endpoint,
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
_url="new_quizzes",
_kwargs=combine_kwargs(**kwargs),
)
response_json = response.json()
Expand Down Expand Up @@ -1758,7 +1758,7 @@ def get_new_quiz(self, assignment, **kwargs):
response = self._requester.request(
"GET",
endpoint,
_url=self._requester.original_url + "/api/quiz/v1/" + endpoint,
_url="new_quizzes",
_kwargs=combine_kwargs(**kwargs),
)
response_json = response.json()
Expand All @@ -1783,7 +1783,7 @@ def get_new_quizzes(self, **kwargs):
self._requester,
"GET",
endpoint,
_url_override=self._requester.original_url + "/api/quiz/v1/" + endpoint,
_url_override="new_quizzes",
_kwargs=combine_kwargs(**kwargs),
)

Expand Down
4 changes: 2 additions & 2 deletions canvasapi/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def request(
elif _url == "graphql":
request_url = self.graphql
else:
# This is kind of a hacky way to make sure request_url has SOME kind of value before moving to the full_url declaration
request_url = ""
# It isn't a special URL case, so assign it to what the user requested.
request_url = _url

full_url = request_url if _url else "{}{}".format(self.base_url, endpoint)

Expand Down

0 comments on commit 4b85189

Please sign in to comment.