Socket
Socket
Sign inDemoInstall

apigum-sdk

Package Overview
Dependencies
51
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apigum-sdk

apigum is npm library for managing integrations between popular cloud applications like Twilio, SendGrid, Shopify and others.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
5.10 MB
Created
Weekly downloads
 

Readme

Source

apigum-sdk

Build Status Dependencies NPM version

apigum-sdk is npm library for managing integrations between popular cloud applications like Twilio, SendGrid, Shopify and others.

Installation

  • npm install apigum-sdk --save

Usage

  • Log into your apigum.com account to obtain your API Key.
  • You'll also need to obtain the relevant application keys. For example secret key for Stripe or Subdomain and Api Key for Freshdesk.
  • This library makes calls to the apigum REST API.
  • This SDK includes a current snapshot of supported integrations. This of course can be overriden by picking up new integration ids @ apigum.com.

Import Module

  // Import a module
  const {Integration, Apps, AppHelper} = require('apigum-sdk')

Setup

  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);

Create Integration

  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}

Update Integration

    const script = fs.readFileSync(path.resolve(__dirname, "./integration.js"), "utf8");
    
    integration.updateScript(integrationId , script)
        .catch(err => console.log(err));  
Sample integration.js
//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();
  };            

Delete Integration

  integration.delete(integrationId)
    .catch(err => console.log(err));

Start Running

  //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));

Stop Running

  //suspends integration data synchronization
  integration.unpublish(integrationId)
    .catch(err => console.log(err));

For product information please visit our site at https://www.apigum.com

Keywords

FAQs

Last updated on 01 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc