Browse Source

add inbound delete api

pull/1/head
InKwon James Kim 5 years ago
parent
commit
aba8fd6949
  1. 6
      GME Remit/APIs/Router/APIRouter.swift
  2. 11
      GME Remit/Modules/Login/User Interface/View/Login.storyboard
  3. 12
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Interactor/InboundAccountsInteractor.swift
  4. 1
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Interactor/InboundAccountsInteractorIO.swift
  5. 8
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Service/InboundAccountsService.swift
  6. 6
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Service/InboundAccountsServiceType.swift
  7. 6
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/User Interface/Presenter/InboundAccountsPresenter.swift
  8. 9
      GME Remit/Modules/ManageAccountsModules/InboundAccounts/User Interface/View/InboundAccountsViewController.swift

6
GME Remit/APIs/Router/APIRouter.swift

@ -74,6 +74,7 @@ enum APIRouter {
case penneyTestCertified(model: PenneyTestVerify)
case fetchInboundAccounts
case fetchInboundTransactionHistory(from: String, to: String)
case deleteInboundAccount(model: InboundAccount)
}
// MARK: - Request
@ -482,6 +483,9 @@ extension APIRouter {
case .fetchInboundTransactionHistory:
let senderId = GMEDB.shared.user.string(.senderId) ?? ""
return "\(baseUrl)/inbound/mobile/tranHistory/\(senderId)"
case .deleteInboundAccount(let model):
let senderId = GMEDB.shared.user.string(.senderId) ?? ""
return "\(baseUrl)/inbound/mobile/deleteInboundAccount/\(senderId)/\(model.accountNo ?? "")"
}
}
}
@ -560,6 +564,8 @@ extension APIRouter {
return .post
case .fetchInboundTransactionHistory:
return .post
case .deleteInboundAccount:
return .post
}
}

11
GME Remit/Modules/Login/User Interface/View/Login.storyboard

@ -77,16 +77,16 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="qZ0-Mc-eUA">
<rect key="frame" x="85" y="442" width="150" height="35"/>
<rect key="frame" x="80.5" y="442" width="159.5" height="35"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="New to GME?" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vyR-zb-CBC">
<rect key="frame" x="0.0" y="0.0" width="67" height="35"/>
<rect key="frame" x="0.0" y="0.0" width="75.5" height="35"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="12"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GFb-Or-Tqp">
<rect key="frame" x="77" y="0.0" width="73" height="35"/>
<rect key="frame" x="85.5" y="0.0" width="74" height="35"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="12"/>
<state key="normal" title="Register Here">
<color key="titleColor" name="ThemeBlue"/>
@ -137,7 +137,7 @@ Global Money Express</string>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dKp-tX-RZc">
<rect key="frame" x="106" y="405" width="108" height="29"/>
<rect key="frame" x="103" y="405" width="114" height="29"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="14"/>
<state key="normal" title="Forgot password?">
<color key="titleColor" name="ThemeRed"/>
@ -216,9 +216,6 @@ Global Money Express</string>
<namedColor name="ThemeRed">
<color red="0.92941176470588238" green="0.10588235294117647" blue="0.14117647058823529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="ThemeRed">
<color red="0.92900002002716064" green="0.10599999874830246" blue="0.14100000262260437" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="ThemeText">
<color red="0.28999999165534973" green="0.28999999165534973" blue="0.28999999165534973" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>

12
GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Interactor/InboundAccountsInteractor.swift

@ -36,4 +36,16 @@ extension InboundAccountsInteractor: InboundAccountsInteractorInput {
}
)
}
func delete(with account: InboundAccount) {
service.delete(
with: account,
success: {[weak self] in
},
failure: {[weak self] in
self?.output?.setError(with: $0)
}
)
}
}

1
GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Interactor/InboundAccountsInteractorIO.swift

@ -8,6 +8,7 @@
protocol InboundAccountsInteractorInput: class {
func fetchAccounts()
func delete(with account: InboundAccount)
}
protocol InboundAccountsInteractorOutput: class {

8
GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Service/InboundAccountsService.swift

@ -15,4 +15,12 @@ class InboundAccountsService: InboundAccountsServiceType {
) {
APIRouter.fetchInboundAccounts.json(success: success, failure: failure)
}
func delete(
with account: InboundAccount,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
) {
APIRouter.deleteInboundAccount(model: account).json(success: success, failure: failure)
}
}

6
GME Remit/Modules/ManageAccountsModules/InboundAccounts/Application Logic/Service/InboundAccountsServiceType.swift

@ -11,4 +11,10 @@ protocol InboundAccountsServiceType: class {
success: @escaping ([InboundAccount]) -> Void,
failure: @escaping (Error) -> Void
)
func delete(
with account: InboundAccount,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
)
}

6
GME Remit/Modules/ManageAccountsModules/InboundAccounts/User Interface/Presenter/InboundAccountsPresenter.swift

@ -18,6 +18,7 @@ class InboundAccountsPresenter: ViewModelType {
let add: Driver<Void>
let pennyTest: Driver<PenneyTestRequest>
let refresh: Driver<Void>
let delete: Driver<InboundAccount>
}
struct Output {
@ -51,6 +52,11 @@ class InboundAccountsPresenter: ViewModelType {
self?.interactor?.fetchAccounts()
}).disposed(by: disposeBag)
input.delete.drive(onNext: {[weak self] in
self?.progressLinker.onNext(true)
self?.interactor?.delete(with: $0)
}).disposed(by: disposeBag)
return Output(
isError: errorLinker.asDriverOnErrorJustComplete(),
isProgress: progressLinker.asDriverOnErrorJustComplete(),

9
GME Remit/Modules/ManageAccountsModules/InboundAccounts/User Interface/View/InboundAccountsViewController.swift

@ -26,6 +26,7 @@ class InboundAccountsViewController: UIViewController {
private var otherAccounts: [InboundAccount]?
private let openPenneyTest = PublishSubject<PenneyTestRequest>()
private let delete = PublishSubject<InboundAccount>()
private let refreshControl = UIRefreshControl()
@ -103,7 +104,8 @@ extension InboundAccountsViewController {
viewWillAppear: viewWillAppear,
add: addButton.rx.tap.asDriverOnErrorJustComplete(),
pennyTest: openPenneyTest.asDriverOnErrorJustComplete(),
refresh: refreshControl.rx.controlEvent(.valueChanged).asDriverOnErrorJustComplete()
refresh: refreshControl.rx.controlEvent(.valueChanged).asDriverOnErrorJustComplete(),
delete: delete.asDriverOnErrorJustComplete()
)
let output = presenter.transform(input: input)
@ -194,8 +196,9 @@ extension InboundAccountsViewController: InboundAccountCellDelegate {
title: "Delete Account",
okTitle: "Delete",
cancelTitle: "Cancel",
okAction: {
print("Delete account: \(model?.bankName ?? "nil")")
okAction: {[weak self] in
guard let account = model else { return }
self?.delete.onNext(account)
},
cancelAction: nil
)

Loading…
Cancel
Save