UNPKG

biojs-rest-tessapi

Version:

API client to interface with the TeSS Rest API. Retrieve a list of metedata about upcoming Life science events, training materials, and other training opportunities. Return results filtered by metadata facets

177 lines (158 loc) 10.1 kB
/** * TeSS API * Access, search and filter through collections of training materials, events, packages, and workflows in TeSS. As a rule of thumb - You can add .json to the end of most pages to retrieve the data in a common exchange format. e.g - https://tess.elixir-europe.org/events/software-carpentry-west-virginia-university.json - https://tess.elixir-europe.org/materials/rna-seq-de-novo-transcriptome-reconstruction-with-rna-seq.json - https://tess.elixir-europe.org/packages/biocomp-computing-skills-collection.json - https://tess.elixir-europe.org/workflows/das-internet-fur-biologen.json - https://tess.elixir-europe.org/nodes/united-kingdom.json * * OpenAPI spec version: 1.0.0 * * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['ApiClient', 'model/Material', 'model/ShortMaterial'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('../model/Material'), require('../model/ShortMaterial')); } else { // Browser globals (root is window) if (!root.TeSsApi) { root.TeSsApi = {}; } root.TeSsApi.MaterialsApi = factory(root.TeSsApi.ApiClient, root.TeSsApi.Material, root.TeSsApi.ShortMaterial); } }(this, function(ApiClient, Material, ShortMaterial) { 'use strict'; /** * Materials service. * @module api/MaterialsApi * @version 1.0.0 */ /** * Constructs a new MaterialsApi. * @alias module:api/MaterialsApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ var exports = function(apiClient) { this.apiClient = apiClient || ApiClient.instance; /** * Callback function to receive the result of the materialsJsonGet operation. * @callback module:api/MaterialsApi~materialsJsonGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/ShortMaterial>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Search over the collection of training materials * The base url (materials.json) returns the first page of materials as seen on the UI (if you just go to /materials). To navigate through and filter out; use the below parameters. The returned value is an array of JSON objects. These parameters in JSON are formed exactly the same as within the UI so it is worth experimenting by clicking filters in the website and changing /materials to /materials.json to see how to create valid JSON requests. Combining different types of filters does a logical AND between filters, whereas combining different values from the same kind of filter does a logical OR between values. For example (scientific topic is &#39;Bioinformatics&#39; OR &#39;Data visualisation&#39;) AND (target_audience is &#39;Life Science Researchers&#39; OR &#39;PHD Students&#39;) * @param {Object} opts Optional parameters * @param {String} opts.q This is the search parameter. Enter terms and the resulting materials will be those that include this term in their description, name, keywords, or URL. * @param {String} opts.sort Sorts the results by a particular attribute. The options are &#39;asc&#39; (Title ascending), &#39;desc&#39; (Title descending), &#39;early&#39; (Earliest first), and &#39;late&#39; (Latest first). (default to desc) * @param {Number} opts.page Selects which page of results to return (e.g. 2) (default to 0.0) * @param {Array.<String>} opts.scientificTopics Returns all materials annotated with a certain scientific topic using EDAM (e.g. Alignment or Data+Visualization) * @param {Array.<String>} opts.contentProvider Returns all materials from the content provider that provided records to TeSS (e.g. Goblet or Erasys+App) * @param {Array.<String>} opts.tools Returns all materials that have been associated with a given tool from the ELIXIR bio.tools registry. * @param {Array.<String>} opts.standardDatabaseOrPolicy returns all materials that have been associated with a database, standard, or policy from the ELIXIR biosharing.org registry * @param {Array.<String>} opts.targetAudience Returns all the materials for an intended audience (e.g. PhD Student or Bench Biologist) * @param {Array.<String>} opts.keywords Returns all the materials that use this keyword to describe it. * @param {Array.<String>} opts.difficultyLevel Returns all materials with the selected difficultly level (e.g. Intermediate or Novice) * @param {Array.<String>} opts.authors Returns all materials by the specified author (e.g. John+Smith or Sarah+Michelle+Gellar * @param {Array.<String>} opts.contributors Returns all materials where a given name has contribuetd to it (e.g. John+Smith or Sarah+Michelle+Gellar * @param {Array.<String>} opts.licence Returns all materials that have this licence associated with it. Licences are from a set list which can be found here https://github.com/ElixirUK/TeSS/blob/master/config/dictionaries/licences.yml - The term to use is the &#39;title&#39; attribute * @param {Array.<String>} opts.node Returns all materials that have been developed by an ELIXIR node (e.g. Belgium or United+Kingdom) * @param {module:api/MaterialsApi~materialsJsonGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/ShortMaterial>} */ this.materialsJsonGet = function(opts, callback) { opts = opts || {}; var postBody = null; var pathParams = { }; var queryParams = { 'q': opts['q'], 'sort': opts['sort'], 'page': opts['page'], 'scientific_topics': this.apiClient.buildCollectionParam(opts['scientificTopics'], 'multi'), 'content_provider': this.apiClient.buildCollectionParam(opts['contentProvider'], 'multi'), 'tools': this.apiClient.buildCollectionParam(opts['tools'], 'multi'), 'standard_database_or_policy': this.apiClient.buildCollectionParam(opts['standardDatabaseOrPolicy'], 'multi'), 'target_audience': this.apiClient.buildCollectionParam(opts['targetAudience'], 'multi'), 'keywords': this.apiClient.buildCollectionParam(opts['keywords'], 'multi'), 'difficulty_level': this.apiClient.buildCollectionParam(opts['difficultyLevel'], 'multi'), 'authors': this.apiClient.buildCollectionParam(opts['authors'], 'multi'), 'contributors': this.apiClient.buildCollectionParam(opts['contributors'], 'multi'), 'licence': this.apiClient.buildCollectionParam(opts['licence'], 'multi'), 'node': this.apiClient.buildCollectionParam(opts['node'], 'multi') }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = []; var accepts = ['application/json']; var returnType = [ShortMaterial]; return this.apiClient.callApi( '/materials.json', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } /** * Callback function to receive the result of the materialsNameJsonGet operation. * @callback module:api/MaterialsApi~materialsNameJsonGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/Material>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get all the information stored about a particular training material in TeSS. * Use the name of the training material to return a JSON object. e.g. https://tess.elixir-europe.org/materials/advanced-statistics-in-r.json - See the response schema to find out what fields are returned and what type each field is. This operation does not permit any parameters except the name as part of the URL. the name is a _slug_ of the title (lowercase + hypenated) * @param {String} name The _slug_ id of a training material e.g. advanced-statistics-in-r * @param {module:api/MaterialsApi~materialsNameJsonGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/Material>} */ this.materialsNameJsonGet = function(name, callback) { var postBody = null; // verify the required parameter 'name' is set if (name == undefined || name == null) { throw new Error("Missing the required parameter 'name' when calling materialsNameJsonGet"); } var pathParams = { 'name': name }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = []; var accepts = ['application/json']; var returnType = [Material]; return this.apiClient.callApi( '/materials/{name}.json', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } }; return exports; }));