Browse Source

implemented api

pull/1/head
devikkim 5 years ago
parent
commit
cffe3d6036
  1. 16
      GME Remit.xcodeproj/project.pbxproj
  2. BIN
      GMERemittance/.DS_Store
  3. 2
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Interactor/RedeemInteractorIO.swift
  4. 26
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/Branch.swift
  5. 32
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/BranchContainer.swift
  6. 33
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/Redeem.swift
  7. 74
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Service/RedeemService.swift
  8. 2
      GMERemittance/Module/RewardModule/Redeem/Application Logic/Service/RedeemServiceType.swift
  9. 10
      GMERemittance/Module/RewardModule/Redeem/User Interface/Presenter/RedeemPresenter.swift
  10. 98
      GMERemittance/Module/RewardModule/Redeem/User Interface/View/RedeemViewController.swift
  11. 5
      GMERemittance/Module/RewardModule/Redeem/User Interface/View/RedeemViewInterface.swift
  12. 2
      GMERemittance/Payment/_Branch.swift

16
GME Remit.xcodeproj/project.pbxproj

@ -49,7 +49,7 @@
044124C61FEBA1BD00FD4240 /* ResetPasswordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044124C31FEBA1BC00FD4240 /* ResetPasswordViewModel.swift */; };
044124C71FEBA1BD00FD4240 /* FillRecoveryCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044124C41FEBA1BC00FD4240 /* FillRecoveryCodeViewController.swift */; };
0448C2A11FF34D9C001FEA77 /* RecipientViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0448C2A01FF34D9C001FEA77 /* RecipientViewModel.swift */; };
04498A70203833D700AC4D99 /* Branch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04498A6F203833D700AC4D99 /* Branch.swift */; };
04498A70203833D700AC4D99 /* _Branch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04498A6F203833D700AC4D99 /* _Branch.swift */; };
04498A722039416E00AC4D99 /* SettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04498A712039416E00AC4D99 /* SettingViewController.swift */; };
044F5B1B20A3002B00E3584C /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 044F5B1A20A3002B00E3584C /* index.html */; };
04546C4120329A36007EFE15 /* AboutGMEViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04546C4020329A36007EFE15 /* AboutGMEViewController.swift */; };
@ -241,6 +241,8 @@
7310475C226960E70025D77D /* KeychainTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7310475B226960E70025D77D /* KeychainTest.swift */; };
731154CA227BF4CA00FEBF7F /* Redeem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154C9227BF4CA00FEBF7F /* Redeem.swift */; };
731154CC227C178A00FEBF7F /* APITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154CB227C178A00FEBF7F /* APITest.swift */; };
731154CE227C430C00FEBF7F /* Branch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154CD227C430C00FEBF7F /* Branch.swift */; };
731154D0227C43E900FEBF7F /* BranchContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154CF227C43E900FEBF7F /* BranchContainer.swift */; };
736A8C402277EB2A00337A50 /* BiometricAuthenticationNotificationModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C2D2277EB2900337A50 /* BiometricAuthenticationNotificationModuleInterface.swift */; };
736A8C412277EB2A00337A50 /* BiometricAuthenticationNotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C312277EB2900337A50 /* BiometricAuthenticationNotificationService.swift */; };
736A8C422277EB2A00337A50 /* BiometricAuthenticationNotificationServiceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C322277EB2900337A50 /* BiometricAuthenticationNotificationServiceType.swift */; };
@ -2265,7 +2267,7 @@
044124C31FEBA1BC00FD4240 /* ResetPasswordViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResetPasswordViewModel.swift; sourceTree = "<group>"; };
044124C41FEBA1BC00FD4240 /* FillRecoveryCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FillRecoveryCodeViewController.swift; sourceTree = "<group>"; };
0448C2A01FF34D9C001FEA77 /* RecipientViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipientViewModel.swift; sourceTree = "<group>"; };
04498A6F203833D700AC4D99 /* Branch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Branch.swift; sourceTree = "<group>"; };
04498A6F203833D700AC4D99 /* _Branch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _Branch.swift; sourceTree = "<group>"; };
04498A712039416E00AC4D99 /* SettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingViewController.swift; sourceTree = "<group>"; };
044F5B1A20A3002B00E3584C /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
04546C4020329A36007EFE15 /* AboutGMEViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutGMEViewController.swift; sourceTree = "<group>"; };
@ -2462,6 +2464,8 @@
7310475B226960E70025D77D /* KeychainTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainTest.swift; sourceTree = "<group>"; };
731154C9227BF4CA00FEBF7F /* Redeem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Redeem.swift; sourceTree = "<group>"; };
731154CB227C178A00FEBF7F /* APITest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APITest.swift; sourceTree = "<group>"; };
731154CD227C430C00FEBF7F /* Branch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Branch.swift; sourceTree = "<group>"; };
731154CF227C43E900FEBF7F /* BranchContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BranchContainer.swift; sourceTree = "<group>"; };
736A8C2D2277EB2900337A50 /* BiometricAuthenticationNotificationModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricAuthenticationNotificationModuleInterface.swift; sourceTree = "<group>"; };
736A8C312277EB2900337A50 /* BiometricAuthenticationNotificationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricAuthenticationNotificationService.swift; sourceTree = "<group>"; };
736A8C322277EB2900337A50 /* BiometricAuthenticationNotificationServiceType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricAuthenticationNotificationServiceType.swift; sourceTree = "<group>"; };
@ -4901,7 +4905,7 @@
0474678B203C4A0100F6A583 /* PdfComposer.swift */,
04F6C2E920109B8600C59431 /* Bank.swift */,
042E7F292010E908006A5176 /* Cdd.swift */,
04498A6F203833D700AC4D99 /* Branch.swift */,
04498A6F203833D700AC4D99 /* _Branch.swift */,
A270F08E2075E34C00B78D00 /* PayoutMode.swift */,
A2336582207DD44C0078DD77 /* BankBranch.swift */,
A248EA872088855B008D28DF /* Currrency.swift */,
@ -5670,6 +5674,8 @@
isa = PBXGroup;
children = (
731154C9227BF4CA00FEBF7F /* Redeem.swift */,
731154CD227C430C00FEBF7F /* Branch.swift */,
731154CF227C43E900FEBF7F /* BranchContainer.swift */,
);
path = Model;
sourceTree = "<group>";
@ -13430,6 +13436,7 @@
043770EF21AD04240005B22D /* PennyTestViewInterface.swift in Sources */,
730197A622535135001954AB /* kycForm3Presenter.swift in Sources */,
A2D2C5902032ACDA001FC8E5 /* TransactionSearchTableViewCell.swift in Sources */,
731154D0227C43E900FEBF7F /* BranchContainer.swift in Sources */,
D922D9AC21351B7400D43053 /* SendMoneyVerificationInteractor.swift in Sources */,
A25A6C0B2029BBCE0024CDFB /* TranscationTableViewCell.swift in Sources */,
730197AA22535135001954AB /* kycForm3ViewInterface.swift in Sources */,
@ -13510,7 +13517,7 @@
9FCBD34B202B179600BAEB32 /* PayoutTableViewCell.swift in Sources */,
730197A522535135001954AB /* kycForm3Interactor.swift in Sources */,
D922D94A2135124200D43053 /* SendMoneyPaymentModeViewInterface.swift in Sources */,
04498A70203833D700AC4D99 /* Branch.swift in Sources */,
04498A70203833D700AC4D99 /* _Branch.swift in Sources */,
D9380D2D2165A2ED00E45156 /* ProfileViewController.swift in Sources */,
722347F2205A8FF600296ADD /* SocialFeedViewModel.swift in Sources */,
D945F122213E1D5100A24824 /* SendMoneyReceiptPresenter.swift in Sources */,
@ -13544,6 +13551,7 @@
9FA09740200E129500F3B5EC /* CommentsViewController.swift in Sources */,
D92E656A222620A0004D1B3D /* SendMoneyCodeInteractorIO.swift in Sources */,
D950BEDE215496F6008367A1 /* HomeRemainingLimitTableViewCell.swift in Sources */,
731154CE227C430C00FEBF7F /* Branch.swift in Sources */,
A2E3379F204911CA002DB015 /* PopUpInviteeDetail.swift in Sources */,
0430986C2029EF4B00821C70 /* TrackTransactionTableViewCell.swift in Sources */,
D922D98721351AAE00D43053 /* SendMoneyExchangeRateInteractorIO.swift in Sources */,

BIN
GMERemittance/.DS_Store

2
GMERemittance/Module/RewardModule/Redeem/Application Logic/Interactor/RedeemInteractorIO.swift

@ -14,7 +14,7 @@ protocol RedeemInteractorInput: class {
protocol RedeemInteractorOutput: class {
func result(model: RewardProduct?)
func setBranches(with model: [GmeContacts]?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()

26
GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/Branch.swift

@ -0,0 +1,26 @@
//
// Branch.swift
// GME Remit
//
// Created by InKwon Devik Kim on 03/05/2019.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
import ObjectMapper
struct Branch: Mappable {
var agentID: String?
var agentName: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
self.agentID <- map["agentId"]
self.agentName <- map["agentName"]
}
}

32
GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/BranchContainer.swift

@ -0,0 +1,32 @@
//
// BranchContainer.swift
// GME Remit
//
// Created by InKwon Devik Kim on 03/05/2019.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
import ObjectMapper
struct BranchContainer: Mappable {
var errorCode: String?
var message: String?
var id: String?
var extra: String?
var extra2: String?
var data: [Branch]?
init?(map: Map) {
}
mutating func mapping(map: Map) {
self.errorCode <- map["ErrorCode"]
self.message <- map["Msg"]
self.id <- map["Id"]
self.extra <- map["Extra"]
self.extra2 <- map["Extra2"]
self.data <- map["Data"]
}
}

33
GMERemittance/Module/RewardModule/Redeem/Application Logic/Model/Redeem.swift

@ -7,27 +7,16 @@
//
import Foundation
import ObjectMapper
struct Redeem: Mappable {
var userID: String?
var productCode: String?
var usePoint: String?
var orderType: String?
var recvType: String?
var branchCode: String?
var recvAddress: String?
var recvZipCode: String?
var recvPhoneNumber: String?
var recvName: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
}
struct Redeem {
let userID: String?
let productCode: String?
let usePoint: String?
let orderType: String?
let recvType: String?
let branchCode: String?
let recvAddress: String?
let recvZipCode: String?
let recvPhoneNumber: String?
let recvName: String?
}

74
GMERemittance/Module/RewardModule/Redeem/Application Logic/Service/RedeemService.swift

@ -17,10 +17,31 @@ class RedeemService: RedeemServiceType {
// MARK: Data management
func fetchBranches(
success: @escaping ([GmeContacts]?) -> Void,
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
) {
success(self.setBranches())
let url = "http://gmeuat.gmeremit.com:5012/api/v2/reward/branchInfo"
auth.request(
method: .post,
url: url,
params: nil,
success: { (response: BranchContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success(response.data)
}
}) { (error) in
failure(error)
}
}
func submit(
@ -65,52 +86,3 @@ class RedeemService: RedeemServiceType {
}
}
}
extension RedeemService {
private func setBranches() -> [GmeContacts]? {
let dongdaemunBranchContacts = GmeContacts()
dongdaemunBranchContacts.title = "Dongdaemun Branch"
dongdaemunBranchContacts.address = "315, Jong-ro Jongno-gu, Seoul \n(Dongdaemun Station - Exit 3) \n 서울시 종로구 종로 315"
dongdaemunBranchContacts.contactNumber = ["027635559"]
let hwaseongBranchContacts = GmeContacts()
hwaseongBranchContacts.title = "Hwaseong Branch"
hwaseongBranchContacts.address = "1101-1, 3.1 Manse-ro Hyangnam-eup, Hwaseong-si, Gyeonggi-do \n(Baran Market Place) \n 경기도 화성시 향남읍 3.1만세로 1101-1"
hwaseongBranchContacts.contactNumber = ["0313540450"]
let ansanBranchContacts = GmeContacts()
ansanBranchContacts.title = "Ansan Branch"
ansanBranchContacts.address = "2nd floor, 455, Jungang-daero, Danwon-gu, Ansan -si, Gyeonggi-do \n(Entrance of Asian Street) \n 경기도 안산시 단원구 중앙대로 455 2층"
ansanBranchContacts.contactNumber = ["0313626740"]
let gimhaeBranchContacts = GmeContacts()
gimhaeBranchContacts.title = "Gimhae Branch"
gimhaeBranchContacts.address = "84, Garak-ro, Gimhae-si, Gyeongsangnam-do,\n(Opposite to Top Mart) \n 경상남도 김해시 가락로 84 "
gimhaeBranchContacts.contactNumber = ["0553295559"]
let songuriBranchContacts = GmeContacts()
songuriBranchContacts.title = "Songu-ri Branch"
songuriBranchContacts.address = "91, Solmoru-ro, Soheul-eup, Pocheon-si, Gyeonggi-do, Korea\nNext to Nonghyub Bank) \n 경기도 포천시 소흘읍 솔모루로 91"
songuriBranchContacts.contactNumber = ["0315411856"]
let dongdaemunCisBranch = GmeContacts()
dongdaemunCisBranch.title = "Dongdaemun CIS Branch"
dongdaemunCisBranch.address = "2nd floor, 281, Changgyeonggunag-ro Jongno-gu, Seoul\n(Upper floor of Dongdaemun Mart) \n 서울 중구 을지로 42길 5 2층"
dongdaemunCisBranch.contactNumber = ["0221386429", "01030156864"]
let hyehwaBranch = GmeContacts()
hyehwaBranch.title = "Hyehwa Branch"
hyehwaBranch.address = "281, Changgyeonggung-ro, Jongno-gu, Seoul Hyehwa Rotary\n(Right across from Catholic Church) \n 서울특별시 종로구 창경궁로 281"
hyehwaBranch.contactNumber = ["0221386429", "01029706864"]
let branches = [dongdaemunCisBranch, dongdaemunBranchContacts, hwaseongBranchContacts, ansanBranchContacts, gimhaeBranchContacts, songuriBranchContacts, hyehwaBranch]
return branches
}
}

2
GMERemittance/Module/RewardModule/Redeem/Application Logic/Service/RedeemServiceType.swift

@ -10,7 +10,7 @@ import Foundation
protocol RedeemServiceType: class, ApiServiceType {
func fetchBranches(
success: @escaping ([GmeContacts]?) -> Void,
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
)

10
GMERemittance/Module/RewardModule/Redeem/User Interface/Presenter/RedeemPresenter.swift

@ -30,6 +30,7 @@ class RedeemPresenter {
extension RedeemPresenter: RedeemModuleInterface {
func viewIsReady() {
self.view?.startLoading()
self.interactor?.viewIsReady(model: self.model)
}
@ -38,6 +39,7 @@ extension RedeemPresenter: RedeemModuleInterface {
}
func fetchBranches() {
self.view?.startLoading()
self.interactor?.fetchBranches()
}
@ -46,6 +48,7 @@ extension RedeemPresenter: RedeemModuleInterface {
}
func submit(with model: Redeem?) {
self.view?.startLoading()
self.interactor?.submit(with: model)
}
}
@ -54,22 +57,27 @@ extension RedeemPresenter: RedeemModuleInterface {
extension RedeemPresenter: RedeemInteractorOutput {
func result(model: RewardProduct?) {
self.view?.endLoading()
self.view?.setModel(model: model)
}
func setBranches(with model: [GmeContacts]?) {
func setBranches(with model: [Branch]?) {
self.view?.endLoading()
self.view?.setBranches(with: model)
}
func setBranchesError(with error: Error) {
self.view?.endLoading()
self.view?.setBranchesError(with: error)
}
func submitSuccess() {
self.view?.endLoading()
self.view?.submitSuccess()
}
func submitFailure(with error: Error) {
self.view?.endLoading()
self.view?.submitFailure(with: error)
}
}

98
GMERemittance/Module/RewardModule/Redeem/User Interface/View/RedeemViewController.swift

@ -16,18 +16,20 @@ class RedeemViewController: UIViewController {
private var model: RewardProduct? {
didSet {
guard
let newModel = model,
let imageURL = newModel.productNumber?.imageURLInResource else { return }
self.selectedItemImageView.image = UIImage(named: imageURL)
// FIXME: /
// guard
// let newModel = model,
// let imageData = newModel.imageData,
// let data = Data(base64Encoded: imageData) else { return }
// self.selectedItemImageView.image = UIImage(data: data)
guard let newModel = model else { return }
self.selectedItemNameLabel.text = newModel.productName
self.selectedItemPriceLabel.text = newModel.pointPrice
}
}
private var redeemModel: Redeem?
private enum AddressType: Int {
case branch = 0
case custom
@ -60,6 +62,9 @@ class RedeemViewController: UIViewController {
self.userNameTextField.text = name
self.userPhoneNumberTextField.text = phoneNumber
self.userNameTextField.sendActions(for: .editingChanged)
self.userPhoneNumberTextField.sendActions(for: .editingChanged)
self.userInfoView.isHidden = false
self.selectAddressInfoLabel.isHidden = false
self.addressSegmentView.isHidden = false
@ -98,14 +103,14 @@ class RedeemViewController: UIViewController {
}
self.submitButton.isHidden = false
self.perform(#selector(self.moveToBottom), with: nil, afterDelay: 0.1)
self.perform(#selector(self.moveToBottom), with: nil, afterDelay: 0.3)
}
}
private var selectedBranch: GmeContacts? {
private var selectedBranch: Branch? {
didSet{
self.branchTextField.text = self.selectedBranch?.title
self.branchTextField.text = self.selectedBranch?.agentName
self.branchTextField.sendActions(for: .editingChanged)
}
}
@ -118,8 +123,9 @@ class RedeemViewController: UIViewController {
}
}
private var branchesPickerView = UIPickerView()
private var branches: [GmeContacts]?
private lazy var branchesPickerView = UIPickerView()
private var branches: [Branch]?
// MARK: IBOutlets
@ -132,8 +138,8 @@ class RedeemViewController: UIViewController {
@IBOutlet private weak var userInfoSegmentedControl: UISegmentedControl!
@IBOutlet private weak var addressSegmentedControl: UISegmentedControl!
@IBOutlet weak var userNameTextField: UITextField!
@IBOutlet weak var userPhoneNumberTextField: UITextField!
@IBOutlet private weak var userNameTextField: UITextField!
@IBOutlet private weak var userPhoneNumberTextField: UITextField!
@IBOutlet private weak var branchTextField: UITextField!
@IBOutlet private weak var detailAddressTextField: UITextField!
@ -174,12 +180,29 @@ class RedeemViewController: UIViewController {
}
@IBAction
func touchBranches(_ sender: UIButton) {
private func touchBranches(_ sender: UIButton) {
self.presenter?.showBranchesVC()
}
@IBAction func touchSubmitButton(_ sender: UIButton) {
self.presenter?.submit(with: redeemModel)
@IBAction
private func touchSubmitButton(_ sender: UIButton) {
let recvType = selectedAddressType == .custom ? "1" : "2"
let address = "\(self.detailAddressTextField.text ?? ""), \(self.addressTextField.text ?? "")"
let model = Redeem(
userID: UserDefaults.standard.string(forKey: UserKeys.email),
productCode: self.model?.productNumber,
usePoint: self.model?.pointPrice,
orderType: "1",
recvType: recvType,
branchCode: self.selectedBranch?.agentID,
recvAddress: address,
recvZipCode: self.selectedAddress?.zipNo,
recvPhoneNumber: self.userPhoneNumberTextField.text,
recvName: self.userNameTextField.text
)
self.presenter?.submit(with: model)
}
// MARK: Other Functions
@ -189,6 +212,8 @@ class RedeemViewController: UIViewController {
self.branchesPickerView.delegate = self
self.branchesPickerView.dataSource = self
self.userNameTextField.addTarget(self, action: #selector(self.editingChanged(_:)), for: .editingChanged)
self.userPhoneNumberTextField.addTarget(self, action: #selector(self.editingChanged(_:)), for: .editingChanged)
self.branchTextField.addTarget(self, action: #selector(self.editingChanged(_:)), for: .editingChanged)
self.detailAddressTextField.addTarget(self, action: #selector(self.editingChanged(_:)), for: .editingChanged)
@ -206,7 +231,7 @@ extension RedeemViewController: RedeemViewInterface {
self.model = model
}
func setBranches(with model: [GmeContacts]?) {
func setBranches(with model: [Branch]?) {
self.branches = model
}
@ -221,6 +246,14 @@ extension RedeemViewController: RedeemViewInterface {
func submitFailure(with error: Error) {
self.alert(message: error.localizedDescription)
}
func startLoading(){
self.showProgressHud()
}
func endLoading(){
self.hideProgressHud()
}
}
// MARK: - UIPickerViewDataSource, UIPickerViewDelegate
@ -235,7 +268,7 @@ extension RedeemViewController: UIPickerViewDataSource, UIPickerViewDelegate {
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return self.branches?[row].title
return self.branches?[row].agentName
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
@ -321,25 +354,30 @@ extension RedeemViewController {
@objc
private func editingChanged(_ textField: UITextField){
let isValid: Bool
let count = textField.text?.count ?? 0
guard
let name = self.userNameTextField.text,
let phoneNumber = self.userPhoneNumberTextField.text,
let branch = self.branchTextField.text,
let detail = self.detailAddressTextField.text,
let address = self.addressTextField.text else { return }
var isValid = name.count > 0 && phoneNumber.count > 0
switch textField{
case self.branchTextField:
isValid = count > 0
case self.detailAddressTextField:
isValid = count > 3 && (self.addressTextField.text?.count ?? 0) > 0
default:
isValid = false
break
switch self.selectedAddressType {
case .branch:
isValid = isValid && branch.count > 0
case .custom:
isValid = isValid && address.count > 0 && detail.count > 0
}
self.submitButton.isEnabled = isValid
self.submitButton.backgroundColor = isValid ? AppConstants.themeRedColor : .lightGray
}
@objc func moveToBottom(){
@objc private func moveToBottom(){
if scrollView.contentSize.height - scrollView.bounds.size.height > 0 {
let bottomOffset = CGPoint(x: 0, y: scrollView.contentSize.height - scrollView.bounds.size.height)
self.scrollView.setContentOffset(bottomOffset, animated: true)
}
}
}

5
GMERemittance/Module/RewardModule/Redeem/User Interface/View/RedeemViewInterface.swift

@ -8,9 +8,12 @@
protocol RedeemViewInterface: class {
func setModel(model: RewardProduct?)
func setBranches(with model: [GmeContacts]?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()
func submitFailure(with error: Error)
func startLoading()
func endLoading()
}

2
GMERemittance/Payment/Branch.swift → GMERemittance/Payment/_Branch.swift

@ -6,7 +6,7 @@
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
//
struct Branch: Decodable {
struct _Branch: Decodable {
var branchId: String!
var branchCode: String!
var address: String?
Loading…
Cancel
Save