Created
November 22, 2016 23:47
-
-
Save Dellybro/540720d72971c2dfba4c3e8c5068ef79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
intersection: function(array1, array2) { | |
var returnedArray = []; | |
for (var i = 0; i < array1.length; i++) { | |
if(array2.includes(array1[i])){ | |
returnedArray.push(array1[i]); | |
} | |
} | |
return returnedArray; | |
}, | |
isSubset: function(containingArray, isSubsetArray){ | |
if(containingArray.length < isSubsetArray.length){ | |
return false; | |
} | |
for (var i = 0; i < isSubsetArray.length; i++) { | |
if(!containingArray.includes(isSubsetArray[i])){ | |
return false; | |
} | |
} | |
return true; | |
}, | |
paramsRequire: function(dictionary, array2){ | |
array1 = Object.keys(dictionary); | |
var returnedArray = []; | |
for (var i = 0; i < array1.length; i++) { | |
if(array2.includes(array1[i])){ | |
returnedArray.push(array1[i]); | |
} | |
} | |
var params = {}; | |
for(var x = 0; x < returnedArray.length; x++){ | |
params[returnedArray[x]] = dictionary[returnedArray[x]]; | |
} | |
return params; | |
}, | |
makeId: function(length){ | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < length; i++ ) | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
return text; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var companyParamsRequirements = [ | |
"name", | |
"billing_address", | |
"billing_zip", | |
"billing_city", | |
"billing_street", | |
"billing_state", | |
"billing_suite", | |
"contactFirstName", | |
"contactLastName", | |
"fourDigitPin", | |
"numberOfEmployees", | |
"contactEmail", | |
"showBilling", | |
"email", | |
"company_name", | |
"contactId", | |
"phoneNumber", | |
"address", | |
"suite", | |
"state", | |
"city", | |
"zip", | |
"logoURL", | |
"rate1", | |
"rate2", | |
"callingPin", | |
"authNetId", | |
"held" | |
] | |
var allowedParameters = Scripts.paramsRequire(req.body, companyParamsRequirements); | |
var company = models.Company.create(allowedParameters).then(function(company){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment