Global

Methods

bindOrganisationsToUser(organisationsIDs) → {Promise}

Binds a list of organisations to the current user

Parameters:
Name Type Description
organisationsIDs Array.<Number>

a list of organisations IDs

Returns:
Promise
Example
client.bindOrganisationsToUser([1, 2]).then((res) => { console.log(res) });

canClaim(recordID) → {Promise}

Determine if a the logged in user has permission to claim a record.

Parameters:
Name Type Description
recordID Number

ID for the relevant FairsharingRecord.

Returns:
Promise

canEdit(recordID) → {Promise}

Determine if a user has permission to edit this record.

Parameters:
Name Type Description
recordID Number

ID of the record.

Returns:
Promise

claimRecord(recordID) → {Promise}

Attempt to create a request to become a maintainer/owner of the record. Requires admin validation.

Parameters:
Name Type Description
recordID Number

ID for the relevant record.

Returns:
Promise

clearCache()

Clear the current cache

confirmAccount(token) → {Promise}

Validate the account given the corresponding token received in the email

Parameters:
Name Type Description
token String

the account token to validate

Returns:
Promise
Example
RESTClient.confirmAccount({token: "tokenFromEmail"}).then((res) => { console.log(res) })

createAccount(userAccount) → {Promise}

Method to create a new user

Parameters:
Name Type Description
userAccount Object

the user account to create

Returns:
Promise -

response - server response

Example
RESTClient.createAccount({username: "username", email: "email@example.com", password: "pwd", repeatPassword: "pwd"}).then((res) => {console.log(res)})

createGrant(grant) → {Promise}

Create a new grant

Parameters:
Name Type Description
grant Object
Returns:
Promise
Example
let newGrant = {
"description": "A rather generous grant.",
"organisation_links_attributes":
[
  {
    "fairsharing_record_id": 1,
    "organisation_id": 1,
    "relation": "funds"
  }
]
}
RESTClient.createGrant(newGrant).then((res) => { console.log(res) });

Create new a licence link between a licence and a record

Parameters:
Name Type Description
licenceLink Object

the licence link to create: contains the licence id and the record id.

Returns:
Promise
Example
const licenceLink = {
    "fairsharing_record_id": 1,
    "licence_id": 1,
    "relation": "optional_string"
}
RESTClient.createLicenceLink(licence_link).then((res) => { console.log(res) })

createNewUserDefinedTag(term) → {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

Returns:
Promise

createOrganisation(organisation) → {Promise}

Create a given organisation

Parameters:
Name Type Description
organisation Object
Returns:
Promise
Example
const newOrganisation = {
"organisation_type_ids": [
  1
],
"name": "Harlington-Straker Studios",
"homepage": "https://harlington-straker.org",
"alternative_names": [
  "SHADO"
],
"logo": {
  "filename": "shado.jpg",
  "data": "file_data",
  "content_type": "image/jpeg"
}
}
RESTClient.createOrganisation(newOrganisation).then((res) => { console.log(res) });

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

Parameters:
Name Type Description
organisationLink Object

the organisation link to create

Returns:
Promise
Example
const organisationLink = {
{
"fairsharing_record_id": 1,
"organisation_id": 1,
"relation": "relation"
}
RESTClient.createOrganisationLink(organisationLink).then((res) => { console.log(res) });

createPublication(publication) → {Promise}

Creates a new publications

Parameters:
Name Type Description
publication Object

the publication to create

Returns:
Promise

createRecord(record) → {Promise}

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

Parameters:
Name Type Description
record Object
Returns:
Promise
Example
const newRecord = {
"metadata": {
    "name": "My new record",
    "homepage": "http://example.com",
    "abbreviation": "MNR",
    "contacts": [
        {
            "contact_name": "John Smith",
            "contact_orcid": "00000-321321321",
            "contact_email": "jsmith@example.com"
        }
    ],
    "description": "This record is for my new exciting resource.",
    "status": "ready"
},
"record_type_id": 1,
"subject_ids": [1, 2, 3],
"domain_ids": [1, 2, 3],
"taxonomy_ids": [1, 2, 3],
"user_defined_tag_ids": [1, 2, 3],
"country_ids": [1, 2, 3],
"publication_ids": [1, 2, 3],
"citation_ids": [1, 2, 3]
};
RESTClient.createRecord(newRecord).then((res) => {console.log(res)})

Delete the given licence

Parameters:
Name Type Description
licenceLinkID Number

id of the licence link to delete

Returns:
Promise

Delete the given organisation link

Parameters:
Name Type Description
linkID Number

the id of the link to remove

Returns:
Promise

deleteRecord(recordID) → {Promise}

Delete Record. Requires Admin right.

Parameters:
Name Type Description
recordID Number

id of the record link to delete

Returns:
Promise

deleteUser(userID) → {Promise}

Delete the user

Parameters:
Name Type Description
userID

the ID of the user to delete. Requires Admin rights.

Returns:
Promise

disableCache()

Disable the localStorage cache

editMyself(newUser) → {Promise}

Edit the current logged in user profile

Parameters:
Name Type Description
newUser Object

the new values for the logged in user

Returns:
Promise

editPublication(publication) → {Promise}

Edit the given publication

Parameters:
Name Type Description
publication Object

the publication ID and new values

Returns:
Promise

editUser(newUser) → {Promise}

Edit the given user profile. Requires Admin rights.

Parameters:
Name Type Description
newUser Object

the new values for the user to edit.

Returns:
Promise

enableCache(timer)

Enables the localStorage cache

Parameters:
Name Type Description
timer Number

in hours

getCountries(query) → {Promise}

Helper to get countries

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getCountry(countryID) → {Promise}

Helper to get a country

Parameters:
Name Type Description
countryID Number

ID of the country to get

Returns:
Promise

getDomain(domainID) → {Promise}

Helper to get a domain

Parameters:
Name Type Description
domainID Number

ID of the domain to get

Returns:
Promise

getDomains(query) → {Promise}

Helper to get domains

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getMetadataFields(recordType) → {Promise}

Get the extra metadata fields for a RecordType

Parameters:
Name Type Description
recordType String

name of the record type.

Returns:
Promise

getMyself() → {Promise}

Get the current user data

Returns:
Promise

getProfileTypes() → {Promise}

Get the list of available profile types for a user.

Returns:
Promise

getPublication(pubID) → {Promise}

Helper to get a publication

Parameters:
Name Type Description
pubID Number

ID of the publication to get

Returns:
Promise

getPublications(query) → {Promise}

Helper to get publications

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getPublicUser(userID) → {Promise}

Get the given user public data

Parameters:
Name Type Description
userID

ID of the user to get the data from

Returns:
Promise

getRecord(recordID) → {Promise}

Get the current record

Parameters:
Name Type Description
recordID Number

id of the record to get

Returns:
Promise

getRecordsWithoutDOI() → {Promise}

Get records without a DOI

Returns:
Promise

getRecordTypes() → {Promise}

Helper to get recordTypes

Returns:
Promise

getRelationsTypes() → {Promise}

Get the list of allowed relation types for editing record's relationships.

Returns:
Promise

getSpecies(speciesID) → {Promise}

Helper to get a user taxonomy term

Parameters:
Name Type Description
speciesID Number

ID of the taxonomy term to get

Returns:
Promise

getSubject(subjectID) → {Promise}

Helper to get a subject

Parameters:
Name Type Description
subjectID Number

ID of the subject to get

Returns:
Promise

getSubjects(query) → {Promise}

Helper to get subjects

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getTag(tagType, tagID) → {Promise}

Get the given tag type

Parameters:
Name Type Description
tagType
tagID
Returns:
Promise

getTaxon(taxonID) → {Promise}

Helper to get a user taxonomy term

Parameters:
Name Type Description
taxonID Number

ID of the taxonomy term to get

Returns:
Promise

getTaxonomies(query) → {Promise}

Helper to get taxonomies terms

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getUserDefinedTag(tagID) → {Promise}

Helper to get a user defined tag

Parameters:
Name Type Description
tagID Number

ID of the user defined tag to get

Returns:
Promise

getUserDefinedTags(query) → {Promise}

Helper to get user defined tags

Parameters:
Name Type Description
query String

optional query string

Returns:
Promise

getUsersList() → {Promise}

Get a list of all users

Returns:
Promise

login(username, password) → {Promise}

Method to log in the user and set the JWT into the headers

Parameters:
Name Type Description
username

name of the user

password

password of the user

Returns:
Promise -
  • the response of the server
Example
RESTClient.login({username: "username", password: "password"}).then((res) => {console.log(RESTClient.headers.Authorization)})

logout() → {Promise}

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

Returns:
Promise
Example
RESTClient.logout().then((res) => {console.log(res)})

processQuery(query, mustBeLoggedIn) → {Promise}

Process the query and either get the data from the cache or execute the axios request

Parameters:
Name Type Description
query Object

the query to execute

mustBeLoggedIn Boolean

should the user be logged in before attempting to execute the query

Returns:
Promise

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

Returns:
Promise
Example
RESTClient.requestResetPwd({email: "email@exmaple.com"}).then((res) => { console.log(res) })

resendConfirmation(user) → {Promise}

Resend the validation link for a given user

Parameters:
Name Type Description
user Object

contains the email of the user.

Returns:
Promise
Example
RESTClient.resendConfirmation({email: "example@email.com"}).then((res) => {console.log(res)});

resetPassword(user) → {Promise}

Reset the password of the given user

Parameters:
Name Type Description
user Object

contains the new pwd, repeated pwd and token received in the email.

Returns:
Promise
Example
RESTClient.resetPassword({password: "pwd", repeatPassword: "pwd", token: "ExtractFromEmail"}).then((res) => {console.log(res)});

resetPasswordWithoutToken(user) → {Promise}

Changes the password of the logged in user

Parameters:
Name Type Description
user Object

contains the current, new and repeated new password

Returns:
Promise

reviewRecord(recordID) → {Promise}

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

Parameters:
Name Type Description
recordID Number

ID for the relevant FairsharingRecord.

Returns:
Promise

saveRelations(recordID, relations) → {Promise}

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

Parameters:
Name Type Description
recordID Number

the record to add the relationships to.

relations Array.<Object>

the relations.

Returns:
Promise

searchRecords(query) → {Promise}

Search FAIRsharing records

Parameters:
Name Type Description
query Object

optional query string

Returns:
Promise
Example
RESTClient.searchRecords({q: "GenBank", page: 1, perPage: 2}).then((res) => {console.log(res)})

searchTags(tagType, query) → {Promise}

Search the countries

Parameters:
Name Type Description
tagType String

the type of tag to search for (eg. countries, domains, subjects, ...)

query String

an optional query string

Returns:
Promise

Update the licenceLink

Parameters:
Name Type Description
licenceLink Object

the new values for the licence link

Returns:
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

Returns:
Promise

updateRecord(recordID, record) → {Promise}

Update the given record

Parameters:
Name Type Description
recordID Number

the record ID to update

record Object

the record new values

Returns:
Promise

updateStatusMaintenanceRequest(maintenanceRequest, newStatus) → {Promise}

Update the maintenanceRequest given the new status value. Requires admin right.

Parameters:
Name Type Description
maintenanceRequest Number

ID of the maintenanceRequest to update

newStatus string

new status to update

Returns:
Promise

validateToken() → {Promise}

Verify that the given JWT is still valid

Returns:
Promise

verifyPassword(password) → {Promise}

Verify the given password is strong enough

Parameters:
Name Type Description
password String

the password to test

Returns:
Promise