@kopamerchant/connector-sdk2
v0.5.5
Published
Kopa connector sdk for NestJS framework
Readme
Features
- Configure and connect to Köpa connector instance
Installation
Yarn
yarn add @kopamerchant/connector-sdkNPM
npm install @kopamerchant/connector-sdk --saveGetting Started
To use Köpa connector SDK we need to register module for example in app.module.ts
import { Module } from '@nestjs/common';
import { ConnectorModule } from '@kopamerchant/connector-sdk';
@Module({
imports: [
ConnectorModule.register({
password: 'connector_password',
username: 'connector_username',
resource: 'connector_resource',
})
})
export class AppModule {}and run the connector in app.service.ts
import { ConnectorService } from '@kopamerchant/connector-sdk';
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
constructor(private readonly connectorService: ConnectorService) {
this.connectorService.bootstrap();
}
}After the registration connection to Köpa connector instance should be completed and ready for usage.
Example usage in service.
import { Injectable } from '@nestjs/common';
import { ConnectorService } from '@kopamerchant/connector-sdk';
import { OnEvent } from '@nestjs/event-emitter';
@Injectable()
export class ContentService {
constructor(private readonly connectorService: ConnectorService) {}
@OnEvent('merchant.get')
handleGetMerchantEvent(payload) {
const message = {
to: payload.from,
sagaId: payload.sagaId,
payload: {
companyName: 'Company name',
companyAddress: 'Company address',
companyPib: 'Company pib',
},
};
this.connectorService.sendGetMerchantResponse(message);
}
}