import {
|
BlLifeRechargeServices,
|
PhoneMesssageCodeLoginInput,
|
RequestConfig,
|
} from './lifeRechargeServices';
|
import { IRequest, BlLifeRechargeOptions } from './types';
|
import { LifeRechargeConstants } from './lifeRechargeConstants';
|
|
export class BlLifeRecharge<T extends IRequest = IRequest> {
|
services: BlLifeRechargeServices<T>;
|
userId = '';
|
|
static constants = LifeRechargeConstants;
|
constants = LifeRechargeConstants;
|
|
constructor(options: BlLifeRechargeOptions<T>) {
|
this.services = new BlLifeRechargeServices(options);
|
this.userId = options.userId || '';
|
}
|
|
async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) {
|
let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options);
|
this.userId = res;
|
return res;
|
}
|
|
loginout() {
|
this.userId = '';
|
}
|
|
isLogin() {
|
return !!this.userId;
|
}
|
|
getRechargeParValue(amount: number, rate: number) {
|
return (amount * rate).toFixed(2);
|
}
|
}
|