{"size": 1061, "ext": "js", "max_stars_repo_path": "bunq/tree-progress.js", "max_stars_repo_name": "M4LE5/node-red-contrib-bunq", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bunq/tree-progress.js", "max_issues_repo_name": "M4LE5/node-red-contrib-bunq", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bunq/tree-progress.js", "max_forks_repo_name": "M4LE5/node-red-contrib-bunq", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.4722222222, "max_line_length": 102, "alphanum_fraction": 0.4872761546}
module.exports = function (RED) {
    'use strict';
    
	function Node(n) {
		RED.nodes.createNode(this, n);

		var bunqnode = RED.nodes.getNode(n.bunqnode);
		var node = this;

		this.on('input', function (msg, send, done) {
            send = send || function() { node.send.apply(node,arguments) }

			//preseting
			var req = {
                "method": "GET",
                "url": '/user/{userID}/tree-progress',
                "body": "",
                "options": {}
			};
            
            node.status({fill:"yellow",shape:"ring",text:"Initialization"});
            
            bunqnode.bunqInstance.API(req.method, req.url, req.body, req.options).then(function(msg) {
                if (msg.hasOwnProperty('error')) {
                    node.status({fill:"red",shape:"ring",text:"Error"});
                } else {
                    node.status({fill:"green",shape:"ring",text:"Success"});
                }
                send(msg);
            });
            done();
		});
	}

	RED.nodes.registerType("bunq-treeprogress", Node);
};