Browse Source

password added in model

pull/1/head
gme_2 6 years ago
parent
commit
551e547aa0
  1. 1
      GMERemittance/Module/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift
  2. 6
      GMERemittance/Module/SendMoneyVerification/Application Logic/Interactor/SendMoneyVerificationInteractor.swift
  3. 3
      GMERemittance/Module/SendMoneyVerification/Application Logic/Interactor/SendMoneyVerificationInteractorIO.swift
  4. 23
      GMERemittance/Module/SendMoneyVerification/Application Logic/Service/SendMoneyVerificationServiceType.swift
  5. 11
      GMERemittance/Module/SendMoneyVerification/User Interface/Presenter/SendMoneyVerificationPresenter.swift
  6. 55
      GMERemittance/Module/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift
  7. 1
      GMERemittance/Module/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewInterface.swift
  8. 2
      GMERemittance/Recipient/RecipientListViewController.storyboard

1
GMERemittance/Module/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift

@ -40,6 +40,7 @@ class SendMoneyRequestModel {
var accountNumber: String?
var payingAmount: String?
var exchangeRateDetail: SendMoneyExchangeRateModel?
var transactionPassword: String?
}
class SendMoneyParentViewController: UIViewController {

6
GMERemittance/Module/SendMoneyVerification/Application Logic/Interactor/SendMoneyVerificationInteractor.swift

@ -30,7 +30,11 @@ extension SendMoneyVerificationInteractor: SendMoneyVerificationInteractorInput
func submit(model: SendMoneyRequestModel, reciepient: Recipient) {
guard let username = UserDefaults.standard.value(forKey: UserKeys.userId) as? String else {return}
let params = self.getParams(model: model, reciepient: reciepient, userName: username)
self.service.submit(params: params, success: { (response) in
self.output?.show(model: response)
}) { (error) in
self.output?.show(error: error)
}
}
func getParams(model: SendMoneyRequestModel, reciepient: Recipient, userName: String) -> [String: String] {

3
GMERemittance/Module/SendMoneyVerification/Application Logic/Interactor/SendMoneyVerificationInteractorIO.swift

@ -11,5 +11,6 @@ protocol SendMoneyVerificationInteractorInput: class {
}
protocol SendMoneyVerificationInteractorOutput: class {
func show(error: Error)
func show(model: SendMoneySubmitModel?)
}

23
GMERemittance/Module/SendMoneyVerification/Application Logic/Service/SendMoneyVerificationServiceType.swift

@ -8,11 +8,30 @@
import Foundation
protocol SendMoneyVerificationServiceType: class {
protocol SendMoneyVerificationServiceType: class, SendMoneyVerificationSubmitApi {
}
protocol SendMoneyVerificationSubmitApi: ApiServiceType {
func submit(params: [String: String])
func submit(params: [String: String], success: @escaping (SendMoneySubmitModel?) -> (), failure: @escaping (Error) -> ())
}
extension SendMoneyVerificationSubmitApi {
func submit(params: [String: String], success: @escaping (SendMoneySubmitModel?) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "mobile/sendmoney/dotransaction"
self.auth.request(method: .post, url: url, params: params, success: { (response: SendMoneySubmitModelContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}else {
let model = response.data
success(model)
}
}) { (error) in
failure(error)
}
}
}

11
GMERemittance/Module/SendMoneyVerification/User Interface/Presenter/SendMoneyVerificationPresenter.swift

@ -25,6 +25,7 @@ class SendMoneyVerificationPresenter {
extension SendMoneyVerificationPresenter: SendMoneyVerificationModuleInterface {
func submit(model: SendMoneyRequestModel, reciepient: Recipient) {
self.view?.showLoading()
self.interactor?.submit(model: model, reciepient: reciepient)
}
}
@ -32,5 +33,15 @@ extension SendMoneyVerificationPresenter: SendMoneyVerificationModuleInterface {
// MARK: SendMoneyVerification interactor output interface
extension SendMoneyVerificationPresenter: SendMoneyVerificationInteractorOutput {
func show(error: Error) {
self.view?.hideLoading()
self.view?.show(error: error.localizedDescription)
}
func show(model: SendMoneySubmitModel?) {
self.view?.hideLoading()
self.view?.show(model: model)
}
}

55
GMERemittance/Module/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift

@ -36,6 +36,15 @@ class SendMoneyVerificationViewController: UITableViewController {
var reciepient: Recipient?
var requestModel: SendMoneyRequestModel?
var hudDelegate: HUDStatusDelegate?
var password: String? {
didSet {
if let model = self.requestModel, let reciepient = self.reciepient {
model.transactionPassword = password ?? ""
self.presenter?.submit(model: model, reciepient: reciepient)
}
}
}
// MARK: VC's Life cycle
@ -59,10 +68,9 @@ class SendMoneyVerificationViewController: UITableViewController {
return
}
self.askPassword()
// submit the request model
if let model = self.requestModel, let reciepient = self.reciepient {
self.presenter?.submit(model: model, reciepient: reciepient)
}
}
// MARK: Other Functions
@ -94,10 +102,48 @@ class SendMoneyVerificationViewController: UITableViewController {
self.serviceChargeLabel.text = self.requestModel?.exchangeRateDetail?.transferFee
self.payoutAgentBankLabel.text = self.requestModel?.bank?.name
}
func askPassword() {
let alertController = UIAlertController(title: "Enter your login password", message: "", preferredStyle: .alert)
alertController.addTextField { (textField : UITextField!) -> Void in
textField.placeholder = "Enter password"
textField.isSecureTextEntry = true
textField.tag = 51
// textField.delegate = self
}
let confirmAction = UIAlertAction(title: "Confirm", style: .default, handler: {
alert -> Void in
let passwordTextField = alertController.textFields![0] as UITextField
if passwordTextField.text! != "" {
self.password = passwordTextField.text!
} else {
self.alert(message: "Password was missing")
}
})
let cancelAction = UIAlertAction(title: "Cancel", style: .destructive, handler: {
(action : UIAlertAction!) -> Void in
})
cancelAction.setValue(UIColor.black, forKey: "titleTextColor")
confirmAction.setValue(UIColor(hex:0xEC1C24), forKey: "titleTextColor")
alertController.addAction(cancelAction)
alertController.addAction(confirmAction)
self.present(alertController, animated: true, completion: nil)
}
}
// MARK: SendMoneyVerificationViewInterface
extension SendMoneyVerificationViewController: SendMoneyVerificationViewInterface {
func show(model: SendMoneySubmitModel?) {
print(model?.charge)
}
func show(error: String) {
self.alert(message: error)
}
@ -116,3 +162,6 @@ extension SendMoneyVerificationViewController {
self.viewWillAppear(true)
}
}

1
GMERemittance/Module/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewInterface.swift

@ -10,4 +10,5 @@ protocol SendMoneyVerificationViewInterface: class {
func show(error: String)
func showLoading()
func hideLoading()
func show(model: SendMoneySubmitModel?)
}

2
GMERemittance/Recipient/RecipientListViewController.storyboard

@ -855,7 +855,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="upto" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dYw-vK-a2G">
<rect key="frame" x="162" y="52.5" width="19" height="12"/>
<rect key="frame" x="162" y="52.5" width="20" height="12"/>
<constraints>
<constraint firstAttribute="height" constant="12" id="d7X-dM-wj1"/>
</constraints>

Loading…
Cancel
Save