NodeJs wrapper for QI Tech API.
npm install qitech-wrapper --save
You have two ways to do the configuration:
1 - Or you can call qitech_wrapper.setup
method
const QITtech = require('qitech-wrapper');
let qitech_wrapper = QITtech({
clientKey: "QI Tech API Client_Key",
privateKey: "user private file path or key",
publicKey: "QITECH public file path or key"
});
2 - Or you can define env vars directly.
export QITECH_API_CLIENT_KEY="QI Tech API Client_Key"
export QITECH_API_PRIVATE_KEY="client private file path or USER PRIVATE KEY"
export QITECH_API_QI_PUBLIC_KEY="QITECH public file path or QI TECH PUBLIC KEY"
The sandbox environment is default for any value for QITECH_ENV, except production
## production environment
export QITECH_ENV=production
You can either define it in class constructor.
const QITtech = require('qitech-wrapper');
let qitech_wrapper = QITtech({
environment: "production"
});
API calls return a Promisse and optionally accept http options
You can use async/await
const QITtech = require('qitech-wrapper');
let qitech_wrapper = QITtech({
clientKey: "QI Tech API Client_Key",
privateKey: "user private file path or key",
publicKey: "QITECH public file path or key"
});
let debtKey = [DEBT_KEY];
async function getDebtSimulation(debtKey) {
try {
const response = await qitech_wrapper.debt.get(debtKey);
console.log(response.decoded.data);
} catch (error) {
console.error(error);
}
}
Or you can use then/catch
const QITtech = require('qitech-wrapper');
let qitech_wrapper = QITtech({
clientKey: "QI Tech API Client_Key",
privateKey: "user private file path or key",
publicKey: "QITECH public file path or key"
});
let data = {
"borrower": {
"person_type": "natural"
},
"financial": {
"amount": 5000,
"interest_type": "pre_price",
"credit_operation_type": "ccb",
"annual_interest_rate": 2.32,
"disbursement_date": "2021-08-06",
"interest_grace_period": 0,
"principal_grace_period": 0,
"number_of_installments": 2,
"rebate": null,
"fine_configuration": {
"contract_fine_rate": 0.02,
"interest_base": "calendar_days",
"monthly_rate": 0.01
}
}
};
qitech_wrapper.debt_simulation.post(data)
.then(response => {
// handle success
console.log(response.decoded);
})
.catch(error => {
// handle error
console.error(error.decoded);
})
.then(() => {
// always executed
});
const QITtech = require('qitech-wrapper');
let qitech_wrapper = QITtech({
clientKey: "QI Tech API Client_Key",
privateKey: "user private file path or key",
publicKey: "QITECH public file path or key"
});
let filePath = [path to file, using fs.readFileSync()];
let fileContent = [alternatively, pass the content file];
qitech_wrapper.upload.post(filePath)
.then(console.log)
.catch(console.error);
qitech_wrapper.upload.post(filePath, fileContent, options);
qitech_wrapper.debt.post(data, options);
qitech_wrapper.debt.get(debt_key, options);
qitech_wrapper.debt.list(query, options);
qitech_wrapper.debt.postSigned(query, options);
qitech_wrapper.signed_debt.post(data, options);
qitech_wrapper.signed_debt.get(debt_key, options);
qitech_wrapper.signed_debt.list(query, options);
qitech_wrapper.debt_simulation.post(data, options);
qitech_wrapper.account.post(data, options);
qitech_wrapper.account.list(query, options);
qitech_wrapper.escrow.post(data, options);
qitech_wrapper.scr.post(data, options);
qitech_wrapper.scr.postRedo(data, options);
qitech_wrapper.scr.postSigned(data, options);
qitech_wrapper.scr.list(query, options);
qitech_wrapper.scr.get(scr_key, options);
qitech_wrapper.scr.delete(data, options);
qitech_wrapper.bank_slip.get(bank_slip_key, options);
qitech_wrapper.bank_slip.list(person_key, query, options);
qitech_wrapper.bank_slip.report(requester_profile_code, query, options);
qitech_wrapper.bank_slip_duplicate_balance.get(query, options);
qitech_wrapper.bank_slip_duplicate_balance.getExcel(query, options);
qitech_wrapper.bank_slip_pdf.post(bank_slip_key, options);
qitech_wrapper.bank_slip_pdf.list(bank_slip_key, options);
qitech_wrapper.multibank.postInstruction(data, options);
qitech_wrapper.multibank.uploadCnab(filePath, fileContent, options);
qitech_wrapper.multibank.listCnab(person_key, options);
qitech_wrapper.transfer.post(data, options);
qitech_wrapper.transfer.postApproval(data, options);
qitech_wrapper.transfer.listPending(options);
qitech_wrapper.transfer.getReceipt(transaction_key, query, options);
qitech_wrapper.financial_institute.list(query, options);