Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework url structure to accommodate graphql and new quizzes endpoints #619

Closed
Thetwam opened this issue May 4, 2023 · 0 comments · Fixed by #653
Closed

Rework url structure to accommodate graphql and new quizzes endpoints #619

Thetwam opened this issue May 4, 2023 · 0 comments · Fixed by #653
Assignees

Comments

@Thetwam
Copy link
Member

Thetwam commented May 4, 2023

I wonder if instead of defining the_urlon all these calls we could modify requester.py to handle both of these patterns? Would eliminate a little redundancy. Would probably need like

self.base_url = base_url + "/api/v1"
self.new_quizzes_url = base_url + "/api/quiz/v1"

And then in requester.request would have to have some way of determining if it's a new quiz. >I feel like there will be more methods so having this a a little cleaner now could be of >benefit.

I'm not sure the best way to handle that though. The easy solution might be to re-use url? >Just an idea, not sure if it makes it significantly better.

       :param _url: Optional argument to specify the base URL to use for the request.
           If set to "new_quizzes", the `new_quizzes_url` instance variable will be used.
           If set to any other value (including None), the `base_url` instance variable will >be used.
           If this is selected and an endpoint is provided, the endpoint will be ignored
           and only the `_url` argument will be used.
       if _url == "new_quizzes":
           base_url = self.new_quizzes_url
       else:
           base_url = self.base_url

Originally posted by @jonespm in #612 (comment)

@Thetwam Thetwam mentioned this issue May 4, 2023
@Thetwam Thetwam added this to the CanvasAPI v3.2.0 milestone May 4, 2023
@Thetwam Thetwam removed this from the CanvasAPI v3.2.0 milestone May 24, 2023
bennettscience added a commit to bennettscience/canvasapi that referenced this issue Apr 24, 2024
Updated docstring with class arguments
Add check for _url without breaking `full_url` assignment

See ucfopen#619 for more details.

Following discussion on ucfopen#619, let the `Requester` be smarter about how
to send a request. The user can specify either `new_quizzes` or
`graphql` in the request to automatically use the correct endpoint. This
moves repeated logic out of the class methods themselves.
@bennettscience bennettscience self-assigned this Apr 24, 2024
bennettscience added a commit to bennettscience/canvasapi that referenced this issue May 10, 2024
Based on ucfopen#612 and as an issue in ucfopen#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.
bennettscience added a commit to bennettscience/canvasapi that referenced this issue May 11, 2024
Based on ucfopen#612 and as an issue in ucfopen#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.

Calls from the `canvas`, `course`, and `new_quizzes` modules have been
updated to use they keywords rather than a formatted URL string.

All tests passing.
Thetwam added a commit that referenced this issue May 12, 2024
* Use `new_quizzes` and `graphql` keywords

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.

Calls from the `canvas`, `course`, and `new_quizzes` modules have been
updated to use they keywords rather than a formatted URL string.

All tests passing.

* Better variable checks

Rearrange to check for `_url` first, then assign the request url more
explicitely.

* fix silly typos

---------

Co-authored-by: Matthew Emond <me@ucf.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants