ww-lcp-wallet
v0.0.8
Published
Digital-Wallet is a SDK help connect db and process action related wallet, items, currency,..
Downloads
11
Readme
Digital-Wallet is a SDK help connect db and process action related wallet, items, currency,..
Note
Whenever there is a need to update something in this SDK, it is required to rebuild the project using the command npm run build
and push the entire dist directory.
The usage of this SDK project as a package in another project is restricted to authorized individuals only.
Features
- checkHealth(): Promise
- createCurrency(data: ICurrencyCreate): Promise
- updateCurrency(data: ICurrencyUpdate): Promise
- queryCurrency(data: ICurrencyQuery): Promise
- getCurrency(payload: ICurrencyDetail): Promise
- createExchangeConfig(data: IExchangeConfigCreate): Promise
- updateExchangeConfig(data: IExchangeConfigUpdate): Promise
- queryExchangeConfig(data: IExchangeConfigQuery): Promise
- getDetailExchangeConfig(payload: IExchangeConfigDetail): Promise
- createItem(data: IItemCreate): Promise
- updateItem(data: IItemUpdate): Promise
- getDetailItem(payload: IItemDetail): Promise
- queryItem(data: IItemQuery): Promise
- consumeItem(data: IItemConsume): Promise
- createUserItem(data: IUserItemCreate): Promise
- updateUserItem(data: IUserItemUpdate): Promise
- queryUserItem(data: IUserItemQuery): Promise
- createWalletTransaction(data: ITransactionCreate): Promise
- rollbackWalletTransaction(data: ITransactionRollback): Promise
- exchangeCurrencyTransaction(data: IExchangeCurrency): Promise
- getUserBalanceByCurrency(data: IGetBalanceUserCurrency): Promise
- getUserBalance(payload: IGetAllBalanceUser): Promise
- queryTransaction(payload: ITransactionQuery): Promise
- createItemPrice(data: IItemPriceCreate): Promise
- updateItemPrice(data: IItemPriceUpdate): Promise And more...
Install
add dependency in package.json file
- package name: https://www.npmjs.com/package/ww-lcp-wallet
Usage in NestJS
import { DigitalWalletModule } from "ww-digital-wallet/dist";
@Module({
imports: [
DigitalWalletModule.forRoot({
sequelizeConfigs: {
// "mysql" | "postgres" | "sqlite" | "mariadb" |..
dialect: "postgres",
host: "host",
port: "port",
username: "username",
password: "password",
database: "database",
logging: false,
timezone: "+07:00",
},
// config when use inapp-purchase
// optional
googleCloudServiceConfigs: {
clientEmail: "string",
privateKey: "string",
},
// optional
googlePlayConfigs: {
googlePublicKeyPath: "string",
googlePublicKeyStrSandBox: "string",
googlePublicKeyStrLive: "string",
},
// optional
appleStoreConfigs: {
password: "string",
},
}),
],
controllers: [],
providers: [],
})
export class AppModule {}
And using, inject your service:
import { DigitalWalletService } from "ww-digital-wallet/dist";
@Injectable()
export class AppService {
constructor(private readonly digitalWalletService: DigitalWalletService) {}
async checkHealth() {
return await this.digitalWalletService.checkHealth();
}
}
Configuration
export interface AppleStoreConfigs {
password: string;
}
export interface GoogleCloudSericeConfigs {
clientEmail: string;
privateKey: string;
}
export interface GooglePlayConfigs {
googlePublicKeyPath: string;
googlePublicKeyStrSandBox?: string;
googlePublicKeyStrLive?: string;
}
export interface DigitalWalletConfigOptions {
sequelizeConfigs: SequelizeConfigOptions;
googleCloudServiceConfigs?: GoogleCloudSericeConfigs;
googlePlayConfigs?: GooglePlayConfigs;
appleStoreConfigs?: AppleStoreConfigs;
}
export type Dialect =
| "mysql"
| "postgres"
| "sqlite"
| "mariadb"
| "mssql"
| "mariadb";
export interface SequelizeConfigOptions {
/**
* The dialect of the database you are connecting to. One of mysql, postgres, sqlite, mariadb and mssql.
*
* @default 'mysql'
*/
dialect?: Dialect;
/**
* The name of the database
*/
database?: string;
/**
* The username which is used to authenticate against the database.
*/
username?: string;
/**
* The password which is used to authenticate against the database.
*/
password?: string;
/**
* The host of the relational database.
*
* @default 'localhost'
*/
host?: string;
/**
* The port of the relational database.
*/
port?: number;
/**
* The timezone used when converting a date from the database into a JavaScript date. The timezone is also
* used to SET TIMEZONE when connecting to the server, to ensure that the result of NOW, CURRENT_TIMESTAMP
* and other time related functions have in the right timezone. For best cross platform performance use the
* format
* +/-HH:MM. Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles');
* this is useful to capture daylight savings time changes.
*
* @default '+00:00'
*/
timezone?: string;
/**
* A function that gets executed while running the query to log the sql.
*/
logging?: boolean | ((sql: string, timing?: number) => void);
}