apigum-sdk is npm library for managing integrations between popular cloud applications like Twilio, SendGrid, Shopify and others.
// Import a module
const {Integration, Apps, AppHelper} = require('apigum-sdk')
const freshdeskCredentials = {}
const stripeCredentials = {}
//set up credentials
freshdeskCredentials[Apps.Freshdesk.Keys.Apikey] = "<your Freshdesk api key>"
freshdeskCredentials[Apps.Freshdesk.Keys.Subdomain] = "<your Freshdesk subdomain>"
//set up credentials
stripeCredentials[Apps.Stripe.Keys.Secretkey] = "<your Stripe secret key>"
//obtain api key at https://account.apigum.com/api
const apiKey = "<Your API key>"
//create integration instance
const integration = new Integration(apiKey);
const freshdesk = AppHelper.configure(Apps.Freshdesk.AppId, this.freshdeskCredentials);
const stripe = AppHelper.configure(Apps.Stripe.AppId, this.stripeCredentials);
integration.create(freshdesk, stripe,
Apps.Freshdesk.Integrations.CREATE_FRESHDESK_CONTACT_FOR_NEW_STRIPE_CUSTOMERS)
.then(id => {
// returns id of created integration
})
.catch(err => console.log(err));
//You may clone other integrations on apigum.com by using the id (last part) in the URL:
//e.g.: https://www.apigum.com/Integrations/{integration-id}
const script = fs.readFileSync(path.resolve(__dirname, "./integration.js"), "utf8");
integration.updateScript(integrationId , script)
.catch(err => console.log(err));
//Integration code for => "Create Freshdesk contact for new Stripe customers"
var freshdesk={};
function setElements(stripe) {
freshdesk.name = stripe.description;
freshdesk.email = stripe.email;
}
function template() {
return `{
"name": "${freshdesk.name}",
"email": "${freshdesk.email}",
"other_emails": []
}`;
}
module.exports = function (context, events) {
let actions = [];
for (let event of events.body) {
setElements(event);
actions.push(template());
}
context.res = {
body: actions
};
context.done();
};
integration.delete(integrationId)
.catch(err => console.log(err));
//by default integrations start running when created
//this method may be used if integration has been stopped.
integration.publish(integrationId)
.catch(err => console.log(err));
//suspends integration data synchronization
integration.unpublish(integrationId)
.catch(err => console.log(err));
For product information please visit our site at https://www.apigum.com
Version | Tag | Published |
---|---|---|
1.0.2 | latest | 4yrs ago |