lib/client.js
function client (root) {
	return {

		tasks: {

			// Create a new task
			create: function (task, done) {
				post(root + 'tasks', task, done);
			},

			// Get all tasks
			get: function (query, done) {
				get(root + 'tasks', query, done);
			},

			// Get results for all tasks
			results: function (query, done) {
				get(root + 'tasks/results', query, done);
			}

		},

		task: function (id) {
			return {

				// Get a task
				get: function (query, done) {
					get(root + 'tasks/' + id, query, done);
				},

				// Edit a task
				edit: function (edits, done) {
					patch(root + 'tasks/' + id, edits, done);
				},

				// Remove a task
				remove: function (done) {
					del(root + 'tasks/' + id, null, done);
				},

				// Run a task
				run: function (done) {
					post(root + 'tasks/' + id + '/run', null, done);
				},

				// Get results for a task
				results: function (query, done) {
					get(root + 'tasks/' + id + '/results', query, done);
				},

				result: function (rid) {
					return {

						// Get a result
						get: function (query, done) {
							get(root + 'tasks/' + id + '/results/' + rid, query, done);
						}

					};
				}

			};
		}

	};
}
function client (root) {
	return {

		tasks: {

			// Create a new task
			create: function (task, done) {
				post(root + 'tasks', task, done);
			},

			// Get all tasks
			get: function (query, done) {
				get(root + 'tasks', query, done);
			},

			// Get results for all tasks
			results: function (query, done) {
				get(root + 'tasks/results', query, done);
			}

		},

		task: function (id) {
			return {

				// Get a task
				get: function (query, done) {
					get(root + 'tasks/' + id, query, done);
				},

				// Edit a task
				edit: function (edits, done) {
					patch(root + 'tasks/' + id, edits, done);
				},

				// Remove a task
				remove: function (done) {
					del(root + 'tasks/' + id, null, done);
				},

				// Run a task
				run: function (done) {
					post(root + 'tasks/' + id + '/run', null, done);
				},

				// Get results for a task
				results: function (query, done) {
					get(root + 'tasks/' + id + '/results', query, done);
				},

				result: function (rid) {
					return {

						// Get a result
						get: function (query, done) {
							get(root + 'tasks/' + id + '/results/' + rid, query, done);
						}

					};
				}

			};
		}

	};
}
function client ( root ) { return { tasks : { // Create a new task create : function ( task , done ) { post ( root + 'tasks' , task , done ) ; } , // Get all tasks get : function ( query , done ) { get ( root + 'tasks' , query , done ) ; } , // Get results for all tasks results : function ( query , done ) { get ( root + 'tasks/results' , query , done ) ; } } , task : function ( id ) { return { // Get a task get : function ( query , done ) { get ( root + 'tasks/' + id , query , done ) ; } , // Edit a task edit : function ( edits , done ) { patch ( root + 'tasks/' + id , edits , done ) ; } , // Remove a task remove : function ( done ) { del ( root + 'tasks/' + id , null , done ) ; } , // Run a task run : function ( done ) { post ( root + 'tasks/' + id + '/run' , null , done ) ; } , // Get results for a task results : function ( query , done ) { get ( root + 'tasks/' + id + '/results' , query , done ) ; } , result : function ( rid ) { return { // Get a result get : function ( query , done ) { get ( root + 'tasks/' + id + '/results/' + rid , query , done ) ; } } ; } } ; } } ; }
Create a web-service client
Create a web - service client