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

1,208 lines (1,093 loc) 163 kB
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (Buffer){ /** * 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(['superagent'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('superagent')); } else { // Browser globals (root is window) if (!root.TeSsApi) { root.TeSsApi = {}; } root.TeSsApi.ApiClient = factory(root.superagent); } }(this, function(superagent) { 'use strict'; /** * @module ApiClient * @version 1.0.0 */ /** * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an * application to use this class directly - the *Api and model classes provide the public API for the service. The * contents of this file should be regarded as internal but are documented for completeness. * @alias module:ApiClient * @class */ var exports = function() { /** * The base URL against which to resolve every API call's (relative) path. * @type {String} * @default https://tess.oerc.ox.ac.uk/ */ this.basePath = 'https://tess.oerc.ox.ac.uk/'.replace(/\/+$/, ''); /** * The authentication methods to be included for all API calls. * @type {Array.<String>} */ this.authentications = { }; /** * The default HTTP headers to be included for all API calls. * @type {Array.<String>} * @default {} */ this.defaultHeaders = {}; /** * The default HTTP timeout for all API calls. * @type {Number} * @default 60000 */ this.timeout = 60000; }; /** * Returns a string representation for an actual parameter. * @param param The actual parameter. * @returns {String} The string representation of <code>param</code>. */ exports.prototype.paramToString = function(param) { if (param == undefined || param == null) { return ''; } if (param instanceof Date) { return param.toJSON(); } return param.toString(); }; /** * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values. * NOTE: query parameters are not handled here. * @param {String} path The path to append to the base URL. * @param {Object} pathParams The parameter values to append. * @returns {String} The encoded path with parameter values substituted. */ exports.prototype.buildUrl = function(path, pathParams) { if (!path.match(/^\//)) { path = '/' + path; } var url = this.basePath + path; var _this = this; url = url.replace(/\{([\w-]+)\}/g, function(fullMatch, key) { var value; if (pathParams.hasOwnProperty(key)) { value = _this.paramToString(pathParams[key]); } else { value = fullMatch; } return encodeURIComponent(value); }); return url; }; /** * Checks whether the given content type represents JSON.<br> * JSON content type examples:<br> * <ul> * <li>application/json</li> * <li>application/json; charset=UTF8</li> * <li>APPLICATION/JSON</li> * </ul> * @param {String} contentType The MIME content type to check. * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>. */ exports.prototype.isJsonMime = function(contentType) { return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i)); }; /** * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first. * @param {Array.<String>} contentTypes * @returns {String} The chosen content type, preferring JSON. */ exports.prototype.jsonPreferredMime = function(contentTypes) { for (var i = 0; i < contentTypes.length; i++) { if (this.isJsonMime(contentTypes[i])) { return contentTypes[i]; } } return contentTypes[0]; }; /** * Checks whether the given parameter value represents file-like content. * @param param The parameter to check. * @returns {Boolean} <code>true</code> if <code>param</code> represents a file. */ exports.prototype.isFileParam = function(param) { // fs.ReadStream in Node.js (but not in runtime like browserify) if (typeof window === 'undefined' && typeof require === 'function' && require('fs') && param instanceof require('fs').ReadStream) { return true; } // Buffer in Node.js if (typeof Buffer === 'function' && param instanceof Buffer) { return true; } // Blob in browser if (typeof Blob === 'function' && param instanceof Blob) { return true; } // File in browser (it seems File object is also instance of Blob, but keep this for safe) if (typeof File === 'function' && param instanceof File) { return true; } return false; }; /** * Normalizes parameter values: * <ul> * <li>remove nils</li> * <li>keep files and arrays</li> * <li>format to string with `paramToString` for other cases</li> * </ul> * @param {Object.<String, Object>} params The parameters as object properties. * @returns {Object.<String, Object>} normalized parameters. */ exports.prototype.normalizeParams = function(params) { var newParams = {}; for (var key in params) { if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) { var value = params[key]; if (this.isFileParam(value) || Array.isArray(value)) { newParams[key] = value; } else { newParams[key] = this.paramToString(value); } } } return newParams; }; /** * Enumeration of collection format separator strategies. * @enum {String} * @readonly */ exports.CollectionFormatEnum = { /** * Comma-separated values. Value: <code>csv</code> * @const */ CSV: ',', /** * Space-separated values. Value: <code>ssv</code> * @const */ SSV: ' ', /** * Tab-separated values. Value: <code>tsv</code> * @const */ TSV: '\t', /** * Pipe(|)-separated values. Value: <code>pipes</code> * @const */ PIPES: '|', /** * Native array. Value: <code>multi</code> * @const */ MULTI: 'multi' }; /** * Builds a string representation of an array-type actual parameter, according to the given collection format. * @param {Array} param An array parameter. * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy. * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns * <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>. */ exports.prototype.buildCollectionParam = function buildCollectionParam(param, collectionFormat) { if (param == null) { return null; } switch (collectionFormat) { case 'csv': return param.map(this.paramToString).join(','); case 'ssv': return param.map(this.paramToString).join(' '); case 'tsv': return param.map(this.paramToString).join('\t'); case 'pipes': return param.map(this.paramToString).join('|'); case 'multi': // return the array directly as SuperAgent will handle it as expected return param.map(this.paramToString); default: throw new Error('Unknown collection format: ' + collectionFormat); } }; /** * Applies authentication headers to the request. * @param {Object} request The request object created by a <code>superagent()</code> call. * @param {Array.<String>} authNames An array of authentication method names. */ exports.prototype.applyAuthToRequest = function(request, authNames) { var _this = this; authNames.forEach(function(authName) { var auth = _this.authentications[authName]; switch (auth.type) { case 'basic': if (auth.username || auth.password) { request.auth(auth.username || '', auth.password || ''); } break; case 'apiKey': if (auth.apiKey) { var data = {}; if (auth.apiKeyPrefix) { data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey; } else { data[auth.name] = auth.apiKey; } if (auth['in'] === 'header') { request.set(data); } else { request.query(data); } } break; case 'oauth2': if (auth.accessToken) { request.set({'Authorization': 'Bearer ' + auth.accessToken}); } break; default: throw new Error('Unknown authentication type: ' + auth.type); } }); }; /** * Deserializes an HTTP response body into a value of the specified type. * @param {Object} response A SuperAgent response object. * @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: * all properties on <code>data<code> will be converted to this type. * @returns A value of the specified type. */ exports.prototype.deserialize = function deserialize(response, returnType) { if (response == null || returnType == null) { return null; } // Rely on SuperAgent for parsing response body. // See http://visionmedia.github.io/superagent/#parsing-response-bodies var data = response.body; if (data == null) { // SuperAgent does not always produce a body; use the unparsed response as a fallback data = response.text; } return exports.convertToType(data, returnType); }; /** * Callback function to receive the result of the operation. * @callback module:ApiClient~callApiCallback * @param {String} error Error message, if any. * @param data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Invokes the REST service using the supplied settings and parameters. * @param {String} path The base URL to invoke. * @param {String} httpMethod The HTTP method to use. * @param {Object.<String, String>} pathParams A map of path parameters and their values. * @param {Object.<String, Object>} queryParams A map of query parameters and their values. * @param {Object.<String, Object>} headerParams A map of header parameters and their values. * @param {Object.<String, Object>} formParams A map of form parameters and their values. * @param {Object} bodyParam The value to pass as the request body. * @param {Array.<String>} authNames An array of authentication type names. * @param {Array.<String>} contentTypes An array of request MIME types. * @param {Array.<String>} accepts An array of acceptable response MIME types. * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the * constructor for a complex type. * @param {module:ApiClient~callApiCallback} callback The callback function. * @returns {Object} The SuperAgent request object. */ exports.prototype.callApi = function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, callback) { var _this = this; var url = this.buildUrl(path, pathParams); var request = superagent(httpMethod, url); // apply authentications this.applyAuthToRequest(request, authNames); // set query parameters request.query(this.normalizeParams(queryParams)); // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); // set request timeout request.timeout(this.timeout); var contentType = this.jsonPreferredMime(contentTypes); if (contentType) { // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746) if(contentType != 'multipart/form-data') { request.type(contentType); } } else if (!request.header['Content-Type']) { request.type('application/json'); } if (contentType === 'application/x-www-form-urlencoded') { request.send(this.normalizeParams(formParams)); } else if (contentType == 'multipart/form-data') { var _formParams = this.normalizeParams(formParams); for (var key in _formParams) { if (_formParams.hasOwnProperty(key)) { if (this.isFileParam(_formParams[key])) { // file field request.attach(key, _formParams[key]); } else { request.field(key, _formParams[key]); } } } } else if (bodyParam) { request.send(bodyParam); } var accept = this.jsonPreferredMime(accepts); if (accept) { request.accept(accept); } request.end(function(error, response) { if (callback) { var data = null; if (!error) { data = _this.deserialize(response, returnType); } callback(error, data, response); } }); return request; }; /** * Parses an ISO-8601 string representation of a date value. * @param {String} str The date value as a string. * @returns {Date} The parsed date object. */ exports.parseDate = function(str) { return new Date(str.replace(/T/i, ' ')); }; /** * Converts a value to the specified type. * @param {(String|Object)} data The data to convert, as a string or object. * @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: * all properties on <code>data<code> will be converted to this type. * @returns An instance of the specified type. */ exports.convertToType = function(data, type) { switch (type) { case 'Boolean': return Boolean(data); case 'Integer': return parseInt(data, 10); case 'Number': return parseFloat(data); case 'String': return String(data); case 'Date': return this.parseDate(String(data)); default: if (type === Object) { // generic object, return directly return data; } else if (typeof type === 'function') { // for model type like: User return type.constructFromObject(data); } else if (Array.isArray(data)) { // for array type like: ['String'] var itemType = type[0]; return data.map(function(item) { return exports.convertToType(item, itemType); }); } else if (typeof type === 'object') { // for plain object type like: {'String': 'Integer'} var keyType, valueType; for (var k in type) { if (type.hasOwnProperty(k)) { keyType = k; valueType = type[k]; break; } } var result = {}; for (var k in data) { if (data.hasOwnProperty(k)) { var key = exports.convertToType(k, keyType); var value = exports.convertToType(data[k], valueType); result[key] = value; } } return result; } else { // for unknown type, return the data directly return data; } } }; /** * Constructs a new map or array model from REST data. * @param data {Object|Array} The REST data. * @param obj {Object|Array} The target object or array. */ exports.constructFromObject = function(data, obj, itemType) { if (Array.isArray(data)) { for (var i = 0; i < data.length; i++) { if (data.hasOwnProperty(i)) obj[i] = exports.convertToType(data[i], itemType); } } else { for (var k in data) { if (data.hasOwnProperty(k)) obj[k] = exports.convertToType(data[k], itemType); } } }; /** * The default API client implementation. * @type {module:ApiClient} */ exports.instance = new exports(); return exports; })); }).call(this,require("buffer").Buffer) },{"buffer":12,"fs":11,"superagent":17}],2:[function(require,module,exports){ /** * 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/Event'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('../model/Event')); } else { // Browser globals (root is window) if (!root.TeSsApi) { root.TeSsApi = {}; } root.TeSsApi.EventsApi = factory(root.TeSsApi.ApiClient, root.TeSsApi.Event); } }(this, function(ApiClient, Event) { 'use strict'; /** * Events service. * @module api/EventsApi * @version 1.0.0 */ /** * Constructs a new EventsApi. * @alias module:api/EventsApi * @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 eventsJsonGet operation. * @callback module:api/EventsApi~eventsJsonGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/Event>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Search over the collection of events * The base endpoint (events.json) returns the first page of events as seen on the UI (if you just go to &lt;tess&gt;/events). To navigate through and filter by attributes; use the below parameters. The returned value is an array of JSON objects described below. * @param {Object} opts Optional parameters * @param {String} opts.q This is the search parameter. Enter terms and the resulting events will be those that include this term in their description, name, keywords, or URL. * @param {Boolean} opts.includeExpired When true; the results will return include events that have already occured. By default this is false and will only return upcoming events. * @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). * @param {Number} opts.page Selects which page of results to return (e.g. 2) * @param {Array.<String>} opts.eventTypes Returns all events of a categorical type. These can be &#39;Meetings and conferences&#39; and &#39;Workshops and courses&#39; * @param {Boolean} opts.online Filters returned events by whether or not is an online event. This can include things like telecons, webinars, and MOOCs. * @param {Array.<String>} opts.country Returns all the events that will be hosted in a certain country (e.g. Portugal or United Kingdom) * @param {Array.<String>} opts.scientificTopics Returns all events annotated with a given scientific topic from the EDAM ontology. * @param {String} opts.tools Returns all events that have been associated with a given tool from the ELIXIR bio.tools registry. * @param {String} opts.standardDatabaseOrPolicy returns all events that have been associated with a database, standard, or policy from the ELIXIR biosharing.org registry * @param {Array.<String>} opts.organizer Returns all events that have been created by an organizing institution. This is different to content provider in that the content provider is the website that provided the information whereas the organizer was involved in creating it. * @param {Array.<String>} opts.city Returns all the events that are held in a certain city (e.g. London or Daghstul) * @param {Array.<String>} opts.sponsor Returns all the events that have been sponsored by a given institution or organization * @param {Array.<String>} opts.keyword Returns all the events that have been tagged with the given free text keywords * @param {Array.<String>} opts.contentProvider Returns all events from the content provider that provided records to TeSS (e.g. DTLS, GOBLET, Software Carpentry) * @param {Array.<String>} opts.venue Returns all events that are held in a venue (e.g. University of Melbourne or Harvard) * @param {Array.<String>} opts.node Returns all events that are associated with a specified ELIXIR node (e.g. Belgium or United+Kingdom) * @param {Array.<String>} opts.targetAudience Returns all events that have a selected target audience (e.g. Graduate students, Academics, Post-Docs) * @param {module:api/EventsApi~eventsJsonGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/Event>} */ this.eventsJsonGet = function(opts, callback) { opts = opts || {}; var postBody = null; var pathParams = { }; var queryParams = { 'q': opts['q'], 'include_expired': opts['includeExpired'], 'sort': opts['sort'], 'page': opts['page'], 'event_types': this.apiClient.buildCollectionParam(opts['eventTypes'], 'multi'), 'online': opts['online'], 'country': this.apiClient.buildCollectionParam(opts['country'], 'multi'), 'scientific_topics': this.apiClient.buildCollectionParam(opts['scientificTopics'], 'multi'), 'tools': opts['tools'], 'standard_database_or_policy': opts['standardDatabaseOrPolicy'], 'organizer': this.apiClient.buildCollectionParam(opts['organizer'], 'multi'), 'city': this.apiClient.buildCollectionParam(opts['city'], 'multi'), 'sponsor': this.apiClient.buildCollectionParam(opts['sponsor'], 'multi'), 'keyword': this.apiClient.buildCollectionParam(opts['keyword'], 'multi'), 'content_provider': this.apiClient.buildCollectionParam(opts['contentProvider'], 'multi'), 'venue': this.apiClient.buildCollectionParam(opts['venue'], 'multi'), 'node': this.apiClient.buildCollectionParam(opts['node'], 'multi'), 'target_audience': this.apiClient.buildCollectionParam(opts['targetAudience'], 'multi') }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = []; var accepts = ['application/json']; var returnType = [Event]; return this.apiClient.callApi( '/events.json', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } /** * Callback function to receive the result of the eventsSlugJsonGet operation. * @callback module:api/EventsApi~eventsSlugJsonGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/Event>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get all the information stored about a particular event in TeSS. * Use the slug name of the event (lowercase hypenathed) to return a JSON object. e.g. https://tess.elixir-europe.org/events/software-carpentry-229th-aas-meeting.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} slug The _slug_ id of an event e.g. software-carpentry-229th-aas-meeting * @param {module:api/EventsApi~eventsSlugJsonGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/Event>} */ this.eventsSlugJsonGet = function(slug, callback) { var postBody = null; // verify the required parameter 'slug' is set if (slug == undefined || slug == null) { throw new Error("Missing the required parameter 'slug' when calling eventsSlugJsonGet"); } var pathParams = { 'slug': slug }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = []; var accepts = ['application/json']; var returnType = [Event]; return this.apiClient.callApi( '/events/{slug}.json', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } }; return exports; })); },{"../ApiClient":1,"../model/Event":4}],3:[function(require,module,exports){ /** * 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; })); },{"../ApiClient":1,"../model/Material":6,"../model/ShortMaterial":9}],4:[function(require,module,exports){ /** * 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/ScientificTopic'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('./ScientificTopic')); } else { // Browser globals (root is window) if (!root.TeSsApi) { root.TeSsApi = {}; } root.TeSsApi.Event = factory(root.TeSsApi.ApiClient, root.TeSsApi.ScientificTopic); } }(this, function(ApiClient, ScientificTopic) { 'use strict'; /** * The Event model module. * @module model/Event * @version 1.0.0 */ /** * Constructs a new <code>Event</code>. * @alias module:model/Event * @class */ var exports = function() { var _this = this; }; /** * Constructs a <code>Event</code> from a plain JavaScript object, optionally creating a new instance. * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not. * @param {Object} data The plain JavaScript object bearing properties of interest. * @param {module:model/Event} obj Optional instance to populate. * @return {module:model/Event} The populated <code>Event</code> instance. */ exports.constructFromObject = function(data, obj) { if (data) { obj = obj || new exports(); if (data.hasOwnProperty('id')) { obj['id'] = ApiClient.convertToType(data['id'], 'Number'); } if (data.hasOwnProperty('title')) { obj['title'] = ApiClient.convertToType(data['title'], 'String'); } if (data.hasOwnProperty('subtitle')) { obj['subtitle'] = ApiClient.convertToType(data['subtitle'], 'String'); } if (data.hasOwnProperty('url')) { obj['url'] = ApiClient.convertToType(data['url'], 'String'); } if (data.hasOwnProperty('organizer')) { obj['organizer'] = ApiClient.convertToType(data['organizer'], 'String'); } if (data.hasOwnProperty('description')) { obj['description'] = ApiClient.convertToType(data['description'], 'String'); } if (data.hasOwnProperty('start')) { obj['start'] = ApiClient.convertToType(data['start'], 'Date'); } if (data.hasOwnProperty('end')) { obj['end'] = ApiClient.convertToType(data['end'], 'Date'); } if (data.hasOwnProperty('sponsor')) { obj['sponsor'] = ApiClient.convertToType(data['sponsor'], 'String'); } if (data.hasOwnProperty('venue')) { obj['venue'] = ApiClient.convertToType(data['venue'], 'String'); } if (data.hasOwnProperty('city')) { obj['city'] = ApiClient.convertToType(data['city'], 'String'); } if (data.hasOwnProperty('country')) { obj['country'] = ApiClient.convertToType(data['country'], 'String'); } if (data.hasOwnProperty('county')) { obj['county'] = ApiClient.convertToType(data['county'], 'String'); } if (data.hasOwnProperty('postcode')) { obj['postcode'] = ApiClient.convertToType(data['postcode'], 'String'); } if (data.hasOwnProperty('latitude')) { obj['latitude'] = ApiClient.convertToType(data['latitude'], 'String'); } if (data.hasOwnProperty('longitude')) { obj['longitude'] = ApiClient.convertToType(data['longitude'], 'String'); } if (data.hasOwnProperty('created_at')) { obj['created_at'] = ApiClient.convertToType(data['created_at'], 'Date'); } if (data.hasOwnProperty('updated_at')) { obj['updated_at'] = ApiClient.convertToType(data['updated_at'], 'Date'); } if (data.hasOwnProperty('keywords')) { obj['keywords'] = ApiClient.convertToType(data['keywords'], ['String']); } if (data.hasOwnProperty('event_types')) { obj['event_types'] = ApiClient.convertToType(data['event_types'], ['String']); } if (data.hasOwnProperty('target_audience')) { obj['target_audience'] = ApiClient.convertToType(data['target_audience'], ['String']); } if (data.hasOwnProperty('capacity')) { obj['capacity'] = ApiClient.convertToType(data['capacity'], ['String']); } if (data.hasOwnProperty('eligibility')) { obj['eligibility'] = ApiClient.convertToType(data['eligibility'], ['String']); } if (data.hasOwnProperty('contact')) { obj['contact'] = ApiClient.convertToType(data['contact'], 'String'); } if (data.hasOwnProperty('host_institutions')) { obj['host_institutions'] = ApiClient.convertToType(data['host_institutions'], ['String']); } if (data.hasOwnProperty('scientific_topics')) { obj['scientific_topics'] = ApiClient.convertToType(data['scientific_topics'], [ScientificTopic]); } } return obj; } /** * Unique identifier of the event * @member {Number} id */ exports.prototype['id'] = undefined; /** * The title of the event * @member {String} title */ exports.prototype['title'] = undefined; /** * The subtitle of the event * @member {String} subtitle */ exports.prototype['subtitle'] = undefined; /** * The URL where the actual event can be found. * @member {String} url */ exports.prototype['url'] = undefined; /** * The organization responsible for creating the event. * @member {String} organizer */ exports.prototype['organizer'] = undefined; /** * A succinct description of what the event is about. * @member {String} description */ exports.prototype['description'] = undefined; /** * The date and time the event starts on * @member {Date} start */ exports.prototype['start'] = undefined; /** * The date and time the event ends on. * @member {Date} end */ exports.prototype['end'] = undefined; /** * The person or organization that is sponsoring the event. * @member {String} sponsor */ exports.prototype['sponsor'] = undefined; /** * The name of the building the event will be hosted in * @member {String} venue */ exports.prototype['venue'] = undefined; /** * The city the event will be hosted in * @member {String} city */ exports.prototype['city'] = undefined; /** * The regional county the event will be hosted in * @member {String} country */ exports.prototype['country'] = undefined; /** * The name of country the event will be hosted in * @member {String} county */ exports.prototype['county'] = undefined; /** * The postcode of the venue hosting the event * @member {String} postcode */ exports.prototype['postcode'] = undefined; /** * The latitude co-ordinate of the event. * @member {String} latitude */ exports.prototype['latitude'] = undefined; /** * The longitude co-ordinate of the event. * @member {String} longitude */ exports.prototype['longitude'] = undefined; /** * The date the event was first created on TeSS * @member {Date} created_at */ exports.prototype['created_at'] = undefined; /** * The date the event was last updated on TeSS * @member {Date} updated_at */ exports.prototype['updated_at'] = undefined; /** * A series of freetext words used to describe an event. * @member {Array.<String>} keywords */ exports.prototype['keywords'] = undefined; /** * The category of the event. This could be a meeting or a course; or if unknown or neither, an event * @member {Array.<String>} event_types */ exports.prototype['event_types'] = undefined; /** * The intended audience of the event. This can includes things like scientific discpline and expertise level * @member {Array.<String>} target_audience */ exports.prototype['target_audience'] = undefined; /** * The number of people allowed to attend the event * @member {Array.<String>} capacity */ exports.prototype['capacity'] = undefined; /** * Various criteria require to participate in the event * @member {Array.<String>} eligibility */ exports.prototype['eligibility'] = undefined; /** * The name and/or contact details of a person or institution organizing the event * @member {String} contact */ exports.prototype['contact'] = undefined; /** * The institution physically hosting the event * @member {Array.<String>} host_institutions */ exports.prototype['host_institutions'] = undefined; /** * The classification of the material based on the EDAM ontologies scientific topics. * @member {Array.<module:model/ScientificTopic>} scientific_topics */ exports.prototype['scientific_topics'] = undefined; return exports; })); },{"../ApiClient":1,"./ScientificTopic":7}],5:[function(require,module,exports){ /** * 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: