|
@ -51,6 +51,7 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
struct Input { |
|
|
struct Input { |
|
|
let viewWillAppear: Driver<Void> |
|
|
let viewWillAppear: Driver<Void> |
|
|
let selectAutodebit: Driver<Void> |
|
|
let selectAutodebit: Driver<Void> |
|
|
|
|
|
let showBalanceTrigger: Driver<Void> |
|
|
let availableBalance: Driver<String> |
|
|
let availableBalance: Driver<String> |
|
|
let selectedMobile: Driver<String> |
|
|
let selectedMobile: Driver<String> |
|
|
let contactOpenTap: Driver<Void> |
|
|
let contactOpenTap: Driver<Void> |
|
@ -67,6 +68,7 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
let isProgress: Driver<Bool> |
|
|
let isProgress: Driver<Bool> |
|
|
let isEnableNext: Driver<Status> |
|
|
let isEnableNext: Driver<Status> |
|
|
let isSuccessPayment: Driver<Void> |
|
|
let isSuccessPayment: Driver<Void> |
|
|
|
|
|
let getBalance: Driver<BalanceModel?> |
|
|
let bankModel: Driver<[Account]> |
|
|
let bankModel: Driver<[Account]> |
|
|
let regularModel: Driver<[PriceModel]> |
|
|
let regularModel: Driver<[PriceModel]> |
|
|
let fixedModel: Driver<[MainCardInformation]> |
|
|
let fixedModel: Driver<[MainCardInformation]> |
|
@ -82,12 +84,12 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
private let errorLinker = PublishSubject<Error>() |
|
|
private let errorLinker = PublishSubject<Error>() |
|
|
private let isSuccessPayment = PublishSubject<Void>() |
|
|
private let isSuccessPayment = PublishSubject<Void>() |
|
|
private let selectedPaymentMode = PublishSubject<Account?>() |
|
|
private let selectedPaymentMode = PublishSubject<Account?>() |
|
|
|
|
|
|
|
|
|
|
|
private let getBalanceLinker = BehaviorSubject<BalanceModel?>(value: nil) |
|
|
private let regularModel = BehaviorSubject<[PriceModel]>(value: []) |
|
|
private let regularModel = BehaviorSubject<[PriceModel]>(value: []) |
|
|
private let bankModel = BehaviorSubject<[Account]>(value: []) |
|
|
private let bankModel = BehaviorSubject<[Account]>(value: []) |
|
|
private let fixedModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let fixedModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let dataOnlyModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private let dataOnlyModel = BehaviorSubject<[MainCardInformation]>(value: []) |
|
|
private var accounts: [Account]? |
|
|
|
|
|
|
|
|
private var accountType: String? |
|
|
|
|
|
|
|
|
func transform(input: Input) -> Output { |
|
|
func transform(input: Input) -> Output { |
|
|
Driver.combineLatest(input.viewWillAppear, input.selectedMobile, input.selectedRechargeType) |
|
|
Driver.combineLatest(input.viewWillAppear, input.selectedMobile, input.selectedRechargeType) |
|
@ -104,6 +106,14 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
}) |
|
|
}) |
|
|
.disposed(by: disposeBag) |
|
|
.disposed(by: disposeBag) |
|
|
|
|
|
|
|
|
|
|
|
input.showBalanceTrigger.withLatestFrom(selectedPaymentMode.asDriverOnErrorJustComplete()) { $1 } |
|
|
|
|
|
.drive(onNext: { |
|
|
|
|
|
let fintechUseNumber = $0?.fintechUseNumber ?? "" |
|
|
|
|
|
let type = $0?.type ?? "autodebit" |
|
|
|
|
|
self.progressLinker.onNext(true) |
|
|
|
|
|
self.interactor?.fetchBalanceForPowerCall(type: type, fintechUseNumber: fintechUseNumber) |
|
|
|
|
|
}).disposed(by: disposeBag) |
|
|
|
|
|
|
|
|
input.selectAutodebit.drive(onNext: {[weak self] in |
|
|
input.selectAutodebit.drive(onNext: {[weak self] in |
|
|
let model = try? self?.bankModel.value() |
|
|
let model = try? self?.bankModel.value() |
|
|
self?.wireframe?.showPaymentMode(with: model) |
|
|
self?.wireframe?.showPaymentMode(with: model) |
|
@ -159,7 +169,9 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
.map { ( _, mobile, type, priceModel, _, carrierPlan, dataOnlyType) -> RechargeModel? in |
|
|
.map { ( _, mobile, type, priceModel, _, carrierPlan, dataOnlyType) -> RechargeModel? in |
|
|
switch type { |
|
|
switch type { |
|
|
case .regular: |
|
|
case .regular: |
|
|
|
|
|
|
|
|
return RechargeModel( |
|
|
return RechargeModel( |
|
|
|
|
|
paymentType: self.accountType ?? "", |
|
|
type: type.value, |
|
|
type: type.value, |
|
|
chargeType: "", |
|
|
chargeType: "", |
|
|
cardName: "", |
|
|
cardName: "", |
|
@ -168,6 +180,7 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
) |
|
|
) |
|
|
case .fixed: |
|
|
case .fixed: |
|
|
return RechargeModel( |
|
|
return RechargeModel( |
|
|
|
|
|
paymentType: self.accountType ?? "", |
|
|
type: type.value, |
|
|
type: type.value, |
|
|
chargeType: carrierPlan?.cardType ?? "", |
|
|
chargeType: carrierPlan?.cardType ?? "", |
|
|
cardName: carrierPlan?.cardName ?? "", |
|
|
cardName: carrierPlan?.cardName ?? "", |
|
@ -176,6 +189,7 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
) |
|
|
) |
|
|
case .dataOnly: |
|
|
case .dataOnly: |
|
|
return RechargeModel( |
|
|
return RechargeModel( |
|
|
|
|
|
paymentType: self.accountType ?? "", |
|
|
type: type.value, |
|
|
type: type.value, |
|
|
chargeType: dataOnlyType?.cardCode ?? "", |
|
|
chargeType: dataOnlyType?.cardCode ?? "", |
|
|
cardName: dataOnlyType?.cardName ?? "", |
|
|
cardName: dataOnlyType?.cardName ?? "", |
|
@ -193,6 +207,7 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
isProgress: progressLinker.asDriverOnErrorJustComplete(), |
|
|
isProgress: progressLinker.asDriverOnErrorJustComplete(), |
|
|
isEnableNext: isEnableNext.asDriverOnErrorJustComplete(), |
|
|
isEnableNext: isEnableNext.asDriverOnErrorJustComplete(), |
|
|
isSuccessPayment: isSuccessPayment.asDriverOnErrorJustComplete(), |
|
|
isSuccessPayment: isSuccessPayment.asDriverOnErrorJustComplete(), |
|
|
|
|
|
getBalance: getBalanceLinker.asDriverOnErrorJustComplete(), |
|
|
bankModel: bankModel.asDriverOnErrorJustComplete(), |
|
|
bankModel: bankModel.asDriverOnErrorJustComplete(), |
|
|
regularModel: regularModel.asDriverOnErrorJustComplete(), |
|
|
regularModel: regularModel.asDriverOnErrorJustComplete(), |
|
|
fixedModel: fixedModel.asDriverOnErrorJustComplete(), |
|
|
fixedModel: fixedModel.asDriverOnErrorJustComplete(), |
|
@ -206,6 +221,13 @@ class PhoneCardRechargePresenter: ViewModelType { |
|
|
|
|
|
|
|
|
// MARK: PhoneCardRecharge interactor output interface |
|
|
// MARK: PhoneCardRecharge interactor output interface |
|
|
extension PhoneCardRechargePresenter: PhoneCardRechargeInteractorOutput { |
|
|
extension PhoneCardRechargePresenter: PhoneCardRechargeInteractorOutput { |
|
|
|
|
|
|
|
|
|
|
|
func setBalance(with model: BalanceModel) { |
|
|
|
|
|
progressLinker.onNext(false) |
|
|
|
|
|
getBalanceLinker.onNext(model) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func setModel(with model: [Account]) { |
|
|
func setModel(with model: [Account]) { |
|
|
progressLinker.onNext(false) |
|
|
progressLinker.onNext(false) |
|
|
bankModel.onNext(model) |
|
|
bankModel.onNext(model) |
|
|