Socket
Socket
Sign inDemoInstall

elarian

Package Overview
Dependencies
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elarian

Elrian JavaScript SDK


Version published
Weekly downloads
8
decreased by-55.56%
Maintainers
2
Weekly downloads
 
Created
Source

Elarian

NPM

A convenient way to interact with the Elarian APIs.

Install

You can install the package from npm by running:

$ npm install elarian

Usage


// on node
const { Elarian }  = require('elarian');
/*
or in the browser
<script src="dist/elarian.min.js"></script>
const { Elarian } = ElarianSDK;
*/

// ...

const client = new Elarian({
    apiKey: 'YOUR_API_KEY', // or authToken: 'YOUR_AUTH_TOKEN'
    orgId: 'YOUR_ORG_ID',
    appId: 'YOUR_APP_ID',
});

client.on('ussdSession', async ({ data, customer}, callback) => {
    const {
        input,
        sessionId,
    } = data;

    const appData = await customer.leaseAppData();
    let {
        name,
        state = 'newbie',
    } = appData;

    const menu = {
        text: null,
        isTerminal: true,
    };

    switch (state) {
    case 'veteran':
        if (name) {
            menu.text = `Welcome back ${name}! What is your new name?`;
            menu.isTerminal = false;
        } else {
            name = input.value;
            menu.text = `Thank you for trying Elarian, ${name}!`;
            menu.isTerminal = true;
            await customer.sendMessage(
                { number: 'Elarian', provider: 'telco' },
                { text: `Hey ${name}! Thank you for trying out Elarian` },
            );
        }
        break;
    case 'newbie':
    default:
        menu.text = 'Hey there, welcome to Elarian! What\'s your name?';
        menu.isTerminal = false;
        state = 'veteran';
        break;
    }

    await customer.updateAppData({ state, name });
    callback(null, menu);
});

client
    .connect()
    .then(() => console.log('App is running!'))
    .catch(console.error);

Documentation

Take a look at the API docs here. For detailed info on this SDK, see the documentation.

Development

Run all tests:

$ npm install
$ npm test

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

Keywords

FAQs

Package last updated on 05 Mar 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc