feat: downloadable tx summary and logs

This commit is contained in:
José Oliveira 2021-03-19 18:53:50 +00:00 committed by Josh Harvey
parent bd9615c5ea
commit 92b6093a07
7 changed files with 311 additions and 37 deletions

View file

@ -5,17 +5,17 @@ const transactions = require('../../services/transactions')
const anonymous = require('../../../constants').anonymousCustomer
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids))
const tx_logFields = ["txClass", "id", "deviceId", "toAddress", "cryptoAtoms",
"cryptoCode", "fiat", "fiatCode", "fee", "status",
"dispense", "notified", "redeem", "phone", "error",
"created", "confirmedAt", "hdIndex", "swept", "timedout",
"dispenseConfirmed", "provisioned1", "provisioned2",
"denomination1", "denomination2", "errorCode", "customerId",
"txVersion", "publishedAt", "termsAccepted", "layer2Address",
"commissionPercentage", "rawTickerPrice", "receivedCryptoAtoms",
"discount", "txHash", "customerPhone", "customerIdCardDataNumber",
"customerIdCardDataExpiration", "customerIdCardData", "customerName",
"customerFrontCameraPath", "customerIdCardPhotoPath", "expired", "machineName"]
const txLogFields = ['txClass', 'id', 'deviceId', 'toAddress', 'cryptoAtoms',
'cryptoCode', 'fiat', 'fiatCode', 'fee', 'status',
'dispense', 'notified', 'redeem', 'phone', 'error',
'created', 'confirmedAt', 'hdIndex', 'swept', 'timedout',
'dispenseConfirmed', 'provisioned1', 'provisioned2',
'denomination1', 'denomination2', 'errorCode', 'customerId',
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName']
const resolvers = {
Customer: {
@ -28,7 +28,11 @@ const resolvers = {
transactions: (...[, { from, until, limit, offset, deviceId }]) =>
transactions.batch(from, until, limit, offset, deviceId),
transactionsCsv: (...[, { from, until, limit, offset }]) =>
transactions.batch(from, until, limit, offset).then(data => parseAsync(data, {fields: tx_logFields}))
transactions.batch(from, until, limit, offset).then(data => parseAsync(data, { fields: txLogFields })),
transactionCsv: (...[, { id, txClass }]) =>
transactions.getTx(id, txClass).then(parseAsync),
txAssociatedDataCsv: (...[, { id, txClass }]) =>
transactions.getTxAssociatedData(id, txClass).then(parseAsync)
}
}