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

fix(api): Add support for http interceptors #1039

Merged
merged 2 commits into from
Jul 29, 2019

Conversation

mickr
Copy link
Contributor

@mickr mickr commented Jul 15, 2019

No description provided.

@boxcla
Copy link

boxcla commented Jul 15, 2019

Verified that @mickr has signed the CLA. Thanks for the pull request!

@mickr mickr requested review from jstoffan and ConradJChan July 15, 2019 23:44
src/lib/api.js Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/Preview.js Outdated Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/__tests__/api-test.js Outdated Show resolved Hide resolved
@mickr
Copy link
Contributor Author

mickr commented Jul 17, 2019

I have updated the other feedback on this PR and I'm going to start working on the api layer refactor.

@mickr mickr requested a review from a team as a code owner July 18, 2019 05:19
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
src/lib/api.js Outdated Show resolved Hide resolved
@mickr mickr force-pushed the use-http-interceptors-in-preview branch 2 times, most recently from 569c80b to 1e271e2 Compare July 18, 2019 22:58
@mickr mickr changed the title Fix: Add support for http interceptors fix(api): Add support for http interceptors Jul 18, 2019
src/lib/api.js Show resolved Hide resolved
src/lib/Preview.js Outdated Show resolved Hide resolved
@mickr
Copy link
Contributor Author

mickr commented Jul 21, 2019

The tests have not been updated, I want to go over the changes in the PR before updating the test implementation.

Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach looks reasonable to me.

src/lib/Preview.js Outdated Show resolved Hide resolved
src/lib/Preview.js Outdated Show resolved Hide resolved
src/lib/metadataAPI.js Outdated Show resolved Hide resolved
src/lib/viewers/BaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/box3d/Box3DRenderer.js Outdated Show resolved Hide resolved
src/lib/util.js Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@ import EventEmitter from 'events';
import cloneDeep from 'lodash/cloneDeep';
import throttle from 'lodash/throttle';
/* eslint-enable import/first */
import api from './api';
import Api from './api';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the preference is that acronyms be uppercased

Copy link
Contributor Author

@mickr mickr Jul 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we are trying to denote that it is a class that requires new?

src/lib/RepStatus.js Outdated Show resolved Hide resolved
src/lib/Preview.js Show resolved Hide resolved

// Otherwise, get the content download URL of the original file and download
} else {
const getDownloadUrl = appendQueryParams(getDownloadURL(this.file.id, apiHost), queryParams);
api.get(getDownloadUrl, { headers: this.getRequestHeaders() }).then(data => {
this.api.get(getDownloadUrl, { headers: this.getRequestHeaders() }).then(data => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up, we could probably generalize this to this.api.file.getDownloadUrl and hide the reachability checks from the consumer entirely.

src/lib/__tests__/RepStatus-test.js Outdated Show resolved Hide resolved
src/lib/__tests__/api-test.js Outdated Show resolved Hide resolved
src/lib/__tests__/api-test.js Outdated Show resolved Hide resolved
src/lib/__tests__/api-test.js Outdated Show resolved Hide resolved
@mickr mickr force-pushed the use-http-interceptors-in-preview branch from cac3825 to 8b8516a Compare July 26, 2019 22:29
jstoffan
jstoffan previously approved these changes Jul 26, 2019
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job.

* Add support for using passed in request/response http interceptors.
* Add request and response interceptors to documentation
* Convert metadata API to a class and encapsulate within the API
* Add DownloadReachability to API
@mickr mickr force-pushed the use-http-interceptors-in-preview branch from 15d79c5 to 583183a Compare July 26, 2019 23:48
jstoffan
jstoffan previously approved these changes Jul 27, 2019
Changed instantiation point to the constructor and updated the tests.
@mickr mickr merged commit fbe052b into box:master Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants