Updates for version 1.3.6
- Bug fixes for submitting event when token already exists.
Mzaalo SDK for JavaScript
This repository allows to use the functions of Mzaalo Blockchain Service by connecting it with your backend application.
Installation
npm install mzaalosdk
Usage
- Include the library and create the MzaaloSdk object environment can be "staging" or "production"
const config = require("./config.json")
const MzaaloSdkService= require('./src/service/mzaalosdk_service')
mzaalo = new MzaaloSdkService(apiKey, organization,config, environment)
//initialise mzaalo
mzaalo.initializeSDK()
//config can be set like blank object as well
//api key is organisations api key obtained while registering the organisation
- To send an event to Mzaalo servers
mzaalo.call_event(userId, eventType, metadata)
Use this function to submit events to mzaalo blockchain service.
Params
- userId- The accepted userID type is string and is the userId as per sender's records
- eventType- The accepted eventType is string and is as per the sender's configurations in rules core
- organizationId- The accepted organisationId is string and is as per the organisation Id provided to the sender
- metadata- This is optional but is custom payload that can be used by sender for further analysis of users
This is an async function which returns status of event submission as a promise
Algo Service
Functions
-
get_balance: To get balance for an account
mzaalo.get_balance(userId)
Params:
- userId - The accepted type is string .
- userId - The accepted type is string .
-
get_transactions: To get transactions
mzaalo.get_transactions(userId)
Params:
- userId- The accepted type is string .
Rule Service
Functions
-
create_rule : To create a new rule
mzaalo.create_rule(rule, name, description)
Params:
- rule - The accepted type is string .
- name - The accepted type is string .
- description - The accepted type is string .
-
get_rule : To get created rule
mzaalo.get_rule(rule_id)
Params:
- rule_id - The accepted type is string .
- rule_id - The accepted type is string .
-
update_rule : To update a rule
mzaalo.update_rule(rule_id, rule)
Params:
- rule_id - The accepted type is string .
Event-rule Service
Functions
-
create_event_rule : To create an event rule
mzaalo.create_event_rule(rule_id, event_type)
Params:
- rule_id - The accepted type is array of valid rule-id .
- event_type - The accepted type is string.
-
get_event_rule : To get created event rule
mzaalo.get_event_rule(event_type)
Params:
- event_type - The accepted type is string .
Errors
- Config error
ReferenceError: config is not defined
Please create a config file as per provided
- Default configuration error
{
error: 'Unable to fetch default configuration',
......
Please check whether you are able to access the url provided in response of error and make sure it is accessible from your run time environment
- Default configuration url missing
default configuration Url Missing
Please check the configuration url
- Error in getting token
FAILED_TO_REGENERATE_TOKEN
Token url may not be getting valid api key
- If there is some error in Mzaalo object initialisation then you will get the error as below
Instance not initialized
Url may not be working at all
- Error in token url
ERROR_GETTING_TOKEN_URL
- Error in inputs type in event submission function
INPUT_TYPE_ERROR
- Token generation error
FAILED_TO_REGENERATE_TOKEN
- Any other major error
SDK_ERROR