@inploi/sdk v1.14.11
@inploi/sdk
This package contains the core functionality for the inploi SDK.
Installation
npm install @inploi/sdkUsage
You can initialise the SDK by calling initialiseInploiSdk with the following options:
import { initialiseInploiSdk } from '@inploi/sdk';
const sdk = initialiseInploiSdk({
publishableKey: 'your-publishable-key',
env: 'sandbox',
});Plugins
You can write custom plugins via the createPlugin function. The plugin will have two dependencies injected: a logger service and a an apiClient service, which can be used to make requests to the inploi API.
Example:
export const myCounterPlugin = createPlugin(({ logger, apiClient }) => {
let count = 0;
logger.info('myCounterPlugin initialised');
return {
add: () => {
count++;
logger.info(`count is now ${count}`);
},
getCount: () => count,
};
});External dependencies
If your plugin requires external dependencies, you may want to wrap the createPlugin function with whatever it takes, to then generate a function that returns a plugin:
import { createPlugin } from '@inploi/sdk';
type CounterExternalDeps = {onUpdate: (newCounter: number) => void};
export const myCounterPlugin = ({onUpdate}: CounterExternalDeps) =>
createPlugin(({ logger, apiClient }) => {
let count = 0;
logger.info('myCounterPlugin initialised');
return {
add: () => {
count++;
logger.info(`count is now ${count}`);
onUpdate(count);
},
getCount: () => count,
};
});Using plugins
Users of the SDK may invoke sdk.registerPlugin with a plugin to register it. The plugin will be initialised with the dependencies it requires, and the returned object will be returned to the user.
const sdk = initialiseInploiSdk({
publishableKey: 'your-publishable-key',
env: 'sandbox',
});
const mySimplePlugin = sdk.registerPlugin(mySimplePlugin);
const myCounterPlugin = sdk.registerPlugin(myPluginWithDeps({ onUpdate: newCounter => console.log(newCounter) }));
myCounterPlugin.add();12 months ago
9 months ago
11 months ago
11 months ago
11 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago