0.0.5 • Published 3 months ago

ww-lcp-wallet v0.0.5

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 months ago

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

  • with deploy token:
  "package_name": "git+https://<user_deploy_token>:<deploy_token>@<GitLab hostname>:<username>/<repository>.git"
  • with setting ssh key, branch:
  "package_name": "git+ssh://git@<GitLab hostname>:<username>/<repository>.git#<branch-name>"
  • with version tag:
  "package_name": "git+ssh://git@<GitLab hostname>:<username>/<repository>.git#<version-tag>"

example

  • with deploy token:
  "ww-digital-wallet": "git+https://gitlab+deploy-token-2231371:HpQoiHRQii6qja_22zBL@gitlab.com/iecgames/virtual-girlfriend/ww-digital-wallet.git#1.0.3"
  • with http:
"ww-digital-wallet": "https://gitlab.com/iecgames/virtual-girlfriend/ww-digital-wallet.git#1.0.3"
  • with ssh:
  "ww-digital-wallet": "git+ssh://git@gitlab.com/iecgames/virtual-girlfriend/ww-digital-wallet.git#package/sdk"
  "ww-digital-wallet": "git+ssh://git@gitlab.com/iecgames/virtual-girlfriend/ww-digital-wallet.git#1.0.3"

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);
}