connect-react-native
Advanced tools
Comparing version 2.41.0 to 2.42.0
@@ -0,1 +1,5 @@ | ||
## 2.42.0 | ||
- return `DapiError` object as the error object. contains error.message, error.type, error.operationID. | ||
## 2.41.0 | ||
@@ -13,6 +17,2 @@ | ||
## 2.39.0 | ||
- Added presentAccountSelection implementation for iOS. | ||
## 2.38.0 | ||
@@ -19,0 +19,0 @@ - Removed `accessCode` and `connectionID` from connection parameters `connection.getParameters()`. |
@@ -7,2 +7,3 @@ "use strict"; | ||
var _exportNames = { | ||
DapiError: true, | ||
DapiConfigurations: true, | ||
@@ -19,3 +20,3 @@ DapiThemeConfigurations: true, | ||
}; | ||
exports.default = exports.DapiWireBeneficiary = exports.DapiThemeConfigurations = exports.DapiPair = exports.DapiLineAddress = exports.DapiConnection = exports.DapiConfigurations = exports.DapiCardBalance = exports.DapiCard = exports.DapiBeneficiary = exports.DapiAccount = void 0; | ||
exports.default = exports.DapiWireBeneficiary = exports.DapiThemeConfigurations = exports.DapiPair = exports.DapiLineAddress = exports.DapiError = exports.DapiConnection = exports.DapiConfigurations = exports.DapiCardBalance = exports.DapiCard = exports.DapiBeneficiary = exports.DapiAccount = void 0; | ||
var _nativeInterface = _interopRequireDefault(require("./internal/nativeInterface")); | ||
@@ -38,2 +39,15 @@ var _types = require("./internal/types"); | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
class DapiError extends Error { | ||
constructor(message, type, operationID, account) { | ||
super(message); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "operationID", void 0); | ||
_defineProperty(this, "account", void 0); | ||
this.name = 'DapiError'; | ||
this.type = type; | ||
this.operationID = operationID; | ||
this.account = account; | ||
} | ||
} | ||
exports.DapiError = DapiError; | ||
class DapiConfigurations { | ||
@@ -169,75 +183,262 @@ constructor(countries) { | ||
async presentAccountSelection() { | ||
return _nativeInterface.default.presentAccountSelection(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.presentAccountSelection(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getParameters() { | ||
return _nativeInterface.default.getConnectionParameters(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getConnectionParameters(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getIdentity() { | ||
return _nativeInterface.default.getIdentity(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getIdentity(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getAccounts() { | ||
return _nativeInterface.default.getAccounts(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getAccounts(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getCards() { | ||
return _nativeInterface.default.getCards(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getCards(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getTransactionsForAccount(account, startDate, endDate, type) { | ||
return _nativeInterface.default.getTransactionsForAccount(this.userID, account.id, startDate.getTime(), endDate.getTime(), type); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getTransactionsForAccount(this.userID, account.id, startDate.getTime(), endDate.getTime(), type).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getTransactionsForCard(card, startDate, endDate, type) { | ||
return _nativeInterface.default.getTransactionsForCard(this.userID, card.id, startDate.getTime(), endDate.getTime(), type); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getTransactionsForCard(this.userID, card.id, startDate.getTime(), endDate.getTime(), type).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getAccountsMetadata() { | ||
return _nativeInterface.default.getAccountsMetadata(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getAccountsMetadata(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
delete() { | ||
return _nativeInterface.default.delete(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.delete(this.userID).then(() => { | ||
resolve(); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
createBeneficiary(beneficiary) { | ||
return _nativeInterface.default.createBeneficiary(this.userID, beneficiary); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.createBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getBeneficiaries() { | ||
return _nativeInterface.default.getBeneficiaries(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
async createTransfer(fromAccount, toBeneficiary, amount, remark) { | ||
let transferResponse = await _nativeInterface.default.createTransfer(this.userID, fromAccount ? fromAccount.id : null, toBeneficiary, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await _nativeInterface.default.createTransfer(this.userID, fromAccount ? fromAccount.id : null, toBeneficiary, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createTransferToExistingBeneficiary(fromAccount, toBeneficiaryID, amount, remark) { | ||
let transferResponse = await _nativeInterface.default.createTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await _nativeInterface.default.createTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
createWireBeneficiary(beneficiary) { | ||
return _nativeInterface.default.createWireBeneficiary(this.userID, beneficiary); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.createWireBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getWireBeneficiaries() { | ||
return _nativeInterface.default.getWireBeneficiaries(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
_nativeInterface.default.getWireBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
async createWireTransfer(toBeneficiary, fromAccount, amount, remark) { | ||
let transferResponse = await _nativeInterface.default.createWireTransfer(this.userID, toBeneficiary, fromAccount ? fromAccount.id : null, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await _nativeInterface.default.createWireTransfer(this.userID, toBeneficiary, fromAccount ? fromAccount.id : null, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createWireTransferToExistingBeneficiary(fromAccount, toBeneficiaryID, amount, remark) { | ||
let transferResponse = await _nativeInterface.default.createWireTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await _nativeInterface.default.createWireTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
@@ -421,2 +622,27 @@ } | ||
_defineProperty(Dapi, "_instance", new Dapi()); | ||
function errorInfo(error) { | ||
let json = JSON.parse(error.message); | ||
let message; | ||
let type; | ||
let operationID; | ||
let account; | ||
if (json.hasOwnProperty("message")) { | ||
message = json.message; | ||
} | ||
if (json.hasOwnProperty("type")) { | ||
type = json.type; | ||
} | ||
if (json.hasOwnProperty("operationID")) { | ||
operationID = json.operationID; | ||
} | ||
if (json.hasOwnProperty("account")) { | ||
account = json.account; | ||
} | ||
return { | ||
message: message, | ||
type: type, | ||
operationID: operationID, | ||
account: account | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { DapiEnvironment } from './internal/types'; | ||
export class DapiError extends Error { | ||
constructor(message, type, operationID, account) { | ||
super(message); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "operationID", void 0); | ||
_defineProperty(this, "account", void 0); | ||
this.name = 'DapiError'; | ||
this.type = type; | ||
this.operationID = operationID; | ||
this.account = account; | ||
} | ||
} | ||
export class DapiConfigurations { | ||
@@ -135,75 +147,262 @@ constructor(countries) { | ||
async presentAccountSelection() { | ||
return NativeInterface.presentAccountSelection(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.presentAccountSelection(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getParameters() { | ||
return NativeInterface.getConnectionParameters(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getConnectionParameters(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getIdentity() { | ||
return NativeInterface.getIdentity(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getIdentity(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getAccounts() { | ||
return NativeInterface.getAccounts(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getAccounts(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getCards() { | ||
return NativeInterface.getCards(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getCards(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getTransactionsForAccount(account, startDate, endDate, type) { | ||
return NativeInterface.getTransactionsForAccount(this.userID, account.id, startDate.getTime(), endDate.getTime(), type); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getTransactionsForAccount(this.userID, account.id, startDate.getTime(), endDate.getTime(), type).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getTransactionsForCard(card, startDate, endDate, type) { | ||
return NativeInterface.getTransactionsForCard(this.userID, card.id, startDate.getTime(), endDate.getTime(), type); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getTransactionsForCard(this.userID, card.id, startDate.getTime(), endDate.getTime(), type).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getAccountsMetadata() { | ||
return NativeInterface.getAccountsMetadata(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getAccountsMetadata(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
delete() { | ||
return NativeInterface.delete(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.delete(this.userID).then(() => { | ||
resolve(); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
createBeneficiary(beneficiary) { | ||
return NativeInterface.createBeneficiary(this.userID, beneficiary); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.createBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getBeneficiaries() { | ||
return NativeInterface.getBeneficiaries(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
async createTransfer(fromAccount, toBeneficiary, amount, remark) { | ||
let transferResponse = await NativeInterface.createTransfer(this.userID, fromAccount ? fromAccount.id : null, toBeneficiary, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await NativeInterface.createTransfer(this.userID, fromAccount ? fromAccount.id : null, toBeneficiary, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createTransferToExistingBeneficiary(fromAccount, toBeneficiaryID, amount, remark) { | ||
let transferResponse = await NativeInterface.createTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await NativeInterface.createTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
createWireBeneficiary(beneficiary) { | ||
return NativeInterface.createWireBeneficiary(this.userID, beneficiary); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.createWireBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
getWireBeneficiaries() { | ||
return NativeInterface.getWireBeneficiaries(this.userID); | ||
return new Promise(async (resolve, reject) => { | ||
NativeInterface.getWireBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}); | ||
}); | ||
} | ||
async createWireTransfer(toBeneficiary, fromAccount, amount, remark) { | ||
let transferResponse = await NativeInterface.createWireTransfer(this.userID, toBeneficiary, fromAccount ? fromAccount.id : null, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await NativeInterface.createWireTransfer(this.userID, toBeneficiary, fromAccount ? fromAccount.id : null, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createWireTransferToExistingBeneficiary(fromAccount, toBeneficiaryID, amount, remark) { | ||
let transferResponse = await NativeInterface.createWireTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
return new Promise(async (resolve, reject) => { | ||
await NativeInterface.createWireTransferToExistingBeneficiary(this.userID, fromAccount.id, toBeneficiaryID, amount, remark).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { | ||
message, | ||
type, | ||
operationID, | ||
account | ||
} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
@@ -378,3 +577,28 @@ } | ||
_defineProperty(Dapi, "_instance", new Dapi()); | ||
function errorInfo(error) { | ||
let json = JSON.parse(error.message); | ||
let message; | ||
let type; | ||
let operationID; | ||
let account; | ||
if (json.hasOwnProperty("message")) { | ||
message = json.message; | ||
} | ||
if (json.hasOwnProperty("type")) { | ||
type = json.type; | ||
} | ||
if (json.hasOwnProperty("operationID")) { | ||
operationID = json.operationID; | ||
} | ||
if (json.hasOwnProperty("account")) { | ||
account = json.account; | ||
} | ||
return { | ||
message: message, | ||
type: type, | ||
operationID: operationID, | ||
account: account | ||
}; | ||
} | ||
export * from './internal/types'; | ||
//# sourceMappingURL=index.js.map |
import { IDapiConfigurations, IAccount, ICard, IBeneficiary, IWireBeneficiary, IDapiConnection, IPair, IAccountResponse, IIdentityResponse, ITransactionResponse, IAccountsMetadataResponse, DapiEnvironment, IBankBeneficiaryResponse, IBankWireBeneficiaryResponse, IDapiResult, DapiEndpoint, ITransferResponse, ICardResponse, ICardBalance, ILineAddress, IAccountBalance, DapiTransactionsType, IDapiThemeConfigurations, DapiTheme, DapiLanguage } from './internal/types'; | ||
export declare class DapiError extends Error { | ||
type?: string; | ||
operationID?: string; | ||
account?: string; | ||
constructor(message: string, type?: string, operationID?: string, account?: string); | ||
} | ||
export declare class DapiConfigurations implements IDapiConfigurations { | ||
@@ -3,0 +9,0 @@ environment?: DapiEnvironment; |
{ | ||
"name": "connect-react-native", | ||
"version": "2.41.0", | ||
"version": "2.42.0", | ||
"description": "Financial APIs to connect users' bank accounts", | ||
@@ -5,0 +5,0 @@ "react-native": "src/index.ts", |
395
src/index.ts
@@ -30,2 +30,15 @@ import NativeInterface from './internal/nativeInterface'; | ||
export class DapiError extends Error { | ||
type?: string | ||
operationID?: string | ||
account?: string | ||
constructor(message: string, type?: string, operationID?: string, account?: string) { | ||
super(message); | ||
this.name = 'DapiError'; | ||
this.type = type; | ||
this.operationID = operationID; | ||
this.account = account; | ||
} | ||
} | ||
export class DapiConfigurations implements IDapiConfigurations { | ||
@@ -188,24 +201,60 @@ environment?: DapiEnvironment | ||
} | ||
async presentAccountSelection(): Promise<string | undefined> { | ||
return NativeInterface.presentAccountSelection(this.userID); | ||
} | ||
getParameters(): Promise<string> { | ||
return NativeInterface.getConnectionParameters(this.userID); | ||
} | ||
async presentAccountSelection(): Promise < string | undefined > { | ||
return new Promise < string | undefined > (async (resolve, reject) => { | ||
NativeInterface.presentAccountSelection(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getIdentity(): Promise<IIdentityResponse> { | ||
return NativeInterface.getIdentity(this.userID); | ||
} | ||
getParameters(): Promise < string > { | ||
return new Promise < string > (async (resolve, reject) => { | ||
NativeInterface.getConnectionParameters(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getIdentity(): Promise < IIdentityResponse > { | ||
return new Promise < IIdentityResponse > (async (resolve, reject) => { | ||
NativeInterface.getIdentity(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getAccounts(): Promise<IAccountResponse> { | ||
return NativeInterface.getAccounts(this.userID); | ||
} | ||
getCards(): Promise<ICardResponse> { | ||
return NativeInterface.getCards(this.userID); | ||
} | ||
getAccounts(): Promise < IAccountResponse > { | ||
return new Promise < IAccountResponse > (async (resolve, reject) => { | ||
NativeInterface.getAccounts(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getTransactionsForAccount( | ||
getCards(): Promise < ICardResponse > { | ||
return new Promise < ICardResponse > (async (resolve, reject) => { | ||
NativeInterface.getCards(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getTransactionsForAccount( | ||
account: IAccount, | ||
@@ -215,13 +264,20 @@ startDate: Date, | ||
type: DapiTransactionsType | ||
): Promise<ITransactionResponse> { | ||
return NativeInterface.getTransactionsForAccount( | ||
this.userID, | ||
account.id, | ||
startDate.getTime(), | ||
endDate.getTime(), | ||
type | ||
); | ||
} | ||
): Promise < ITransactionResponse > { | ||
return new Promise < ITransactionResponse > (async (resolve, reject) => { | ||
NativeInterface.getTransactionsForAccount( | ||
this.userID, | ||
account.id, | ||
startDate.getTime(), | ||
endDate.getTime(), | ||
type | ||
).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getTransactionsForCard( | ||
getTransactionsForCard( | ||
card: ICard, | ||
@@ -231,30 +287,66 @@ startDate: Date, | ||
type: DapiTransactionsType, | ||
): Promise<ITransactionResponse> { | ||
return NativeInterface.getTransactionsForCard( | ||
this.userID, | ||
card.id, | ||
startDate.getTime(), | ||
endDate.getTime(), | ||
type | ||
); | ||
} | ||
): Promise < ITransactionResponse > { | ||
return new Promise < ITransactionResponse > (async (resolve, reject) => { | ||
NativeInterface.getTransactionsForCard( | ||
this.userID, | ||
card.id, | ||
startDate.getTime(), | ||
endDate.getTime(), | ||
type | ||
).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getAccountsMetadata(): Promise<IAccountsMetadataResponse> { | ||
return NativeInterface.getAccountsMetadata(this.userID); | ||
} | ||
getAccountsMetadata(): Promise < IAccountsMetadataResponse > { | ||
return new Promise < IAccountsMetadataResponse > (async (resolve, reject) => { | ||
NativeInterface.getAccountsMetadata(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
delete(): Promise<void> { | ||
return NativeInterface.delete(this.userID); | ||
} | ||
delete(): Promise < void > { | ||
return new Promise < void > (async (resolve, reject) => { | ||
NativeInterface.delete(this.userID).then(() => { | ||
resolve(); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
createBeneficiary(beneficiary: IBeneficiary): Promise<IDapiResult> { | ||
return NativeInterface.createBeneficiary(this.userID, beneficiary); | ||
} | ||
createBeneficiary(beneficiary: IBeneficiary): Promise < IDapiResult > { | ||
return new Promise < IDapiResult > (async (resolve, reject) => { | ||
NativeInterface.createBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getBeneficiaries(): Promise<IBankBeneficiaryResponse> { | ||
return NativeInterface.getBeneficiaries(this.userID); | ||
} | ||
getBeneficiaries(): Promise < IBankBeneficiaryResponse > { | ||
return new Promise < IBankBeneficiaryResponse > (async (resolve, reject) => { | ||
NativeInterface.getBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
async createTransfer(fromAccount: IAccount | null, toBeneficiary: IBeneficiary | null, amount: number, remark: string | null): Promise<ITransferResponse> { | ||
let transferResponse = await NativeInterface.createTransfer( | ||
async createTransfer(fromAccount: IAccount | null, toBeneficiary: IBeneficiary | null, amount: number, remark: string | null): Promise<ITransferResponse> { | ||
return new Promise < ITransferResponse > (async (resolve, reject) => { | ||
await NativeInterface.createTransfer( | ||
this.userID, | ||
@@ -265,77 +357,115 @@ fromAccount ? fromAccount.id : null, | ||
remark, | ||
); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
} | ||
).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { message, type , operationID, account} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createTransferToExistingBeneficiary( | ||
fromAccount: IAccount, | ||
toBeneficiaryID: string, | ||
amount: number, | ||
remark: string | null, | ||
): Promise<ITransferResponse> { | ||
let transferResponse = await NativeInterface.createTransferToExistingBeneficiary( | ||
this.userID, | ||
fromAccount.id, | ||
toBeneficiaryID, | ||
amount, | ||
remark, | ||
); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
} | ||
async createTransferToExistingBeneficiary( | ||
fromAccount: IAccount, | ||
toBeneficiaryID: string, | ||
amount: number, | ||
remark: string | null, | ||
): Promise<ITransferResponse> { | ||
return new Promise < ITransferResponse > (async (resolve, reject) => { | ||
await NativeInterface.createTransferToExistingBeneficiary( | ||
this.userID, | ||
fromAccount.id, | ||
toBeneficiaryID, | ||
amount, | ||
remark, | ||
).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { message, type , operationID, account} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
createWireBeneficiary(beneficiary: IWireBeneficiary): Promise<IDapiResult> { | ||
return NativeInterface.createWireBeneficiary(this.userID, beneficiary); | ||
} | ||
createWireBeneficiary(beneficiary: IWireBeneficiary): Promise < IDapiResult > { | ||
return new Promise < IDapiResult > (async (resolve, reject) => { | ||
NativeInterface.createWireBeneficiary(this.userID, beneficiary).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
getWireBeneficiaries(): Promise<IBankWireBeneficiaryResponse> { | ||
return NativeInterface.getWireBeneficiaries(this.userID); | ||
} | ||
getWireBeneficiaries(): Promise < IBankWireBeneficiaryResponse > { | ||
return new Promise < IBankWireBeneficiaryResponse > (async (resolve, reject) => { | ||
NativeInterface.getWireBeneficiaries(this.userID).then(response => { | ||
resolve(response); | ||
}).catch(error => { | ||
let { message, type , operationID} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID)); | ||
}) | ||
}); | ||
} | ||
async createWireTransfer(toBeneficiary: IWireBeneficiary, fromAccount: IAccount | null, amount: number, remark: string | null): Promise<ITransferResponse> { | ||
let transferResponse = await NativeInterface.createWireTransfer( | ||
this.userID, | ||
toBeneficiary, | ||
fromAccount ? fromAccount.id : null, | ||
amount, | ||
remark, | ||
); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
} | ||
async createWireTransfer(toBeneficiary: IWireBeneficiary, fromAccount: IAccount | null, amount: number, remark: string | null): Promise<ITransferResponse> { | ||
return new Promise < ITransferResponse > (async (resolve, reject) => { | ||
await NativeInterface.createWireTransfer( | ||
this.userID, | ||
toBeneficiary, | ||
fromAccount ? fromAccount.id : null, | ||
amount, | ||
remark, | ||
).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { message, type , operationID, account} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
async createWireTransferToExistingBeneficiary( | ||
fromAccount: IAccount, | ||
toBeneficiaryID: string, | ||
amount: number, | ||
remark: string | null, | ||
): Promise<ITransferResponse> { | ||
let transferResponse = await NativeInterface.createWireTransferToExistingBeneficiary( | ||
this.userID, | ||
fromAccount.id, | ||
toBeneficiaryID, | ||
amount, | ||
remark, | ||
); | ||
let accountID = transferResponse.account; | ||
let amnt = transferResponse.amount; | ||
let operationID = transferResponse.operationID; | ||
let resultRemark = transferResponse.remark; | ||
let reference = transferResponse.reference; | ||
return new TransferResponse(amnt, operationID, accountID, resultRemark, reference); | ||
} | ||
async createWireTransferToExistingBeneficiary( | ||
fromAccount: IAccount, | ||
toBeneficiaryID: string, | ||
amount: number, | ||
remark: string | null, | ||
): Promise<ITransferResponse> { | ||
return new Promise < ITransferResponse > (async (resolve, reject) => { | ||
await NativeInterface.createWireTransferToExistingBeneficiary( | ||
this.userID, | ||
fromAccount.id, | ||
toBeneficiaryID, | ||
amount, | ||
remark, | ||
).then(response => { | ||
let accountID = response.account; | ||
let amnt = response.amount; | ||
let operationID = response.operationID; | ||
let resultRemark = response.remark; | ||
let reference = response.reference; | ||
resolve(new TransferResponse(amnt, operationID, accountID, resultRemark, reference)); | ||
}).catch(error => { | ||
let { message, type , operationID, account} = errorInfo(error); | ||
reject(new DapiError(message, type, operationID, account)); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -591,2 +721,31 @@ export class DapiPair implements IPair { | ||
function errorInfo(error: any) { | ||
let json = JSON.parse(error.message); | ||
let message; | ||
let type; | ||
let operationID; | ||
let account; | ||
if(json.hasOwnProperty("message")) { | ||
message = json.message; | ||
} | ||
if(json.hasOwnProperty("type")) { | ||
type = json.type; | ||
} | ||
if(json.hasOwnProperty("operationID")) { | ||
operationID = json.operationID; | ||
} | ||
if(json.hasOwnProperty("account")) { | ||
account = json.account; | ||
} | ||
return { message: message, type: type, operationID: operationID, account: account }; | ||
} | ||
export * from './internal/types'; | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1287971
3220