forked from Copyleaks/NodeJS-Plagiarism-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_test.js
141 lines (111 loc) · 3.58 KB
/
local_test.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
var CopyleaksCloud = require('./src/Components/CopyleaksCloud.js');
var _ = require('lodash');
var clCloud = new CopyleaksCloud();
var config = clCloud.getConfig();
var email = '<YOUR-EMAIL>';
var apikey = '<YOUR-API-KEY>';
/*TEST SERVER*/
var http = require("http");
var server = http.createServer();
server.listen(8005,'127.0.0.1',function(){
/*
LOGIN ACCEPTS 1 PARAMETER (type of product).
ACCEPTED TYPES:
1. publisher
2. academy
CONFIG HAS CONSTANTS FOR ACCEPTED TYPES:
1. config.E_PRODUCT.PUBLISHER
2. config.E_PRODUCT.ACADEMY
*/
clCloud.login(email,apikey,config.E_PRODUCT.PUBLISHER,callback);
function callback(resp,err){
//CHECK CREDIT BALANCE FOR YOUR ACCOUNT
/*
clCloud.getCreditBalance(function(resp,err){
//check if we have credits
if(resp && resp.Amount){
console.log('You have this amount of credits left: '+resp.Amount);
}
});
*/
/*
Check if token still valid:
clCloud.loginToken.validateToken() //return true \ false
*/
var _customHeaders = {};
_customHeaders[config.SANDBOX_MODE_HEADER] = true;
//_customHeaders[config.HTTP_CALLBACK] = 'http://example.com/callback-path';
// See more custom-options @ https://api.copyleaks.com/Documentation/RequestHeaders
//create-by-url
var url = 'https://www.copyleaks.com'; // URL to scan
clCloud.createByURL(url,_customHeaders,function(resp,err){
//check if we have credits
if(resp && resp.ProcessId){
console.log('API: create-by-url');
console.log('Process has been created: '+resp.ProcessId);
}
});
//create-by-file example
/*
var _file = __dirname+'/tests/1.pdf';
clCloud.createByFile(_file,_customHeaders,function(resp,err){
//check if we have credits
if(resp && resp.ProcessId){
console.log('API: create-by-file');
console.log('Process has been created: '+resp.ProcessId);
}
});
*/
//create-by-file-ocr example
/*
var language = 'English';
var _ocrFile = __dirname+'/tests/2000px-PDCA_Cycle.svg.png';
clCloud.createByFileOCR(_ocrFile,_customHeaders,language,function(resp,err){
//check if we have credits
if(resp && resp.ProcessId){
console.log('API: create-by-file-ocr');
console.log('Process has been created: '+resp.ProcessId);
}
});
*/
//create-by-text
/*
clCloud.createByText('<PUT YOUR TEXT HERE>',_customHeaders,function(resp,err){
//check if we have credits
if(resp && resp.ProcessId){
console.log('API: create-by-text');
console.log('Process has been created: '+resp.ProcessId);
}
});
*/
//get processes list api
clCloud.getProcessList(function(resp,err){
//check if we have credits
if(resp && resp.length > 0){
console.log('API: processes list');
console.log('There are '+resp.length+' processes running:');
_.forIn(resp,function(pval,pk){
console.log(pval.ProcessId);
});
}
});
//example for process getStatus,getResults & delete
//var _pid = '<YOUR_PID_HERE>';
/* Get process status exmaple */
//clCloud.getProcessStatus(_pid,function(resp,err){
// console.log(resp);
//});
/* Get process results example */
//clCloud.getProcessResults(_pid,function(resp,err){
// console.log(resp);
//});
/* Delete process example */
//clCloud.deleteProcess(_pid,function(resp,err){
// console.log(resp);
//});
}
server.close();
});
process.on("exit", function() {
console.log('Closed process');
});