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)

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)

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)

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> claimRecord(recordID, userToken)

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)

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)

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)

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)

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)

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)

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> createRecord(record, jwt)

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

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)

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)

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> deletePublicUser(userID, jwt)

Delete the user

Parameters:
Name Type Description
userID
jwt String

JWT of the logged in user

Source:
Returns:
Type
Promise

<async> deleteRecord(id, token)

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)

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)

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)

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)

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)

Trigger the given query with Axios

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

<async> extraMetadataFields(type, userToken)

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)

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()

Get JSON+LD for homepage.

Source:
Returns:
Type
Promise

<async> getProfileTypes()

Get the list of available profile types for a user.

Source:
Returns:
Type
Promise

<async> getPublicUser(jwt, id)

Get the current user data

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

<async> getRecordCreatedByMonth(token)

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)

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()

Get statistics data without users

Source:
Returns:
Type
Promise

<async> getUser(jwt)

Get the current user data

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

<async> getUsersList(jwt)

Get all users list

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

<async> getZenodoSearch(call, userToken)

Get Zenodo call

Parameters:
Name Type Description
call String
userToken String

the user jwt

Source:
Returns:
Type
Promise

<async> login(username, password)

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)

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> requestResetPwd(email)

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)

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)

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)

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)

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)

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)

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)

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> updateRecord(record)

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)

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)

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)

Verify the validity of the given password

Parameters:
Name Type Description
password String

the password to test

Source:
Returns:
Type
Promise