@pillarwallet/common-services

4.7.148 • Public • Published

common-services

A module that provides access to common services.

Updating this README.md

Run npm run generateReadme to parse the code for JSDoc comment blocks and recreate this README.md file.

Install

Run npm i @pillarwallet/common-services

Examples

Instantiate a badges service:
@param - (loggerPath - optional) Specify the file path to which log records are written
@param - (logToFile - optional - default false). Set true to enable logging to a file and file rotation
@param - (dbModels - optional) Pass the Badge and BadgeAward mongoose objects (need for the backend integration)

const { Badge, BadgeAward } = require('@pillarwallet/common-models').platform;
const { buildBadgeService } = require('@pillarwallet/common-services');

const BadgeService = buildBadgeService({
  loggerPath: '',
  logToFile: false,
  dbModels: { Badge, BadgeAward },
});

Instantiate a notification service:
@param - (sqsConfiguration - required) Pass the SQS configuration object
@param - (dbModels - optional) Pass the Badge mongoose object (need for the backend integration)

const config = require('../../src/config');
const { Badge } = require('@pillarwallet/common-models').platform;
const { buildNotificationService } = require('@pillarwallet/common-services');

const notificationService = buildNotificationService({
  sqsConfiguration: { region: 'us-east-1', queueUrl: 'https://sqs.us-east-1.amazonaws.com/testing/test.fifo', fifoQueue: true },
  dbModels: { Badge },
});

API

Members

Constructor

This is the constructor of the BadgeService instance. It allows to set the Configuration keys:

onUserRegistered

Method that awards user with a badge for the registration

onWalletImported

Method that awards user with a badge for the imported wallet

onConnectionEstablished

Method that awards user with a badge for the first connection

onTransactionMade

Method that awards user with a badge for the first transaction made

onTransactionReceived

Method that awards user with a badge for the first transaction received

selfAward

Method to award yourself with a badge

Constructor

This is the constructor of the NotificationService instance.

retryMessage

Method to log error and call method sendMessage if corresponds

sendMessage

Method to send a message to SQS

createBadgesNotification

Method that creates a Badge notification and put the message in SQS

onUserRegisteredBadgeNotification

Method that creates badge notification with type: wallet-created

onWalletImportedBadgeNotification

Method that creates badge notification with type: wallet-imported

onConnectionEstablishedBadgeNotification

Method that creates badge notification with type: first-connection-established

onTransactionMadeBadgeNotification

Method that creates badge notification with type: first-transaction-made

onTransactionReceivedBadgeNotification

Method that creates badge notification with type: first-transaction-received

Constructor ⇒

This is the constructor of the BadgeService instance. It allows to set the Configuration keys:

Kind: global variable
Returns: Object

Param Type Description
[loggerPath] String Specify the file path to which log records are written
[logToFile] Boolean Enables logging to a file and file rotation
[dbModels] Object Pass the Badge and BadgeAward mongoose objects

onUserRegistered ⇒

Method that awards user with a badge for the registration

Kind: global variable
Returns: Promise

Param Type Description
[walletId] String Wallet ID
[userId] String User ID

onWalletImported ⇒

Method that awards user with a badge for the imported wallet

Kind: global variable
Returns: Promise

Param Type Description
[walletId] String Wallet ID
[userId] String User ID

onConnectionEstablished ⇒

Method that awards user with a badge for the first connection

Kind: global variable
Returns: Promise

Param Type Description
[walletId] String Wallet ID
[userId] String User ID

onTransactionMade ⇒

Method that awards user with a badge for the first transaction made

Kind: global variable
Returns: Promise

Param Type Description
[walletId] String Wallet ID
[userId] String User ID

onTransactionReceived ⇒

Method that awards user with a badge for the first transaction received

Kind: global variable
Returns: Promise

Param Type Description
[walletId] String Wallet ID
[userId] String User ID

selfAward ⇒

Method to award yourself with a badge

Kind: global variable
Returns: Promise

Param Type Description
[badgeType] String Badge name
[walletId] String Wallet ID
[userId] String User ID

Constructor ⇒

This is the constructor of the NotificationService instance.

Kind: global variable
Returns: Object

Param Type Description
[sqsConfiguration] Object SQS configuration object
[dbModels] Object Pass the Badge mongoose object

retryMessage

Method to log error and call method sendMessage if corresponds

Kind: global variable

sendMessage

Method to send a message to SQS

Kind: global variable

Param Type Description
[message] Object The message object

createBadgesNotification

Method that creates a Badge notification and put the message in SQS

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

onUserRegisteredBadgeNotification

Method that creates badge notification with type: wallet-created

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

onWalletImportedBadgeNotification

Method that creates badge notification with type: wallet-imported

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

onConnectionEstablishedBadgeNotification

Method that creates badge notification with type: first-connection-established

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

onTransactionMadeBadgeNotification

Method that creates badge notification with type: first-transaction-made

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

onTransactionReceivedBadgeNotification

Method that creates badge notification with type: first-transaction-received

Kind: global variable

Param Type Description
[wallet] Object The wallet object from the recipient user

Readme

Keywords

none

Package Sidebar

Install

npm i @pillarwallet/common-services

Weekly Downloads

0

Version

4.7.148

License

ISC

Unpacked Size

42 kB

Total Files

15

Last publish

Collaborators

  • pillarproject
  • rafaelcidade