UNPKG

streamer-client

Version:

A node.js client for the Duke OIT Streamer API

36 lines (30 loc) 1.14 kB
var Dispatcher = require('./dispatcher'); var resources = require('./resources'); /** * Constructs a Client with instances of all the resources using the dispatcher. * It also keeps a reference to the dispatcher so that way the end user can have * access to it. * @class * @classdesc A wrapper for the Streamer API which is authenticated for one user * @param {Dispatcher} dispatcher The request dispatcher to use */ function Client(dispatcher) { /** * The internal dispatcher. This is mostly used by the resources but provided * for custom requests to the API or API features that have not yet been added * to the client. * @type {Dispatcher} */ this.dispatcher = dispatcher; this.curriculum = new resources.Curriculum(this.dispatcher); } /** * Creates a Client for a user using that user's API Key and then authenticates * through HTTP Basic Authentication. * @param {String} apiKey The Asana Api Key of the user * @return {Client} The instantiated client */ Client.basicAuth = function(apiKey) { return new Client(new Dispatcher('access_token', apiKey)); }; module.exports = Client;