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