Browse Source

email verification added

pull/1/head
gme_2 6 years ago
parent
commit
86d0099593
  1. 107
      GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift
  2. 1
      GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift
  3. 12
      GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift
  4. 9
      GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift
  5. 14
      GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
  6. 3
      GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift
  7. 4
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
  8. 10
      GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift
  9. 8
      GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard
  10. 3
      GMERemittance/RestApiManager.swift

107
GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift

@ -10,7 +10,7 @@ import Foundation
class KycInteractor { class KycInteractor {
// MARK: Properties
// MARK: Properties
weak var output: KycInteractorOutput? weak var output: KycInteractorOutput?
private let service: KycServiceType private let service: KycServiceType
@ -20,12 +20,18 @@ class KycInteractor {
init(service: KycServiceType) { init(service: KycServiceType) {
self.service = service self.service = service
} }
// MARK: Converting entities // MARK: Converting entities
// form 1 // form 1
func _validate(model: KycForm1Model?) -> (isValid: Bool, errorsDick: [String: String]) { func _validate(model: KycForm1Model?) -> (isValid: Bool, errorsDick: [String: String]) {
func isValidEmail(email: String) -> Bool {
let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegex)
return emailTest.evaluate(with: email)
}
var errorsDick: [String: String] = [:] var errorsDick: [String: String] = [:]
var sucks = true // isValid = true var sucks = true // isValid = true
@ -50,9 +56,18 @@ class KycInteractor {
} }
}) })
if let email = model?.email {
if !isValidEmail(email: email) {
sucks = false
errorsDick[KycForm1FieldKeys.email] = "invalid email"
}
}
let result = (sucks, errorsDick) // (isValid, errorsDick) let result = (sucks, errorsDick) // (isValid, errorsDick)
return result return result
// self.output?.show(result1: result)
// self.output?.show(result1: result)
} }
// form 2 // form 2
@ -79,7 +94,7 @@ class KycInteractor {
}) })
let result = (sucks, errorsDick) // (isValid, errorsDick) let result = (sucks, errorsDick) // (isValid, errorsDick)
return result return result
// self.output?.show(result2: result)
// self.output?.show(result2: result)
} }
@ -105,7 +120,81 @@ class KycInteractor {
}) })
let result = (sucks, errorsDick) // (isValid, errorsDick) let result = (sucks, errorsDick) // (isValid, errorsDick)
return result return result
// self.output?.show(result3: result)
// self.output?.show(result3: result)
}
private func getImageParams(model: KYCRequestModel) -> [String: Data] {
var images: [String: Data] = [:]
let model = model.kycForm3
// selfie
if let image = model?.selfieImage {
if let data = getCompressedImage(image: image) {
images["selfieUrl"] = data
}
}
// front
if let image = model?.frontImage {
if let data = getCompressedImage(image: image) {
images["regIdcardFrontUrl"] = data
}
}
// back
if let image = model?.backImage {
if let data = getCompressedImage(image: image) {
images["regIdcardBackUrl"] = data
}
}
// passbookImage
if let image = model?.passbookImage {
if let data = getCompressedImage(image: image) {
images["passbookUrl"] = data
}
}
// passportImage
if let image = model?.passportImage {
if let data = getCompressedImage(image: image) {
images["passportUrl"] = data
}
}
return images
}
private func getCompressedImage(image: UIImage) -> Data? {
return UIImageJPEGRepresentation(image, 0.5)
}
private func getParams(model: KYCRequestModel) -> [String: String] {
let defaults = UserDefaults.standard
let userName = defaults.string(forKey: UserKeys.userId) ?? ""
let param: [String: String] =
[
"userId": userName,
"mobileNumber": model.kycForm1?.mobile ?? "",
"email": model.kycForm1?.email ?? "",
"gender": model.kycForm1?.gender ?? "",
"dateOfBirth": model.kycForm1?.dob ?? "",
"nativeCountry": model.kycForm1?.nativeCountry ?? "",
"ProvinceId": model.kycForm1?.province ?? "",
"occupation": model.kycForm1?.occupation ?? "",
"primaryBankName": model.kycForm2?.bank ?? "",
"primaryAccountNumber": model.kycForm2?.accountNumber ?? "",
"verificationIdType": model.kycForm2?.verificationId ?? "",
"verificationIdNumber": model.kycForm2?.verificationIdNumber ?? "",
"expiryDate": model.kycForm2?.expiryDate ?? "",
"sourceOfFund": model.kycForm2?.sourceOfFund ?? "",
"firstName": model.kycForm1?.firstName ?? "",
"middleName": model.kycForm1?.middleName ?? "",
"lastName": model.kycForm1?.lastName ?? "",
"address": model.kycForm1?.country ?? ""
]
return param
} }
} }
@ -121,7 +210,13 @@ extension KycInteractor: KycInteractorInput {
let shouldSubmit = result1.isValid && result2.isValid && result3.isValid let shouldSubmit = result1.isValid && result2.isValid && result3.isValid
if shouldSubmit { if shouldSubmit {
/// call api here. /// call api here.
let params = self.getParams(model: model)
let images = self.getImageParams(model: model)
self.service.submit(param: params, images: images, success: { (response) in
print(response?.firstName)
}) { (error) in
self.output?.show(error: error)
}
}else { }else {
self.output?.show(result1: result1) self.output?.show(result1: result1)
self.output?.show(result2: result2) self.output?.show(result2: result2)

1
GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift

@ -14,4 +14,5 @@ protocol KycInteractorOutput: class {
func show(result1: (isValid: Bool, errorsDick: [String: String])) func show(result1: (isValid: Bool, errorsDick: [String: String]))
func show(result2: (isValid: Bool, errorsDick: [String: String])) func show(result2: (isValid: Bool, errorsDick: [String: String]))
func show(result3: (isValid: Bool, errorsDick: [String: String])) func show(result3: (isValid: Bool, errorsDick: [String: String]))
func show(error: Error)
} }

12
GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift

@ -9,20 +9,22 @@
import Foundation import Foundation
import Alamofire import Alamofire
protocol KycServiceType: class {
protocol KycServiceType: class, KYCSubmitApiService {
} }
protocol KYCSubmitApiService: ApiServiceType { protocol KYCSubmitApiService: ApiServiceType {
func submit(param: [String: String], success: @escaping (KYCResponse?) -> (), failure: @escaping( Error) -> ())
func submit(param: [String: String], images: [String: Data], success: @escaping (KYCResponse?) -> (), failure: @escaping (Error) -> ())
} }
//http://gmeuat.gmeremit.com:5011/api/v1/mobile/RegisterKyc
extension KYCSubmitApiService { extension KYCSubmitApiService {
func submit(param: [String: String], success: @escaping (KYCResponse?) -> (), failure: @escaping (Error) -> ()) {
func submit(param: [String: String], images: [String: Data], success: @escaping (KYCResponse?) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "mobile/RegisterKyc" let url = baseUrl + "mobile/RegisterKyc"
auth.request(method: .get, url: url, params: param, success: { (response: KYCResponseContainer) in
auth.requestMultipart(method: .post, url, parameters: param, images: images, success: { (response: KYCResponseContainer) in
if (response.errorCode ?? "") == "1" { if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error) failure(error)

9
GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift

@ -24,6 +24,7 @@ class KycPresenter {
extension KycPresenter: KycModuleInterface { extension KycPresenter: KycModuleInterface {
func validate(model: KYCRequestModel) { func validate(model: KYCRequestModel) {
self.view?.showLoading()
self.interactor?.validate(model: model) self.interactor?.validate(model: model)
} }
} }
@ -32,15 +33,23 @@ extension KycPresenter: KycModuleInterface {
extension KycPresenter: KycInteractorOutput { extension KycPresenter: KycInteractorOutput {
func show(result1: (isValid: Bool, errorsDick: [String : String])) { func show(result1: (isValid: Bool, errorsDick: [String : String])) {
self.view?.hideLoading()
self.view?.show(resultl: result1) self.view?.show(resultl: result1)
} }
func show(result2: (isValid: Bool, errorsDick: [String : String])) { func show(result2: (isValid: Bool, errorsDick: [String : String])) {
self.view?.hideLoading()
self.view?.show(result2: result2) self.view?.show(result2: result2)
} }
func show(result3: (isValid: Bool, errorsDick: [String : String])) { func show(result3: (isValid: Bool, errorsDick: [String : String])) {
self.view?.hideLoading()
self.view?.show(result3: result3) self.view?.show(result3: result3)
} }
func show(error: Error) {
self.view?.hideLoading()
self.view?.show(error: error.localizedDescription)
}
} }

14
GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift

@ -1,4 +1,4 @@
//
//
// KycViewController.swift // KycViewController.swift
// GMERemittance // GMERemittance
// //
@ -183,6 +183,18 @@ extension KycViewController: KycViewInterface {
self.showErrorView() self.showErrorView()
} }
} }
func show(error: String) {
self.alert(message: error)
}
func showLoading() {
self.showProgressHud()
}
func hideLoading() {
self.hideProgressHud()
}
} }

3
GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift

@ -10,4 +10,7 @@ protocol KycViewInterface: class {
func show(resultl: (isValid: Bool, errorsDick: [String : String])) func show(resultl: (isValid: Bool, errorsDick: [String : String]))
func show(result2: (isValid: Bool, errorsDick: [String : String])) func show(result2: (isValid: Bool, errorsDick: [String : String]))
func show(result3: (isValid: Bool, errorsDick: [String : String])) func show(result3: (isValid: Bool, errorsDick: [String : String]))
func show(error: String)
func showLoading()
func hideLoading()
} }

4
GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift

@ -154,7 +154,8 @@ class KycForm1ViewController: UIViewController {
@IBAction func save(_ sender: UIButton) { @IBAction func save(_ sender: UIButton) {
self.view.endEditing(true) self.view.endEditing(true)
self.continueActionInitiated = true self.continueActionInitiated = true
validate()
self.delegate?._continue(model: self.kycForm1Model)
// validate()
} }
// MARK: Other Functions // MARK: Other Functions
@ -204,6 +205,7 @@ class KycForm1ViewController: UIViewController {
@objc private func handleDatePicker(sender: UIDatePicker) { @objc private func handleDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
// test ccr
dateFormatter.dateFormat = "yyyy-MM-dd" dateFormatter.dateFormat = "yyyy-MM-dd"
self.dobTextField.text = dateFormatter.string(from: sender.date) self.dobTextField.text = dateFormatter.string(from: sender.date)
} }

10
GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift

@ -132,13 +132,13 @@ class KycForm2ViewController: UIViewController {
@IBAction func _continue(_ sender: UIButton) { @IBAction func _continue(_ sender: UIButton) {
continueActionInitiated = true continueActionInitiated = true
validate()
self.delegate?._continue(model: self.kycForm2Model)
} }
// MARK: Other Functions // MARK: Other Functions
private func createModel() { private func createModel() {
self.kycForm2Model.accountNumber = self.accountNumberTextField.text! self.kycForm2Model.accountNumber = self.accountNumberTextField.text!
self.kycForm2Model.verificationIdNumber = self.verificationIdTextField.text!
self.kycForm2Model.verificationIdNumber = self.verificationIdNumberTextField.text!
self.kycForm2Model.expiryDate = self.expiryDateTextField.text! self.kycForm2Model.expiryDate = self.expiryDateTextField.text!
self.kycForm2Model.issueDate = self.issueDateTextField.text! self.kycForm2Model.issueDate = self.issueDateTextField.text!
} }
@ -185,12 +185,14 @@ class KycForm2ViewController: UIViewController {
@objc private func handleIssueDatePicker(sender: UIDatePicker) { @objc private func handleIssueDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd" dateFormatter.dateFormat = "yyyy-MM-dd"
// test ccr
self.issueDateTextField.text = dateFormatter.string(from: sender.date) self.issueDateTextField.text = dateFormatter.string(from: sender.date)
} }
@objc private func handleExpiryDatePicker(sender: UIDatePicker) { @objc private func handleExpiryDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
// test ccr
dateFormatter.dateFormat = "yyyy-MM-dd" dateFormatter.dateFormat = "yyyy-MM-dd"
self.expiryDateTextField.text = dateFormatter.string(from: sender.date) self.expiryDateTextField.text = dateFormatter.string(from: sender.date)
} }
@ -308,19 +310,21 @@ extension KycForm2ViewController: IndicatorInfoProvider {
extension KycForm2ViewController: UITextFieldDelegate { extension KycForm2ViewController: UITextFieldDelegate {
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
textField.layer.addShadow(with: Constants.clearColor) textField.layer.addShadow(with: Constants.clearColor)
textField.layer.borderWidth = 0
switch textField { switch textField {
case bankTextField: case bankTextField:
// show bank picker // show bank picker
showBankPickerView() showBankPickerView()
self.bankErrorLabel.isHidden = true self.bankErrorLabel.isHidden = true
self.bankTextField.layer.borderWidth = 0
return false return false
case verificationIdTextField: case verificationIdTextField:
self.verificationIdErrorLabel.isHidden = true
showVerificationIdTypePicker() showVerificationIdTypePicker()
// show list of verificationId type // show list of verificationId type
return false return false
case sourceOfFundTextField: case sourceOfFundTextField:
// show source of fund picker // show source of fund picker
self.sourceOfFundErrorLabel.isHidden = true
self.showSourceOfFundPicker() self.showSourceOfFundPicker()
return false return false
default: default:

8
GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard

@ -231,17 +231,9 @@
<constraints> <constraints>
<constraint firstItem="IA2-r7-puo" firstAttribute="top" secondItem="hQv-gh-5cz" secondAttribute="top" constant="70" id="BI3-YV-Naw"/> <constraint firstItem="IA2-r7-puo" firstAttribute="top" secondItem="hQv-gh-5cz" secondAttribute="top" constant="70" id="BI3-YV-Naw"/>
<constraint firstItem="IA2-r7-puo" firstAttribute="leading" secondItem="hQv-gh-5cz" secondAttribute="leading" constant="20" id="DDG-4u-4Ym"/> <constraint firstItem="IA2-r7-puo" firstAttribute="leading" secondItem="hQv-gh-5cz" secondAttribute="leading" constant="20" id="DDG-4u-4Ym"/>
<constraint firstAttribute="bottom" secondItem="IA2-r7-puo" secondAttribute="bottom" constant="40" id="FHh-MW-1cn"/>
<constraint firstAttribute="trailing" secondItem="IA2-r7-puo" secondAttribute="trailing" constant="20" id="FfM-Rd-OpC"/> <constraint firstAttribute="trailing" secondItem="IA2-r7-puo" secondAttribute="trailing" constant="20" id="FfM-Rd-OpC"/>
<constraint firstAttribute="bottom" secondItem="IA2-r7-puo" secondAttribute="bottom" constant="100" id="Lqm-n6-fpp"/> <constraint firstAttribute="bottom" secondItem="IA2-r7-puo" secondAttribute="bottom" constant="100" id="Lqm-n6-fpp"/>
<constraint firstItem="IA2-r7-puo" firstAttribute="top" secondItem="hQv-gh-5cz" secondAttribute="top" constant="60" id="rMj-w7-4aj"/>
</constraints> </constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="FHh-MW-1cn"/>
<exclude reference="rMj-w7-4aj"/>
</mask>
</variation>
</view> </view>
</subviews> </subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>

3
GMERemittance/RestApiManager.swift

@ -99,7 +99,6 @@ class RestApiMananger {
failure: @escaping (Error) -> ()) { failure: @escaping (Error) -> ()) {
if NetworkReachabilityManager()?.isReachable == true { if NetworkReachabilityManager()?.isReachable == true {
func makeRequest() {
let headers = needsAuthorization ? getContentHeaderAfterLogin() : getContentHeaderBeforeLogin() let headers = needsAuthorization ? getContentHeaderAfterLogin() : getContentHeaderBeforeLogin()
self.manager.upload( self.manager.upload(
@ -129,8 +128,6 @@ class RestApiMananger {
} }
} }
) )
}
}else { }else {
let error = NSError.init(domain: "NETWORK_REACHABILITY_DOMAIN", code: 0, userInfo: [NSLocalizedDescriptionKey : "No Internet connection found. 
Check your connection."]) let error = NSError.init(domain: "NETWORK_REACHABILITY_DOMAIN", code: 0, userInfo: [NSLocalizedDescriptionKey : "No Internet connection found. 
Check your connection."])

Loading…
Cancel
Save