thinkraz-api-sdk
Version:
橡芮科技API开发包
77 lines (70 loc) • 2.17 kB
JavaScript
const Promise = require('bluebird');
const baseClass = require('../lib/baseClass');
module.exports = class Accounts extends baseClass {
overdraftAccount(accountId, amount) {
return new Promise((resolve, reject) => {
this.request().post(`${this.getPath()}/overdraft`, {
accountId: accountId,
amount: amount
}).then(account => {
resolve(account);
}).catch(err => {
reject(err);
});
});
}
/**
* @description 创建帐户
*/
createAccount() {
return new Promise((resolve, reject) => {
this.request().post(this.getPath()).then(account => {
resolve(account);
}).catch(err => {
reject(err);
});
});
}
/**
* @description 获取账户信息
* @param {string} accountId
*/
getAccount(accountId) {
return new Promise((resolve, reject) => {
this.request().get(`${this.getPath()}/${accountId}`).then(account => {
resolve(account);
}).catch(err => {
reject(err);
});
});
}
/**
* @description 查询帐户记录
* @param {string} accountId
* @param {object} options
*/
getAccountRecords(accountId, options) {
return new Promise((resolve, reject) => {
if (!options) options = {};
this.request().get(`${this.getPath()}/${accountId}/records`, {
where: JSON.stringify(options)
}).then(records => {
resolve(records);
}).catch(err => {
reject(err);
});
});
}
/**
* @description 获取帐户列表
*/
fetchAccounts(query) {
return new Promise((resolve, reject) => {
this.request().get(this.getPath(), {query}).then(accounts => {
resolve(accounts);
}).catch(err => {
reject(err);
});
});
}
};