wallets-africa
Version:
Nodejs API wrapper for wallets africa
131 lines (130 loc) • 4.36 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
/**
* All wallet functionality and methods
* @class wallet
*/
class Wallet {
/**
* Performs a debit on a sub wallet
*/
static async debit(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/debit`;
return axios_1.default.post(url, body);
}
/**
* Performs a credit on a sub wallet
*/
static async credit(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/credit`;
return axios_1.default.post(url, body);
}
/**
* Creates a new customer
*/
static async create(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/create`;
return axios_1.default.post(url, body);
}
/**
* Verifies new customer
*/
static async verify(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/verify`;
return axios_1.default.post(url, body);
}
/**
* Generate
*/
static async generate(options) {
if (!('currency' in options)) {
options.currency = 'NGN';
}
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/generate`;
return axios_1.default.post(url, body);
}
/**
* Generates account number
* @params {string} phone - phone to generate account number against
*/
static async generateAccountNumber(phone) {
const body = { phoneNumber: phone, SecretKey: this.secretKey };
const url = `${this.endpoint}/generateaccountnumber`;
return axios_1.default.post(url, body);
}
/**
* Retrieves account number
*/
static async retrieveAccountNumber(phone) {
const body = { phoneNumber: phone, SecretKey: this.secretKey };
const url = `${this.endpoint}/nuban`;
return axios_1.default.post(url, body);
}
/**
* Sets password against a phone number
*/
static async setPassword(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/password`;
return axios_1.default.post(url, body);
}
/**
* Sets pin
*/
static async setPin(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/pin`;
return axios_1.default.post(url, body);
}
/**
* Returns transaction
*/
static async transactions(options) {
options.currency = options.currency ? options.currency : 'NGN';
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/transactions`;
return axios_1.default.post(url, body);
}
/**
* Verifies BVN
*/
static async verifyBvn(options) {
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/verifybvn`;
return axios_1.default.post(url, body);
}
/**
* Gets a user
*/
static async getUser(phone) {
const body = { phoneNumber: phone, SecretKey: this.secretKey };
const url = `${this.endpoint}/getuser`;
return axios_1.default.post(url, body);
}
/**
* Returns wallet balance
*/
static async getBalance(options) {
if (!('currency' in options)) {
options.currency = 'NGN';
}
const body = Object.assign(Object.assign({}, options), { SecretKey: this.secretKey });
const url = `${this.endpoint}/balance`;
return axios_1.default.post(url, body);
}
}
/*
Api key
*/
Wallet.secretKey = '';
Wallet.endpoint = '/wallet';
exports.default = Wallet;