Login   Register  
Icontem

File: example/example.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jonathan Gotti  >  Node.js Promise Redmine  >  example/example.js  >  Download  
File: example/example.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Node.js Promise Redmine
Access Redmine API using Node.js and promises
Author: By
Last change:
Date: 2014-02-03 15:16
Size: 1,041 bytes
 

Contents

Class file image Download
var Redmine = require('../lib/redmine');

var redmine = new Redmine({
	host: 'redmine host',
	apiKey: 'redmine api key',
});


// get issue
redmine.getIssues({project_id: 1})
	.then(function(data) {
		console.log("Issues:");
		console.log(data);
	},
	function(err) {
		console.log("Error: " + err.message);
		return;
	}
);


// create issue
var issue = {
	project_id: 1,
	subject: "This is test issue on " + Date.now(),
	description: "Test issue description"
};
redmine.postIssue(issue)
	.error(function(err) {
		console.log("Error: " + err.message);
	})
	.success(function(data) {
		console.log(data);
	})
;

// update issue
var issueId = 4; // exist id
var issueUpdate = {
	notes: "this is comment"
};
redmine.updateIssue(issueId, issueUpdate)
	.sucess(function(data) {
		console.log(data);
	})
	.rethrow(function(err) {
		console.log("Error: " + err.message);
	})
;

// delte issue
var issueId = 4;
redmine.deleteIssue(issueId)
	.then(function(data){
		console.log(data);
	},
	function(err) {
		console.log("Error: " + err.message);
	}
);