Class: RESTClient

RESTClient()

new RESTClient()

The RESTClient is a singleton class that handles the connection and data exchange from the back-end REST API.

Source:

Methods

auth_headers(jwt) → {JSON}

Method to add authorisation to the headers.

Parameters:
Name Type Description
jwt

the user's json web token

Source:
Returns:
  • headers with authorisation field added
Type
JSON

(async) canClaim(recordID, userToken) → {Promise}

Determine if a user has permission to create a MaintenanceRequest for a FairsharingRecord.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) canEdit(recordID, userToken) → {Promise}

Determine if a user has permission to edit this record.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) changeWatcher(recordID, operation, userToken) → {Promise}

Add or remove an watcher to/from a FairsharingRecord.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

operation String

'add' or 'remove'.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) claimRecord(recordID, userToken) → {Promise}

Attempt to create a MaintenanceRequest for a user for a FairsharingRecord.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) confirmAccount(token) → {Promise}

Validate the account given the corresponding token

Parameters:
Name Type Description
token String

the account token to validate

Source:
Returns:
Type
Promise

(async) createAccount(userLogin) → {Promise}

Method to create a new user

Parameters:
Name Type Description
userLogin Object

the user account to create

Source:
Returns:

response - server response

Type
Promise

(async) createGrant(grant, userToken) → {Promise}

Create a given grant

Parameters:
Name Type Description
grant Object
userToken String

the user jwt

Source:
Returns:
Type
Promise

Create new a licence link

Parameters:
Name Type Description
licenceLink Object

the licence link to create

token String

the user token

Source:
Returns:
Type
Promise

(async) createMessage(message, userToken) → {Promise}

Update the given message

Parameters:
Name Type Description
message Object

the message to create

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) createNewUserDefinedTag(term, token) → {Promise}

Create a new user defined tag in the database for users to tag their records.

Parameters:
Name Type Description
term String

the string value of the term

token String

the user JWT

Source:
Returns:
Type
Promise

(async) createOrganisation(organisation, userToken) → {Promise}

Create a given organisation

Parameters:
Name Type Description
organisation Object
userToken String

the user jwt

Source:
Returns:
Type
Promise

Create a new link between an organisation, a record and an optional grant.

Parameters:
Name Type Description
organisationLink Object

the organisation link to create

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) createProcessingNotes(noteText, recordId, jwt) → {Promise.<*>}

Create processing note of the given record

Parameters:
Name Type Description
noteText String

Processing Notes

recordId Number

FAIRsharing record Id

jwt String

the user token

Source:
Returns:
Type
Promise.<*>

(async) createRecord(record, jwt) → {Promise}

Post the given object to the API to create the corresponding record.

Parameters:
Name Type Description
record
jwt String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) delete(jwt) → {Promise}

Delete the user's account (they must be logged in).

Parameters:
Name Type Description
jwt String

the user token to expire.

Source:
Returns:
Type
Promise

Delete the given licence

Parameters:
Name Type Description
id Number

id of the licence link to delete

token String

the user token

Source:
Returns:
Type
Promise

(async) deleteMessage(messageId, userToken) → {Promise}

Update the given message

Parameters:
Name Type Description
messageId String

the ID of the message to delete

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) deleteOrganisation(organisationId, userToken) → {Promise}

Delete the given organisation link

Parameters:
Name Type Description
organisationId Number

the id of the link to remove

userToken String

the user jwt

Source:
Returns:
Type
Promise

Delete the given organisation link

Parameters:
Name Type Description
linkID Number

the id of the link to remove

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) deleteProcessingNote(noteId, jwt) → {Promise.<*>}

Delete processing note of the given record

Parameters:
Name Type Description
noteId Number

Processing Note Id

jwt String

the user token

Source:
Returns:
Type
Promise.<*>

(async) deletePublicUser(userID, jwt) → {Promise}

Delete the user

Parameters:
Name Type Description
userID
jwt String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) deleteRecord(id, token) → {Promise}

Delete Record

Parameters:
Name Type Description
id Number

id of the record link to delete

token String

the user token

Source:
Returns:
Type
Promise

(async) deleteRelations(options) → {Promise}

Deletes the relationships as an array of items containing a targetID, a sourceID and a labelID

Parameters:
Name Type Description
options Object

the options to pass as {token: String, relations: Array}

Source:
Returns:
Type
Promise

(async) editOrganisation(organisation, id, userToken) → {Promise}

Edit a given organisation

Parameters:
Name Type Description
organisation Object
id Number
userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) editPublicUser(newUser, jwt) → {Promise}

Edit the current logged in user profile

Parameters:
Name Type Description
newUser Object

the new values for the logged in user

jwt String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) editUser(newUser, jwt) → {Promise}

Edit the current logged in user profile

Parameters:
Name Type Description
newUser Object

the new values for the logged in user

jwt String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) executeQuery(query) → {Promise.<*>}

Trigger the given query with Axios

Parameters:
Name Type Description
query
Source:
Returns:
Type
Promise.<*>

(async) extraMetadataFields(type, userToken) → {Promise}

Get the extra metadata fields for a RecordType

Parameters:
Name Type Description
type String

name of the record type.

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) getEditByMonth(token) → {Promise}

Get count of edits by month

Parameters:
Name Type Description
token String

the user token that needs to be a curator

Source:
Returns:
Type
Promise

(async) getHomepageJsonld() → {Promise}

Get JSON+LD for homepage.

Source:
Returns:
Type
Promise

(async) getProfileTypes() → {Promise}

Get the list of available profile types for a user.

Source:
Returns:
Type
Promise

(async) getPublicUser(jwt, id) → {Promise}

Get the current user data

Parameters:
Name Type Description
jwt
id
Source:
Returns:
Type
Promise

(async) getRecordCreatedByMonth(token) → {Promise}

Get count of records created by month

Parameters:
Name Type Description
token String

the user token that needs to be a curator

Source:
Returns:
Type
Promise

(async) getRecordsWoDOIs(token) → {Promise}

Get records without DOIS

Parameters:
Name Type Description
token String

the user token that needs to be a curator

Source:
Returns:
Type
Promise

(async) getStatisticsData() → {Promise}

Get statistics data without users

Source:
Returns:
Type
Promise

(async) getUser(jwt) → {Promise}

Get the current user data

Parameters:
Name Type Description
jwt
Source:
Returns:
Type
Promise

(async) getUserRoles(token) → {Promise}

Get the list of available roles for a user.

Parameters:
Name Type Description
token String

the user token

Source:
Returns:
Type
Promise

(async) getUsersList(jwt) → {Promise}

Get all users list

Parameters:
Name Type Description
jwt
Source:
Returns:
Type
Promise

(async) getZenodoSearch(call, userToken) → {Promise}

Get Zenodo call

Parameters:
Name Type Description
call String
userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) login(username, password) → {Promise}

Method to log in the user

Parameters:
Name Type Description
username

name of the user

password

password of the user

Source:
Returns:
  • the response of the server
Type
Promise

(async) logout(jwt) → {Promise}

Logout the user from the back, expiring the current jwt.

Parameters:
Name Type Description
jwt String

the user token to expire.

Source:
Returns:
Type
Promise

(async) removeMaintainer(recordID, userToken) → {Promise}

Remove an existing maintainer from a FairsharingRecord.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) requestResetPwd(email) → {Promise}

Method to send a reset password link to the given email address

Parameters:
Name Type Description
email String

to send the link to

Source:
Returns:
Type
Promise

(async) resendConfirmation(user) → {Promise}

Resend the validation link for a given user

Parameters:
Name Type Description
user Object

contains the email of the user.

Source:
Returns:
Type
Promise

(async) resetPassword(user) → {Promise}

Reset the password of the given user

Parameters:
Name Type Description
user Object

contains the new pwd, repeated pwd and token.

Source:
Returns:
Type
Promise

(async) resetPasswordWithoutToken(jwt, user) → {Promise}

Changes the password of the logged in user

Parameters:
Name Type Description
jwt String

the user token

user Object

contains the current, new and repeated new password

Source:
Returns:
Type
Promise

(async) reviewRecord(recordID, userToken) → {Promise}

Attempt to create a RecordReview for a user for a FairsharingRecord.

Parameters:
Name Type Description
recordID Integer

ID for the relevant FairsharingRecord.

userToken String

JWT of the logged in user

Source:
Returns:
Type
Promise

(async) saveRelations(options) → {Promise}

Saves the relationships as an array of items containing a targetID, a sourceID and a labelID

Parameters:
Name Type Description
options Object

the options to pass as {token: String, relations: Array}

Source:
Returns:
Type
Promise

(async) sendOrcidVerification(user) → {Promise}

Send the verification link for a given user

Parameters:
Name Type Description
user Object

contains the email, uid, identifier of the user.

Source:
Returns:
Type
Promise

Update the licenceLink

Parameters:
Name Type Description
licenceLink Object

the new values for the licence link

token String

the user token

Source:
Returns:
Type
Promise

(async) updateMessage(message, userToken) → {Promise}

Update the given message

Parameters:
Name Type Description
message Object

the message to update containing the ID to target and the new values

userToken String

the user jwt

Source:
Returns:
Type
Promise

Update the organisationLink given from linkID input with the given organisationLink

Parameters:
Name Type Description
organisationLink Object

the new organisation link value

linkID Number

ID of the organisationLink to update

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) updateProcessingNotes(noteId, noteText, recordId, jwt) → {Promise.<*>}

Update processing note of the given record

Parameters:
Name Type Description
noteId Number

Processing Note Id

noteText String

Processing Notes

recordId Number

FAIRsharing record Id

jwt String

the user token

Source:
Returns:
Type
Promise.<*>

(async) updateRecord(record) → {Promise}

Update the given record

Parameters:
Name Type Description
record Object

the record to update containing the ID to target, the new values and the user token

Source:
Returns:
Type
Promise

(async) updateStatusMaintenanceRequest(maintenanceRequest, newStatus, userToken) → {Promise}

Update the maintenanceRequest given the new status value

Parameters:
Name Type Description
maintenanceRequest Number

ID of the maintenanceRequest to update

newStatus string

new status to update

userToken String

the user jwt

Source:
Returns:
Type
Promise

(async) validateToken(jwt) → {Promise}

Verify that the given JWT is still valid

Parameters:
Name Type Description
jwt String

the token to validate

Source:
Returns:
Type
Promise

(async) verifyPassword(password) → {Promise}

Verify the validity of the given password

Parameters:
Name Type Description
password String

the password to test

Source:
Returns:
Type
Promise