1.1.1 • Published 1 year ago

bl-airtime-plugin-manager v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

AIRTIME PLUGIN MANAGER

The plugins manager facilitates communication between MO and internal API through plugins.

Installation

# Using npm
npm -i airtime-plugin-manager --save
# Using yarn
yarn add airtime-plugin-manager

Usage

In order for the plugin to be effective, you need to import PluginManager and extend either BasePlugin or BaseBillingPlugin as per your need.

Extend BasePlugin if you need to add new operator. Extend BaseBillingPlugin if you want to implement new logic for the billing.

Example:

Configuring the PluginManager
    // Some where in your application entry e.g. app.js
    const {PluginManager} = require('airtime-plugin-manager');
    const path = require('path');

    // Url pointing to the rabbitmq message.
    const qUrl = 'amq://127.0.0.1';

    // Internal messaging channel
    const topic = 'disbursement';


    new PluginManager()
        // Configuration
        .withConfig(path.join(__dirname, 'config.yaml'))
        // We will eventually remove this (deprecated)
        .useLogger(logger)
        // Define the rabbitmq url
        .rabbitMQUrl(qUrl)
        // Define the queue channel
        .rabbitMQTopic(topic)
        // Define the path where the plugins will be found.
        .pluginsPath(path.join(__dirname, 'plugins'))
        // Spin the plugins manager
        .run();

Developing the plugins

New MO plugin named my_new_mo.js
   // This plugin is located at <root>/plugins/my_new_mo.js

   const {BasePlugin} = require('airtime-plugin-manager');

   class MyNewMoPlugin extends BasePlugin {
       constructor() {
           super();
       }

       // This is where you perform the transfer.
       doTransfer(amount, msisdn) {
           super.doTransfer(amount, msisdn);
       }
   }
New MO Billing plugin named my_new_mo_billing.js
// This plugin is located at <root>/plugins/billing/my_new_mo_billing.js
const {BaseBillingPlugin} = require('airtime-airtime-manager');

class MyNewMoBillingPlugin extends BaseBillingPlugin {

    constructor() {
        super();
    }

    onBlockCredits(args) {
        // Block credits...
    }

    onDebitAccount(args) {
        // Debit Account. Transaction went through
    }

    onCreditAccount(args) {
        // Credit account. Transaction failed.
    }
}

Integrating to your project.

To intergrate the airtime-plugin-manager to your project, you need to specify your configuration in .yaml file.

Assume the file named config.yaml with the following options

new_mo:
    name: my_mo_plugin
    billing: my_mo_billing_plugin

That's it!

1.1.1

1 year ago

1.1.0

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.19

2 years ago

1.0.20

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago