-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add support for figshare sources #8
Conversation
sourceHandlers/figshare.js
Outdated
|
||
result.email = null; | ||
result.lastName = (namePieces.length > 0) ? namePieces.pop() : null; | ||
result.middleName = (namePieces.length > 1) ? namePieces.splice(1 - namePieces.length).join(' ') : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is copied from the GitHub API Handler. Maybe we can create a utility to handle parsing a name?
sourceHandlers/figshare.js
Outdated
} | ||
|
||
/** | ||
* Fetches data to be used in the citation from the API, stores it in a SourceData object, and returns that object to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the @Augments on the class will inherit function comments in the documentation from the super class. Not sure if it is necessary to do that here. Also looking at the documentation on the super class comments looks like I made a mistake and they are incorrect. We should probably fix that.
sourceHandlers/figshare.js
Outdated
const parsedBody = (body != null) ? JSON.parse(body) : null; | ||
|
||
if (error == null && response.statusCode !== 200) { | ||
error = new Error('Received a ' + response.statusCode + ' when making a request to ' + options.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reassigning the error callback parameter seems a little weird. Can we just do:
if(error == null && response.statusCode !== 200) {
callback(null, [new Error('Received a ' + response.statusCode + ' when making a request to ' + options.url)]);
}
else if(error != null) {
callback(null, [error]);
}
else {
// Create the source data object
}
sourceHandlers/figshare.js
Outdated
sourceData.url = parsedBody.url_public_html; | ||
sourceData.licence = parsedBody.license.name; | ||
sourceData.description = parsedBody.description; | ||
sourceData.uid = parsedBody.doi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be a UID object which contains the value and the type of UID it is like a DOI, ISBN, etc. Because this is the only handler that uses this for the moment this can be up for discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceHandlers/figshare.js
Outdated
sourceData.uid = parsedBody.doi; | ||
|
||
sourceData.authors = []; | ||
parsedBody.authors.forEach((author) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use the map function here instead?
sourceData.authors = parsedBody.authors.map((author) => {
return this._createAuthorObject(author);
});
sourceHandlers/figshare.js
Outdated
/** | ||
* Creates a FigshareAPIHandler. | ||
* @param baseUrl {String} - The Base URL to the API. | ||
* @param articleID {String} - The article ID." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the " at the end of the description of the articleID.
Once Erics changes are in I would say this looks like it will be good to go. |
e390cf5
to
66f8ba6
Compare
👍 |
This resolves mozillascience/software-citation-tools#20