| | |
| | | PhoneMesssageCodeLoginInput, |
| | | RequestConfig, |
| | | } from './lifeRechargeServices'; |
| | | import { IRequest, BlLifeRechargeOptions } from './types'; |
| | | import { BlLifeRechargeOptions } from './types'; |
| | | import { LifeRechargeConstants } from './lifeRechargeConstants'; |
| | | import { BlLifeRechargeAccountModel } from './lifeRechargeAccountModel'; |
| | | |
| | | export class BlLifeRecharge<T extends IRequest = IRequest> { |
| | | services: BlLifeRechargeServices<T>; |
| | | export class BlLifeRecharge<TResponse = any, TRequestOptions = any> { |
| | | services: BlLifeRechargeServices<TResponse, TRequestOptions>; |
| | | accountModel: BlLifeRechargeAccountModel; |
| | | |
| | | static constants = LifeRechargeConstants; |
| | | constants = LifeRechargeConstants; |
| | | |
| | | constructor(options: BlLifeRechargeOptions<T>) { |
| | | this.services = new BlLifeRechargeServices(options); |
| | | constructor(options: BlLifeRechargeOptions<TResponse, TRequestOptions>) { |
| | | this.services = new BlLifeRechargeServices(this, options); |
| | | this.accountModel = new BlLifeRechargeAccountModel({ |
| | | userId: options.userId, |
| | | phoneNumber: options.phoneNumber, |
| | | channlesNum: options.channlesNum, |
| | | }); |
| | | } |
| | | |
| | | async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) { |
| | | let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options); |
| | | this.accountModel.setUserId(res); |
| | | this.accountModel.setPhoneNumber(body.phoneNumber); |
| | | return res; |
| | | try { |
| | | let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options); |
| | | this.accountModel.setUserId(res); |
| | | this.accountModel.setPhoneNumber(body.phoneNumber); |
| | | return res; |
| | | } catch (error) { |
| | | throw new Error(error); |
| | | } |
| | | } |
| | | |
| | | loginout() { |
| | |
| | | } |
| | | |
| | | getRechargeParValue(amount: number | string, rate: number) { |
| | | return (Number(amount) * rate).toFixed(2); |
| | | return ((Number(amount) * rate) / 100).toFixed(2); |
| | | } |
| | | |
| | | MaxParValue = 300; |
| | | |
| | | filterParValueList(parValueList: string[]) { |
| | | return parValueList.filter((x) => Number(x) <= this.MaxParValue); |
| | | } |
| | | } |