4.7.148 • Published 4 years ago

@pillarwallet/common-services v4.7.148

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

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:

Kind: global variable
Returns: Object

ParamTypeDescription
loggerPathStringSpecify the file path to which log records are written
logToFileBooleanEnables logging to a file and file rotation
dbModelsObjectPass the Badge and BadgeAward mongoose objects

onUserRegistered ⇒

Method that awards user with a badge for the registration

Kind: global variable
Returns: Promise

ParamTypeDescription
walletIdStringWallet ID
userIdStringUser ID

onWalletImported ⇒

Method that awards user with a badge for the imported wallet

Kind: global variable
Returns: Promise

ParamTypeDescription
walletIdStringWallet ID
userIdStringUser ID

onConnectionEstablished ⇒

Method that awards user with a badge for the first connection

Kind: global variable
Returns: Promise

ParamTypeDescription
walletIdStringWallet ID
userIdStringUser ID

onTransactionMade ⇒

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

Kind: global variable
Returns: Promise

ParamTypeDescription
walletIdStringWallet ID
userIdStringUser ID

onTransactionReceived ⇒

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

Kind: global variable
Returns: Promise

ParamTypeDescription
walletIdStringWallet ID
userIdStringUser ID

selfAward ⇒

Method to award yourself with a badge

Kind: global variable
Returns: Promise

ParamTypeDescription
badgeTypeStringBadge name
walletIdStringWallet ID
userIdStringUser ID

Constructor ⇒

This is the constructor of the NotificationService instance.

Kind: global variable
Returns: Object

ParamTypeDescription
sqsConfigurationObjectSQS configuration object
dbModelsObjectPass 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

ParamTypeDescription
messageObjectThe message object

createBadgesNotification

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

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user

onUserRegisteredBadgeNotification

Method that creates badge notification with type: wallet-created

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user

onWalletImportedBadgeNotification

Method that creates badge notification with type: wallet-imported

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user

onConnectionEstablishedBadgeNotification

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

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user

onTransactionMadeBadgeNotification

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

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user

onTransactionReceivedBadgeNotification

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

Kind: global variable

ParamTypeDescription
walletObjectThe wallet object from the recipient user