@sproutasia/sprout-basisid-api
v1.0.4
Published
Sprout's interface with BASISID
Downloads
1
Keywords
Readme
Simplified BasisID Rest API http request for Sprout Apps
Key features
- Send Basic Data
- Upload Document
- Upload Video
- Upload Image
- Upload Bank Statement
- Upload Utility Bill
- Upload Proof of Income
- Get User Profile Information
Installation
1.Install package
To install sprout-basis-api with npm
:
npm install @sproutasia/sprout-basisid-api --save
To install sprout-basis-api with yarn
:
yarn add @sproutasia/sprout-basisid-api --save
Usage
Here is a basic example of using sprout-basisid-api within a nodejs application.
const BasisController = require("@sproutasia/sprout-basisid-api");
const basis = new BasisController(
"<TypeGoesHere>",
false,
"<ApiKeyGoesHere>",
"<SecretGoesHere>"
);
// Send basic data
basis.sendBasicData(payload);
// payload must be Buffer object, here is the example of how to generate it
const file = fs.createReadStream("./toBeUploadedFile");
const getBuffer = new Promise((resolve, error) => {
const buffer = [];
let buf = null;
file.on("data", (chunk) => {
buffer.push(chunk);
});
file.on("end", () => {
buf = Buffer.concat(buffer);
file.destroy();
resolve(buf);
});
file.on("error", () => {
file.destroy();
error(
new Error({
message: "Error readStream",
})
);
});
});
// Upload document (using buffer object that mentioned earlier)
basis.uploadDocument(
await getBuffer,
"<UserHashGoesHere>",
"<CheckIdGoesHere>",
"<StepGoesHere>"
);
// Upload video (using buffer object that mentioned earlier)
basis.uploadVideo(await getBuffer, "<UserHashGoesHere>", "<CheckIdGoesHere>");
// Upload image (using buffer object that mentioned earlier)
basis.uploadImage(await getBuffer, "<UserHashGoesHere>", "<CheckIdGoesHere>");
// Upload bank statement (using buffer object that mentioned earlier)
basis.uploadBankStatement(
await getBuffer,
"<UserHashGoesHere>",
"<CheckIdGoesHere>"
);
// Upload utility bill (using buffer object that mentioned earlier)
basis.uploadUtilityBill(
await getBuffer,
"<UserHashGoesHere>",
"<CheckIdGoesHere>"
);
// Upload proof of income (using buffer object that mentioned earlier)
basis.uploadProofOfIncome(
await getBuffer,
"<UserHashGoesHere>",
"<CheckIdGoesHere>"
);
// Get users info
basis.getUserProfileInformation("<UserHashGoesHere>");