Link users and Dwolla customers
The implementation of this smart relationship (belongsTo) relies on a Dwolla service that will retrieve the Dwolla customer based on the user's email. The Dwolla service is described in another section.
// forest/users.js
const { collection } = require('forest-express-sequelize');
const DwollaService = require('../services/dwolla-service');
let dwollaService = new DwollaService(process.env.DWOLLA_APP_KEY, process.env.DWOLLA_APP_SECRET, process.env.DWOLLA_ENVIRONMENT);
collection('users', {
actions: [],
fields: [
{
field: 'dwollaCustomer',
type: 'String',
reference: 'dwollaCustomers.id',
get: function (user) {
return dwollaService.getCustomerSmartRelationship(user);
}
},
],
segments: [],
});
Last updated
Was this helpful?