forest-express
Version:
Official package for all Forest Express Lianas
105 lines (103 loc) • 2.77 kB
JavaScript
"use strict";
var _ = require('lodash');
var _require = require('../../utils/integrations'),
pushIntoApimap = _require.pushIntoApimap;
var INTEGRATION_NAME = 'close.io';
exports.createCollections = function (Implementation, apimap, collectionAndFieldName) {
var collectionName = collectionAndFieldName.split('.')[0];
var collectionDisplayName = _.capitalize(collectionName);
// jshint camelcase: false
pushIntoApimap(apimap, {
name: "".concat(collectionName, "_closeio_leads"),
displayName: "".concat(collectionDisplayName, " Leads"),
icon: 'closeio',
integration: INTEGRATION_NAME,
isVirtual: true,
isReadOnly: true,
onlyForRelationships: true,
fields: [{
field: 'url',
type: 'String',
isFilterable: false,
widget: 'link'
}, {
field: 'display_name',
type: 'String',
isFilterable: false
}, {
field: 'status_label',
type: 'String'
}, {
field: 'created_by_name',
type: 'String',
isFilterable: false
}, {
field: 'date_updated',
type: 'Date',
isFilterable: false
}, {
field: 'date_created',
type: 'Date',
isFilterable: false
}, {
field: 'description',
type: 'String',
isFilterable: false
}, {
field: 'emails',
type: ['String'],
reference: "".concat(collectionName, "_closeio_emails.id")
}]
});
pushIntoApimap(apimap, {
name: "".concat(collectionName, "_closeio_emails"),
displayName: "".concat(collectionDisplayName, " Conversations"),
icon: 'closeio',
integration: INTEGRATION_NAME,
isVirtual: true,
isReadOnly: true,
onlyForRelationships: true,
fields: [{
field: 'status',
type: 'String',
isFilterable: false
}, {
field: 'sender',
type: 'String',
isFilterable: false
}, {
field: 'subject',
type: 'String',
isFilterable: false
}, {
field: 'body_text',
type: 'String',
isFilterable: false
}]
});
};
exports.createFields = function (implementation, model, schema) {
schema.fields.push({
field: 'lead',
type: 'String',
reference: "".concat(implementation.getModelName(model), "_closeio_leads.id"),
isFilterable: false,
integration: INTEGRATION_NAME,
isVirtual: true
});
if (!schema.actions) {
schema.actions = [];
}
schema.actions.push({
id: "".concat(implementation.getModelName(model), ".Create Close.io lead"),
name: 'Create Close.io lead',
endpoint: "/forest/".concat(implementation.getModelName(model), "_closeio_leads"),
fields: [{
field: 'Company/Organization Name',
type: 'String'
}, {
field: 'Contact Name',
type: 'String'
}]
});
};