var user = require('./routes/user');
var device = require('./routes/devices');
var applications = require('./routes/applications');
var org = require('./routes/organizations');
var widgets = require('./routes/widgets');

var myrequest = require('./routes/httprequest/httprequest');


var getProxyServerUrl = function(successHandler, errorHandler) {
	var callback = function(result) {
		successHandler(result[0].name)
	};
	myrequest.sendHttpRequests('', '/v1/proxyservers', 'GET', callback, errorHandler);
};


var getNotifications = function(params, successHandler, errorHandler) {
	myrequest.sendHttpRequests('', '/v1/notifications', 'GET', successHandler, errorHandler);
};

var createNotification = function(params, successHandler, errorHandler) {
	myrequest.sendHttpRequests(params, '/v1/notifications', 'POST', successHandler, errorHandler);
};

var deleteNotification = function(params, successHandler, errorHandler) {
	myrequest.sendHttpRequests('', '/v1/notifications/' + params.token + '/' + params.noti_stat, 'DELETE', successHandler, errorHandler);
};


module.exports = {

	login: user.login,
	whoAmI: user.whoAmI,
	updateUser: user.updateUser,
	changeOrg: user.changeOrg,
	logout: user.logout,

	createOrganization: org.createOrganization,
	getOrganization: org.getOrganization,
	updateOrganization: org.updateOrganization,
	deleteOrganization: org.deleteOrganization,
	getOrganizations: org.getOrganizations,
	getUsersInOrg: org.getUsersInOrg,
	getUserRoles: org.getUserRoles,
	removeUserFromOrg: org.removeUserFromOrg,
	updateUserRoles: org.updateUserRoles,

	getDeviceTypes: device.getDeviceTypes,
	addDevice: device.addDevice,
	deleteDevice: device.deleteDevice,
	getDevices: device.getDevices,
	getDevice: device.getDevice,
	getGateways: device.getGateways,
	getPeripherals: device.getPeripherals,
	updateDevice: device.updateDevice,
	getUUIDsFromDevice: device.getUUIDsFromDevice,
	findDeviceByUUID: device.findDeviceByUUID,
	getDeviceAuthToken: device.getDeviceAuthToken,

	createTags: device.createTags,
	addTagsForDevice: device.addTagsForDevice,
	updateTagsForDevice: device.updateTagsForDevice,
	deleteTags: device.deleteTags,
	getAllTags: device.getAllTags,

	getWidgets: widgets.getWidgets,
	createWidget: widgets.createWidget,
	getWidget: widgets.getWidget,
	updateWidget: widgets.updateWidget,
	deleteWidget: widgets.deleteWidget,

	getApplications: applications.getApplications,
	updateAppFromOrg: applications.updateAppFromOrg,

	getProxyServerUrl: getProxyServerUrl,

	getNotifications: getNotifications,
	createNotification: createNotification,
	deleteNotification: deleteNotification
};

@@ -40,16 +40,17 @@
 r device
+s
  = requi
@@ -133,16 +133,26 @@
 %0Avar org
+anizations
  = requi
@@ -1236,16 +1236,26 @@
 ion: org
+anizations
 .createO
@@ -1284,24 +1284,34 @@
 ization: org
+anizations
 .getOrganiza
@@ -1336,24 +1336,34 @@
 ization: org
+anizations
 .updateOrgan
@@ -1395,16 +1395,26 @@
 ion: org
+anizations
 .deleteO
@@ -1444,24 +1444,34 @@
 zations: org
+anizations
 .getOrganiza
@@ -1492,24 +1492,34 @@
 rsInOrg: org
+anizations
 .getUsersInO
@@ -1540,16 +1540,26 @@
 les: org
+anizations
 .getUser
@@ -1588,16 +1588,26 @@
 Org: org
+anizations
 .removeU
@@ -1639,16 +1639,26 @@
 les: org
+anizations
 .updateU
@@ -1683,32 +1683,33 @@
 iceTypes: device
+s
 .getDeviceTypes,
@@ -1723,24 +1723,25 @@
 vice: device
+s
 .addDevice,%0A
@@ -1757,24 +1757,25 @@
 vice: device
+s
 .deleteDevic
@@ -1788,32 +1788,33 @@
 tDevices: device
+s
 .getDevices,%0A%09ge
@@ -1820,32 +1820,33 @@
 etDevice: device
+s
 .getDevice,%0A%09get
@@ -1857,24 +1857,25 @@
 ways: device
+s
 .getGateways
@@ -1895,24 +1895,25 @@
 rals: device
+s
 .getPeripher
@@ -1934,24 +1934,25 @@
 vice: device
+s
 .updateDevic
@@ -1977,24 +1977,25 @@
 vice: device
+s
 .getUUIDsFro
@@ -2028,16 +2028,17 @@
 : device
+s
 .findDev
@@ -2071,24 +2071,25 @@
 oken: device
+s
 .getDeviceAu
@@ -2117,16 +2117,17 @@
 : device
+s
 .createT
@@ -2156,16 +2156,17 @@
 : device
+s
 .addTags
@@ -2204,16 +2204,17 @@
 : device
+s
 .updateT
@@ -2246,16 +2246,17 @@
 : device
+s
 .deleteT
@@ -2279,16 +2279,17 @@
 : device
+s
 .getAllT

Clean up the code.