This commit is contained in:
@@ -12,383 +12,445 @@
|
||||
/*global $, io, app */
|
||||
|
||||
app.api = (function () {
|
||||
"use strict";
|
||||
var initModule,
|
||||
getAuthHeaderObject,
|
||||
RockFishVersion,
|
||||
get,
|
||||
remove,
|
||||
create,
|
||||
update,
|
||||
uploadFile,
|
||||
putAction,
|
||||
postAction,
|
||||
createLicense,
|
||||
createRavLicense,
|
||||
getLicenseRequests,
|
||||
generateFromRequest,
|
||||
licenseEmailResponse;
|
||||
"use strict";
|
||||
var initModule,
|
||||
getAuthHeaderObject,
|
||||
RockFishVersion,
|
||||
get,
|
||||
remove,
|
||||
create,
|
||||
update,
|
||||
uploadFile,
|
||||
putAction,
|
||||
postAction,
|
||||
createLicense,
|
||||
createRavLicense,
|
||||
getLicenseRequests,
|
||||
generateFromRequest,
|
||||
licenseEmailResponse,
|
||||
test;
|
||||
|
||||
RockFishVersion = "6.20";
|
||||
RockFishVersion = "6.20";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOT AUTHORIZED ERROR HANDLER
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOT AUTHORIZED ERROR HANDLER
|
||||
|
||||
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
|
||||
//unauthorized? Trigger logout which will trigger login after clearing creds
|
||||
if (jqxhr.status == 401) {
|
||||
window.location.replace("#!/logout");
|
||||
}
|
||||
});
|
||||
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
|
||||
//unauthorized? Trigger logout which will trigger login after clearing creds
|
||||
if (jqxhr.status == 401) {
|
||||
window.location.replace("#!/logout");
|
||||
}
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// UTILITY
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// UTILITY
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Return the auth token header
|
||||
//
|
||||
//
|
||||
getAuthHeaderObject = function () {
|
||||
return {
|
||||
Authorization: "Bearer " + app.shell.stateMap.user.token
|
||||
///////////////////////////////////////////////////////////
|
||||
// Return the auth token header
|
||||
//
|
||||
//
|
||||
getAuthHeaderObject = function () {
|
||||
return {
|
||||
Authorization: "Bearer " + app.shell.stateMap.user.token
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// ROCKFISH CORE ROUTES
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// ROCKFISH CORE ROUTES
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//Create
|
||||
//Route app.post('/api/:obj_type/create', function (req, res) {
|
||||
//
|
||||
create = function (apiRoute, objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//Create
|
||||
//Route app.post('/api/:obj_type/create', function (req, res) {
|
||||
//
|
||||
create = function (apiRoute, objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/////////////////
|
||||
//Get - get anything, the caller provides the route, this should replace most legacy get
|
||||
//
|
||||
get = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
/////////////////
|
||||
//Get - get anything, the caller provides the route, this should replace most legacy get
|
||||
//
|
||||
get = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
////////////////////
|
||||
};
|
||||
////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//Update
|
||||
//route: app.post('/api/:obj_type/update/:id', function (req, res) {
|
||||
//
|
||||
update = function (objType, objData, callback) {
|
||||
var theId;
|
||||
if (!objData.id) {
|
||||
return callback({
|
||||
error: 1,
|
||||
msg: "app.api.js::update->Error: missing id field in update document",
|
||||
error_detail: objData
|
||||
});
|
||||
}
|
||||
theId = objData.id;
|
||||
$.ajax({
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + objType + "/" + theId,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
///////////////////////////////////////////////////////////
|
||||
//Update
|
||||
//route: app.post('/api/:obj_type/update/:id', function (req, res) {
|
||||
//
|
||||
update = function (objType, objData, callback) {
|
||||
var theId;
|
||||
if (!objData.id) {
|
||||
return callback({
|
||||
error: 1,
|
||||
msg: "app.api.js::update->Error: missing id field in update document",
|
||||
error_detail: objData
|
||||
});
|
||||
}
|
||||
theId = objData.id;
|
||||
$.ajax({
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + objType + "/" + theId,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
}
|
||||
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//remove Item
|
||||
remove = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "DELETE",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//remove Item
|
||||
remove = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "DELETE",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// uploadFile
|
||||
// (ajax route to upload a file)
|
||||
//
|
||||
uploadFile = function (apiRoute, objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: objData,
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
// uploadFile
|
||||
// (ajax route to upload a file)
|
||||
//
|
||||
uploadFile = function (apiRoute, objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: objData,
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//putAction - ad-hoc put method used to trigger actions etc
|
||||
//
|
||||
putAction = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
//data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
//putAction - ad-hoc put method used to trigger actions etc
|
||||
//
|
||||
putAction = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
//data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
}
|
||||
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//postAction - ad-hoc post method used to trigger actions etc
|
||||
// (becuase it shouldn't have been put in the first place above)
|
||||
postAction = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
//postAction - ad-hoc post method used to trigger actions etc
|
||||
// (becuase it shouldn't have been put in the first place above)
|
||||
postAction = function (apiRoute, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success: function (data, textStatus) {
|
||||
if (data == null) {
|
||||
data = { ok: 1 };
|
||||
}
|
||||
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg:
|
||||
textStatus +
|
||||
"\n" +
|
||||
jqXHR.responseText +
|
||||
"\n" +
|
||||
errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// LICENSE KEY RELATED API METHODS
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// LICENSE KEY RELATED API METHODS
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//CreateLicense
|
||||
//Route app.post('/api/license/create', function (req, res) {
|
||||
//
|
||||
createLicense = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "license/generate",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//CreateLicense
|
||||
//Route app.post('/api/license/create', function (req, res) {
|
||||
//
|
||||
createLicense = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "license/generate",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//CreateRavLicense
|
||||
//Route app.post('/api/license/create', function (req, res) {
|
||||
//
|
||||
createRavLicense = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "rvl",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//CreateRavLicense
|
||||
//Route app.post('/api/license/create', function (req, res) {
|
||||
//
|
||||
createRavLicense = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "rvl",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//GetLicenseRequests
|
||||
//Fetch license requests
|
||||
//route: app.get('/api/license/requests', function (req, res) {
|
||||
//
|
||||
getLicenseRequests = function (callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + "license/requests",
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//GetLicenseRequests
|
||||
//Fetch license requests
|
||||
//route: app.get('/api/license/requests', function (req, res) {
|
||||
//
|
||||
getLicenseRequests = function (callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + "license/requests",
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//GenerateFromRequest
|
||||
//Fetch generated response to license request
|
||||
//route: app.get('/api/license/generateFromRequest/:uid', function (req, res) {
|
||||
//
|
||||
generateFromRequest = function (uid, callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + "license/generateFromRequest/" + uid,
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//GenerateFromRequest
|
||||
//Fetch generated response to license request
|
||||
//route: app.get('/api/license/generateFromRequest/:uid', function (req, res) {
|
||||
//
|
||||
generateFromRequest = function (uid, callback) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
url:
|
||||
app.shell.stateMap.apiUrl +
|
||||
"license/generateFromRequest/" +
|
||||
uid,
|
||||
headers: getAuthHeaderObject(),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//Email license request response
|
||||
//app.post('/api/license/email_response', function (req, res) {
|
||||
//
|
||||
licenseEmailResponse = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "license/email_response",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
///////////////////////////////////////////////////////////
|
||||
//Email license request response
|
||||
//app.post('/api/license/email_response', function (req, res) {
|
||||
//
|
||||
licenseEmailResponse = function (objData, callback) {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "text",
|
||||
url: app.shell.stateMap.apiUrl + "license/email_response",
|
||||
headers: getAuthHeaderObject(),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data, textStatus) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
initModule = function () {};
|
||||
///////////////////////////////////////////////////////////
|
||||
//test functin for rockfish endpoint testing
|
||||
//
|
||||
//
|
||||
test = function (objData, callback) {
|
||||
//Test fake shareit webhook
|
||||
$.ajax({
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
url: app.shell.stateMap.apiUrl + "order/shareit",
|
||||
username: 'Y24PYYDQSA1L12905N5MKU',
|
||||
password: 'MA8GMQK2PC3FDNT1RTR68R',
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(objData),
|
||||
success: function (data) {
|
||||
callback(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
initModule: initModule,
|
||||
getAuthHeaderObject: getAuthHeaderObject,
|
||||
RockFishVersion: RockFishVersion,
|
||||
get: get,
|
||||
remove: remove,
|
||||
create: create,
|
||||
update: update,
|
||||
uploadFile: uploadFile,
|
||||
putAction: putAction,
|
||||
postAction: postAction,
|
||||
createLicense: createLicense,
|
||||
createRavLicense: createRavLicense,
|
||||
getLicenseRequests: getLicenseRequests,
|
||||
generateFromRequest: generateFromRequest,
|
||||
licenseEmailResponse: licenseEmailResponse
|
||||
};
|
||||
initModule = function () {};
|
||||
|
||||
return {
|
||||
initModule: initModule,
|
||||
getAuthHeaderObject: getAuthHeaderObject,
|
||||
RockFishVersion: RockFishVersion,
|
||||
get: get,
|
||||
remove: remove,
|
||||
create: create,
|
||||
update: update,
|
||||
uploadFile: uploadFile,
|
||||
putAction: putAction,
|
||||
postAction: postAction,
|
||||
createLicense: createLicense,
|
||||
createRavLicense: createRavLicense,
|
||||
getLicenseRequests: getLicenseRequests,
|
||||
generateFromRequest: generateFromRequest,
|
||||
licenseEmailResponse: licenseEmailResponse,
|
||||
test: test
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user