-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomainQueryMgr.js
59 lines (48 loc) · 1.86 KB
/
domainQueryMgr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var http = require('http');
var resultsArr = [];
var resultsAddedEvent;
var domainTshd = 50;
var request = require('./ExecuteRequest_http');
module.exports = {
checkDomains: function(domains, batchSize, showResponseXml, callbackFunction, errHandler) {
domainTshd = batchSize;
if (domains) {
console.log('domains to process: ' + domains.length + ' batch size: ' + domainTshd);
if (Array.isArray(domains) && domains.length > domainTshd){
var domainsTmp = domains.slice(0);
while (domainsTmp.length){
var arr = domainsTmp.splice(0,domainTshd);
// mainRequest(arr.toString(), showResponseXml);
request.ExecuteRequest(arr.toString(), getNameCheapSettings(), showResponseXml, callbackFunction, errHandler);
}
}
else
// mainRequest(domains.toString(), showResponseXml);
request.ExecuteRequest(domains.toString(), getNameCheapSettings(), showResponseXml, callbackFunction, errHandler);
}
},
results: resultsArr,
batchSize: domainTshd,
resultAddedEvt: function(evt){
resultsAddedEvent = evt;
}
}
function getNameCheapSettings() {
return {
user: 'sonicraf',
apiKey: '4ba061d21c2a49cdb1d90e87fc241aa2',
url: 'api.sandbox.namecheap.com',
query: '/xml.response?ApiUser=[USER_NAME]&ApiKey=[API_KEY]&UserName=[USER_NAME]&ClientIP=[IP]&Command=namecheap.domains.check&DomainList=[DOMAINS]',
clientIp: '198.228.201.161' // '74.66.231.216' //
}
}
function resolve(obj, propertyPath) {
if (!propertyPath) return;
var props = propertyPath.split('.');
var o = obj;
for(var i=1; i<props.length; i++) {
o = o[props[i]];
if(!o) return false;
}
return o;
}