aeremmiddleware 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -28
- package/dist/Finance/ingenicoHtml.js +114 -114
- package/package.json +21 -20
- package/src/Finance/Ingenico.types.ts +21 -21
- package/src/Finance/crimeCheck.ts +135 -135
- package/src/Finance/crimecheck.types.ts +31 -31
- package/src/Finance/encrypt.ts +18 -18
- package/src/Finance/idfy.ts +542 -542
- package/src/Finance/index.ts +13 -13
- package/src/Finance/ingenico.ts +110 -110
- package/src/Finance/ingenicoHtml.ts +119 -119
- package/src/Finance/novel.ts +226 -226
- package/src/Finance/novel.types.ts +24 -24
- package/src/Finance/qbrik.ts +822 -822
- package/src/Finance/qbrik.types.ts +81 -81
- package/src/Socials/Sms.types.ts +9 -9
- package/src/Socials/SmsSender.ts +78 -78
- package/src/Socials/Whatsapp.types.ts +95 -95
- package/src/Socials/index.ts +6 -6
- package/src/Socials/whatsApp.ts +188 -188
- package/src/index.ts +7 -7
- package/src/pushNotification/pushNotificationFCM.ts +35 -35
- package/tsconfig.json +111 -111
- package/dist/Finance/qbrik.d.ts +0 -100
- package/dist/Finance/qbrik.js +0 -506
- package/dist/Finance/qbrik.js.map +0 -1
- package/dist/Finance/qbrik.types.d.ts +0 -76
- package/dist/Finance/qbrik.types.js +0 -3
- package/dist/Finance/qbrik.types.js.map +0 -1
- package/dist/pushNotification/pushNotificationFCM.d.ts +0 -1
- package/dist/pushNotification/pushNotificationFCM.js +0 -42
- package/dist/pushNotification/pushNotificationFCM.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# README #
|
|
2
|
-
|
|
3
|
-
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
-
|
|
5
|
-
### What is this repository for? ###
|
|
6
|
-
|
|
7
|
-
* Quick summary
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
-
|
|
11
|
-
### How do I get set up? ###
|
|
12
|
-
|
|
13
|
-
* Summary of set up
|
|
14
|
-
* Configuration
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
19
|
-
|
|
20
|
-
### Contribution guidelines ###
|
|
21
|
-
|
|
22
|
-
* Writing tests
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
25
|
-
|
|
26
|
-
### Who do I talk to? ###
|
|
27
|
-
|
|
28
|
-
* Repo owner or admin
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
29
|
* Other community or team contact
|
|
@@ -2,120 +2,120 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mandateHtml = void 0;
|
|
4
4
|
const mandateHtml = (mandateData, tokenId) => {
|
|
5
|
-
return `<!DOCTYPE html>
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>Checkout Demo</title>
|
|
9
|
-
<meta name="viewport" content="user-scalable=no, width=device-width,
|
|
10
|
-
initial-scale=1" / />
|
|
11
|
-
<script
|
|
12
|
-
src="https://www.paynimo.com/paynimocheckout/client/lib/jquery.min.js"
|
|
13
|
-
type="text/javascript"
|
|
14
|
-
></script>
|
|
15
|
-
</head>
|
|
16
|
-
|
|
17
|
-
<body>
|
|
18
|
-
<button id="btnSubmit">Register Now</button>
|
|
19
|
-
|
|
20
|
-
<script
|
|
21
|
-
type="text/javascript"
|
|
22
|
-
src="https://www.paynimo.com/paynimocheckout/server/lib/checkout.js"
|
|
23
|
-
></script>
|
|
24
|
-
|
|
25
|
-
<script type="text/javascript">
|
|
26
|
-
$(document).ready(function () {
|
|
27
|
-
function handleResponse(res) {
|
|
28
|
-
if (
|
|
29
|
-
typeof res != "undefined" &&
|
|
30
|
-
typeof res.paymentMethod != "undefined" &&
|
|
31
|
-
typeof res.paymentMethod.paymentTransaction != "undefined" &&
|
|
32
|
-
typeof res.paymentMethod.paymentTransaction.statusCode !=
|
|
33
|
-
"undefined" &&
|
|
34
|
-
res.paymentMethod.paymentTransaction.statusCode == "0300"
|
|
35
|
-
) {
|
|
36
|
-
// success block
|
|
37
|
-
console.log("success block",res);
|
|
38
|
-
} else if (
|
|
39
|
-
typeof res != "undefined" &&
|
|
40
|
-
typeof res.paymentMethod != "undefined" &&
|
|
41
|
-
typeof res.paymentMethod.paymentTransaction != "undefined" &&
|
|
42
|
-
typeof res.paymentMethod.paymentTransaction.statusCode !=
|
|
43
|
-
"undefined" &&
|
|
44
|
-
res.paymentMethod.paymentTransaction.statusCode == "0398"
|
|
45
|
-
) {
|
|
46
|
-
// initiated block
|
|
47
|
-
console.log("initiate block",res);
|
|
48
|
-
} else {
|
|
49
|
-
// error block
|
|
50
|
-
console.log("error block",res);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
$(document)
|
|
55
|
-
.off("click", "#btnSubmit")
|
|
56
|
-
.on("click", "#btnSubmit", function (e) {
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
|
|
59
|
-
var reqJson = {
|
|
60
|
-
features: {
|
|
61
|
-
enableAbortResponse: true,
|
|
62
|
-
enableNewWindowFlow: true, //for hybrid applications please disable this by passing false
|
|
63
|
-
enableExpressPay: true,
|
|
64
|
-
enableMerTxnDetails: true,
|
|
65
|
-
siDetailsAtMerchantEnd: true,
|
|
66
|
-
enableSI: true,
|
|
67
|
-
},
|
|
68
|
-
consumerData: {
|
|
69
|
-
deviceId: "WEBSH2",
|
|
70
|
-
token:"${tokenId}",
|
|
71
|
-
returnUrl:
|
|
72
|
-
"https://aerem.co/", //merchant response page URL
|
|
73
|
-
responseHandler: handleResponse,
|
|
74
|
-
paymentMode: "${mandateData.paymentMode}",
|
|
75
|
-
merchantLogoUrl:
|
|
76
|
-
"https://www.paynimo.com/CompanyDocs/company-logo-vertical.png",
|
|
77
|
-
merchantId: "${mandateData.merchantId}",
|
|
78
|
-
currency: "INR",
|
|
79
|
-
consumerId: "${mandateData.consumerId}",
|
|
80
|
-
consumerMobileNo: "${mandateData.consumerMobileNo}",
|
|
81
|
-
consumerEmailId: "${mandateData.consumerEmailId}",
|
|
82
|
-
txnId: "${mandateData.txnId}",
|
|
83
|
-
|
|
84
|
-
items: [
|
|
85
|
-
{
|
|
86
|
-
itemId: "FIRST",
|
|
87
|
-
amount: "${mandateData.totalamount}",
|
|
88
|
-
comAmt: "0",
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
customStyle: {
|
|
92
|
-
PRIMARY_COLOR_CODE: "#45beaa",
|
|
93
|
-
SECONDARY_COLOR_CODE: "#FFFFFF",
|
|
94
|
-
BUTTON_COLOR_CODE_1: "#2d8c8c",
|
|
95
|
-
BUTTON_COLOR_CODE_2: "#FFFFFF",
|
|
96
|
-
},
|
|
97
|
-
accountNo: "${mandateData.accountNo}", //Pass this if accountNo is captured at merchant side for eMandate/eNACH
|
|
98
|
-
|
|
99
|
-
ifscCode: "${mandateData.ifscCode}", //Pass this if ifscCode is captured at merchant side.
|
|
100
|
-
accountType: "${mandateData.accountType}", //Required for eNACH registration this is mandatory field
|
|
101
|
-
debitStartDate: "${mandateData.debitStartDate}",
|
|
102
|
-
debitEndDate: "${mandateData.debitEndDate}",
|
|
103
|
-
maxAmount: "${mandateData.maxAmount}",
|
|
104
|
-
amountType: "${mandateData.amountType}",
|
|
105
|
-
frequency: "${mandateData.frequency}",
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
$.pnCheckout(reqJson);
|
|
110
|
-
if (reqJson.features.enableNewWindowFlow) {
|
|
111
|
-
pnCheckoutShared.openNewWindow();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
</script>
|
|
116
|
-
</body>
|
|
117
|
-
</html>
|
|
118
|
-
|
|
5
|
+
return `<!DOCTYPE html>
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>Checkout Demo</title>
|
|
9
|
+
<meta name="viewport" content="user-scalable=no, width=device-width,
|
|
10
|
+
initial-scale=1" / />
|
|
11
|
+
<script
|
|
12
|
+
src="https://www.paynimo.com/paynimocheckout/client/lib/jquery.min.js"
|
|
13
|
+
type="text/javascript"
|
|
14
|
+
></script>
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
<button id="btnSubmit">Register Now</button>
|
|
19
|
+
|
|
20
|
+
<script
|
|
21
|
+
type="text/javascript"
|
|
22
|
+
src="https://www.paynimo.com/paynimocheckout/server/lib/checkout.js"
|
|
23
|
+
></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript">
|
|
26
|
+
$(document).ready(function () {
|
|
27
|
+
function handleResponse(res) {
|
|
28
|
+
if (
|
|
29
|
+
typeof res != "undefined" &&
|
|
30
|
+
typeof res.paymentMethod != "undefined" &&
|
|
31
|
+
typeof res.paymentMethod.paymentTransaction != "undefined" &&
|
|
32
|
+
typeof res.paymentMethod.paymentTransaction.statusCode !=
|
|
33
|
+
"undefined" &&
|
|
34
|
+
res.paymentMethod.paymentTransaction.statusCode == "0300"
|
|
35
|
+
) {
|
|
36
|
+
// success block
|
|
37
|
+
console.log("success block",res);
|
|
38
|
+
} else if (
|
|
39
|
+
typeof res != "undefined" &&
|
|
40
|
+
typeof res.paymentMethod != "undefined" &&
|
|
41
|
+
typeof res.paymentMethod.paymentTransaction != "undefined" &&
|
|
42
|
+
typeof res.paymentMethod.paymentTransaction.statusCode !=
|
|
43
|
+
"undefined" &&
|
|
44
|
+
res.paymentMethod.paymentTransaction.statusCode == "0398"
|
|
45
|
+
) {
|
|
46
|
+
// initiated block
|
|
47
|
+
console.log("initiate block",res);
|
|
48
|
+
} else {
|
|
49
|
+
// error block
|
|
50
|
+
console.log("error block",res);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
$(document)
|
|
55
|
+
.off("click", "#btnSubmit")
|
|
56
|
+
.on("click", "#btnSubmit", function (e) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
|
|
59
|
+
var reqJson = {
|
|
60
|
+
features: {
|
|
61
|
+
enableAbortResponse: true,
|
|
62
|
+
enableNewWindowFlow: true, //for hybrid applications please disable this by passing false
|
|
63
|
+
enableExpressPay: true,
|
|
64
|
+
enableMerTxnDetails: true,
|
|
65
|
+
siDetailsAtMerchantEnd: true,
|
|
66
|
+
enableSI: true,
|
|
67
|
+
},
|
|
68
|
+
consumerData: {
|
|
69
|
+
deviceId: "WEBSH2",
|
|
70
|
+
token:"${tokenId}",
|
|
71
|
+
returnUrl:
|
|
72
|
+
"https://aerem.co/", //merchant response page URL
|
|
73
|
+
responseHandler: handleResponse,
|
|
74
|
+
paymentMode: "${mandateData.paymentMode}",
|
|
75
|
+
merchantLogoUrl:
|
|
76
|
+
"https://www.paynimo.com/CompanyDocs/company-logo-vertical.png",
|
|
77
|
+
merchantId: "${mandateData.merchantId}",
|
|
78
|
+
currency: "INR",
|
|
79
|
+
consumerId: "${mandateData.consumerId}",
|
|
80
|
+
consumerMobileNo: "${mandateData.consumerMobileNo}",
|
|
81
|
+
consumerEmailId: "${mandateData.consumerEmailId}",
|
|
82
|
+
txnId: "${mandateData.txnId}",
|
|
83
|
+
|
|
84
|
+
items: [
|
|
85
|
+
{
|
|
86
|
+
itemId: "FIRST",
|
|
87
|
+
amount: "${mandateData.totalamount}",
|
|
88
|
+
comAmt: "0",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
customStyle: {
|
|
92
|
+
PRIMARY_COLOR_CODE: "#45beaa",
|
|
93
|
+
SECONDARY_COLOR_CODE: "#FFFFFF",
|
|
94
|
+
BUTTON_COLOR_CODE_1: "#2d8c8c",
|
|
95
|
+
BUTTON_COLOR_CODE_2: "#FFFFFF",
|
|
96
|
+
},
|
|
97
|
+
accountNo: "${mandateData.accountNo}", //Pass this if accountNo is captured at merchant side for eMandate/eNACH
|
|
98
|
+
|
|
99
|
+
ifscCode: "${mandateData.ifscCode}", //Pass this if ifscCode is captured at merchant side.
|
|
100
|
+
accountType: "${mandateData.accountType}", //Required for eNACH registration this is mandatory field
|
|
101
|
+
debitStartDate: "${mandateData.debitStartDate}",
|
|
102
|
+
debitEndDate: "${mandateData.debitEndDate}",
|
|
103
|
+
maxAmount: "${mandateData.maxAmount}",
|
|
104
|
+
amountType: "${mandateData.amountType}",
|
|
105
|
+
frequency: "${mandateData.frequency}",
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
$.pnCheckout(reqJson);
|
|
110
|
+
if (reqJson.features.enableNewWindowFlow) {
|
|
111
|
+
pnCheckoutShared.openNewWindow();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
</script>
|
|
116
|
+
</body>
|
|
117
|
+
</html>
|
|
118
|
+
|
|
119
119
|
`;
|
|
120
120
|
};
|
|
121
121
|
exports.mandateHtml = mandateHtml;
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aeremmiddleware",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"type": "dist/index.d.ts",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"prod": "node ./build/src/index.js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"axios": "^1.5.1"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "aeremmiddleware",
|
|
3
|
+
"version": "1.0.13",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "dist/index.d.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prod": "node ./build/src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": "^1.5.1",
|
|
16
|
+
"fcm-node": "^1.6.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.8.2"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export interface MandateDataType {
|
|
2
|
-
merchantId: string;
|
|
3
|
-
txnId: string;
|
|
4
|
-
totalamount: string;
|
|
5
|
-
accountNo: string;
|
|
6
|
-
consumerId: string;
|
|
7
|
-
consumerMobileNo: string;
|
|
8
|
-
consumerEmailId: string;
|
|
9
|
-
debitStartDate: string;
|
|
10
|
-
debitEndDate: string;
|
|
11
|
-
maxAmount: string;
|
|
12
|
-
amountType: string;
|
|
13
|
-
frequency: string;
|
|
14
|
-
cardNumber?: string;
|
|
15
|
-
expMonth?: string;
|
|
16
|
-
expYear?: string;
|
|
17
|
-
cvvCode?: string;
|
|
18
|
-
paymentMode: string;
|
|
19
|
-
ifscCode: string;
|
|
20
|
-
accountType: string;
|
|
21
|
-
}
|
|
1
|
+
export interface MandateDataType {
|
|
2
|
+
merchantId: string;
|
|
3
|
+
txnId: string;
|
|
4
|
+
totalamount: string;
|
|
5
|
+
accountNo: string;
|
|
6
|
+
consumerId: string;
|
|
7
|
+
consumerMobileNo: string;
|
|
8
|
+
consumerEmailId: string;
|
|
9
|
+
debitStartDate: string;
|
|
10
|
+
debitEndDate: string;
|
|
11
|
+
maxAmount: string;
|
|
12
|
+
amountType: string;
|
|
13
|
+
frequency: string;
|
|
14
|
+
cardNumber?: string;
|
|
15
|
+
expMonth?: string;
|
|
16
|
+
expYear?: string;
|
|
17
|
+
cvvCode?: string;
|
|
18
|
+
paymentMode: string;
|
|
19
|
+
ifscCode: string;
|
|
20
|
+
accountType: string;
|
|
21
|
+
}
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import axios, { AxiosResponse } from "axios";
|
|
2
|
-
import { companyDetails, individualDetails } from "./crimecheck.types";
|
|
3
|
-
|
|
4
|
-
class CrimeSearchAPIWrapper {
|
|
5
|
-
private apiKey: string;
|
|
6
|
-
private baseUrl: string = "https://crime.getupforchange.com/api/";
|
|
7
|
-
private statusCheckEndpoint = "v3/status";
|
|
8
|
-
private addReportEndpoint = "v3/addReport";
|
|
9
|
-
private downloadAsJsonEndpoint = "v3/downloadJsonReport/";
|
|
10
|
-
private downloadAsPdfEndpoint = "v3/downloadReport/";
|
|
11
|
-
|
|
12
|
-
constructor(apiKey: string) {
|
|
13
|
-
this.apiKey = apiKey;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async checkApiStatus(): Promise<void> {
|
|
17
|
-
try {
|
|
18
|
-
const response: AxiosResponse = await axios.get(
|
|
19
|
-
this.baseUrl + this.statusCheckEndpoint,
|
|
20
|
-
{
|
|
21
|
-
headers: {
|
|
22
|
-
Authorization: this.apiKey,
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
console.log(response.data);
|
|
28
|
-
return response.data;
|
|
29
|
-
} catch (error: any) {
|
|
30
|
-
console.error(error);
|
|
31
|
-
return error.message;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async addCompanyReport(companyDetails: companyDetails): Promise<void> {
|
|
35
|
-
const bodyFormData = new FormData();
|
|
36
|
-
if (companyDetails) {
|
|
37
|
-
bodyFormData.append("companyName", companyDetails.companyName);
|
|
38
|
-
try {
|
|
39
|
-
const response: AxiosResponse = await axios.post(
|
|
40
|
-
this.baseUrl + this.addReportEndpoint,
|
|
41
|
-
companyDetails,
|
|
42
|
-
{
|
|
43
|
-
auth: {
|
|
44
|
-
username: this.apiKey,
|
|
45
|
-
password: "",
|
|
46
|
-
},
|
|
47
|
-
headers: {
|
|
48
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
console.log(response.data);
|
|
54
|
-
return response.data;
|
|
55
|
-
} catch (error: any) {
|
|
56
|
-
console.error(error);
|
|
57
|
-
return error.message;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async addIndividualReport(
|
|
63
|
-
individualDetails: individualDetails
|
|
64
|
-
): Promise<void> {
|
|
65
|
-
const bodyFormData = new FormData();
|
|
66
|
-
if (individualDetails.name) {
|
|
67
|
-
bodyFormData.append("name", individualDetails.name);
|
|
68
|
-
try {
|
|
69
|
-
const response: AxiosResponse = await axios.post(
|
|
70
|
-
this.baseUrl + this.addReportEndpoint,
|
|
71
|
-
individualDetails,
|
|
72
|
-
{
|
|
73
|
-
auth: {
|
|
74
|
-
username: this.apiKey,
|
|
75
|
-
password: "",
|
|
76
|
-
},
|
|
77
|
-
headers: {
|
|
78
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
console.log(response.data);
|
|
84
|
-
return response.data;
|
|
85
|
-
} catch (error: any) {
|
|
86
|
-
console.error(error);
|
|
87
|
-
return error.message;
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
console.log("invalid input");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async downloadAsJSON(reqId: string): Promise<any> {
|
|
95
|
-
try {
|
|
96
|
-
const response: AxiosResponse = await axios.get(
|
|
97
|
-
this.baseUrl + this.downloadAsJsonEndpoint + `${reqId}/${this.apiKey}`
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
if (response.data) {
|
|
101
|
-
console.log("File downloaded successfully");
|
|
102
|
-
console.log(response.data);
|
|
103
|
-
return response.data;
|
|
104
|
-
} else {
|
|
105
|
-
console.error("Failed to download file");
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
} catch (error: any) {
|
|
109
|
-
console.error("Error:", error.message);
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async downloadAsPDF(reqId: string): Promise<any> {
|
|
115
|
-
try {
|
|
116
|
-
const response: AxiosResponse = await axios.get(
|
|
117
|
-
this.baseUrl + this.downloadAsPdfEndpoint + `${reqId}/${this.apiKey}`
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
if (response.data) {
|
|
121
|
-
console.log("File downloaded successfully");
|
|
122
|
-
console.log(response.data);
|
|
123
|
-
return response.data;
|
|
124
|
-
} else {
|
|
125
|
-
console.error("Failed to download file");
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
} catch (error: any) {
|
|
129
|
-
console.error("Error:", error.message);
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export default CrimeSearchAPIWrapper;
|
|
1
|
+
import axios, { AxiosResponse } from "axios";
|
|
2
|
+
import { companyDetails, individualDetails } from "./crimecheck.types";
|
|
3
|
+
|
|
4
|
+
class CrimeSearchAPIWrapper {
|
|
5
|
+
private apiKey: string;
|
|
6
|
+
private baseUrl: string = "https://crime.getupforchange.com/api/";
|
|
7
|
+
private statusCheckEndpoint = "v3/status";
|
|
8
|
+
private addReportEndpoint = "v3/addReport";
|
|
9
|
+
private downloadAsJsonEndpoint = "v3/downloadJsonReport/";
|
|
10
|
+
private downloadAsPdfEndpoint = "v3/downloadReport/";
|
|
11
|
+
|
|
12
|
+
constructor(apiKey: string) {
|
|
13
|
+
this.apiKey = apiKey;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async checkApiStatus(): Promise<void> {
|
|
17
|
+
try {
|
|
18
|
+
const response: AxiosResponse = await axios.get(
|
|
19
|
+
this.baseUrl + this.statusCheckEndpoint,
|
|
20
|
+
{
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: this.apiKey,
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
console.log(response.data);
|
|
28
|
+
return response.data;
|
|
29
|
+
} catch (error: any) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
return error.message;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async addCompanyReport(companyDetails: companyDetails): Promise<void> {
|
|
35
|
+
const bodyFormData = new FormData();
|
|
36
|
+
if (companyDetails) {
|
|
37
|
+
bodyFormData.append("companyName", companyDetails.companyName);
|
|
38
|
+
try {
|
|
39
|
+
const response: AxiosResponse = await axios.post(
|
|
40
|
+
this.baseUrl + this.addReportEndpoint,
|
|
41
|
+
companyDetails,
|
|
42
|
+
{
|
|
43
|
+
auth: {
|
|
44
|
+
username: this.apiKey,
|
|
45
|
+
password: "",
|
|
46
|
+
},
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
console.log(response.data);
|
|
54
|
+
return response.data;
|
|
55
|
+
} catch (error: any) {
|
|
56
|
+
console.error(error);
|
|
57
|
+
return error.message;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async addIndividualReport(
|
|
63
|
+
individualDetails: individualDetails
|
|
64
|
+
): Promise<void> {
|
|
65
|
+
const bodyFormData = new FormData();
|
|
66
|
+
if (individualDetails.name) {
|
|
67
|
+
bodyFormData.append("name", individualDetails.name);
|
|
68
|
+
try {
|
|
69
|
+
const response: AxiosResponse = await axios.post(
|
|
70
|
+
this.baseUrl + this.addReportEndpoint,
|
|
71
|
+
individualDetails,
|
|
72
|
+
{
|
|
73
|
+
auth: {
|
|
74
|
+
username: this.apiKey,
|
|
75
|
+
password: "",
|
|
76
|
+
},
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
console.log(response.data);
|
|
84
|
+
return response.data;
|
|
85
|
+
} catch (error: any) {
|
|
86
|
+
console.error(error);
|
|
87
|
+
return error.message;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
console.log("invalid input");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async downloadAsJSON(reqId: string): Promise<any> {
|
|
95
|
+
try {
|
|
96
|
+
const response: AxiosResponse = await axios.get(
|
|
97
|
+
this.baseUrl + this.downloadAsJsonEndpoint + `${reqId}/${this.apiKey}`
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (response.data) {
|
|
101
|
+
console.log("File downloaded successfully");
|
|
102
|
+
console.log(response.data);
|
|
103
|
+
return response.data;
|
|
104
|
+
} else {
|
|
105
|
+
console.error("Failed to download file");
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
} catch (error: any) {
|
|
109
|
+
console.error("Error:", error.message);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async downloadAsPDF(reqId: string): Promise<any> {
|
|
115
|
+
try {
|
|
116
|
+
const response: AxiosResponse = await axios.get(
|
|
117
|
+
this.baseUrl + this.downloadAsPdfEndpoint + `${reqId}/${this.apiKey}`
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (response.data) {
|
|
121
|
+
console.log("File downloaded successfully");
|
|
122
|
+
console.log(response.data);
|
|
123
|
+
return response.data;
|
|
124
|
+
} else {
|
|
125
|
+
console.error("Failed to download file");
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
} catch (error: any) {
|
|
129
|
+
console.error("Error:", error.message);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default CrimeSearchAPIWrapper;
|