diff --git a/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift b/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift
index f2fa1612..9312763a 100644
--- a/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift
+++ b/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift
@@ -10,7 +10,7 @@ import Foundation
class KycInteractor {
- // MARK: Properties
+ // MARK: Properties
weak var output: KycInteractorOutput?
private let service: KycServiceType
@@ -20,12 +20,18 @@ class KycInteractor {
init(service: KycServiceType) {
self.service = service
}
-
+
// MARK: Converting entities
// form 1
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 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)
return result
-// self.output?.show(result1: result)
+ // self.output?.show(result1: result)
}
// form 2
@@ -79,7 +94,7 @@ class KycInteractor {
})
let result = (sucks, errorsDick) // (isValid, errorsDick)
return result
-// self.output?.show(result2: result)
+ // self.output?.show(result2: result)
}
@@ -105,7 +120,81 @@ class KycInteractor {
})
let result = (sucks, errorsDick) // (isValid, errorsDick)
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
if shouldSubmit {
/// 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 {
self.output?.show(result1: result1)
self.output?.show(result2: result2)
diff --git a/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift b/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift
index d227031e..4ca5c58e 100644
--- a/GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift
+++ b/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(result2: (isValid: Bool, errorsDick: [String: String]))
func show(result3: (isValid: Bool, errorsDick: [String: String]))
+ func show(error: Error)
}
diff --git a/GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift b/GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift
index a28d3e1b..e3a73088 100644
--- a/GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift
+++ b/GMERemittance/Module/New Group/Kyc/Application Logic/Service/KycServiceType.swift
@@ -9,20 +9,22 @@
import Foundation
import Alamofire
-protocol KycServiceType: class {
+protocol KycServiceType: class, KYCSubmitApiService {
}
+
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 {
- 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"
- 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" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
diff --git a/GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift b/GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift
index 8bc1077e..eb101afa 100644
--- a/GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift
+++ b/GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift
@@ -24,6 +24,7 @@ class KycPresenter {
extension KycPresenter: KycModuleInterface {
func validate(model: KYCRequestModel) {
+ self.view?.showLoading()
self.interactor?.validate(model: model)
}
}
@@ -32,15 +33,23 @@ extension KycPresenter: KycModuleInterface {
extension KycPresenter: KycInteractorOutput {
func show(result1: (isValid: Bool, errorsDick: [String : String])) {
+ self.view?.hideLoading()
self.view?.show(resultl: result1)
}
func show(result2: (isValid: Bool, errorsDick: [String : String])) {
+ self.view?.hideLoading()
self.view?.show(result2: result2)
}
func show(result3: (isValid: Bool, errorsDick: [String : String])) {
+ self.view?.hideLoading()
self.view?.show(result3: result3)
}
+
+ func show(error: Error) {
+ self.view?.hideLoading()
+ self.view?.show(error: error.localizedDescription)
+ }
}
diff --git a/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift b/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
index a3e60f96..58ef4baa 100644
--- a/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
+++ b/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
@@ -1,4 +1,4 @@
-//
+ //
// KycViewController.swift
// GMERemittance
//
@@ -183,6 +183,18 @@ extension KycViewController: KycViewInterface {
self.showErrorView()
}
}
+
+ func show(error: String) {
+ self.alert(message: error)
+ }
+
+ func showLoading() {
+ self.showProgressHud()
+ }
+
+ func hideLoading() {
+ self.hideProgressHud()
+ }
}
diff --git a/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift b/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift
index 10b82910..4fac3fca 100644
--- a/GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift
+++ b/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(result2: (isValid: Bool, errorsDick: [String : String]))
func show(result3: (isValid: Bool, errorsDick: [String : String]))
+ func show(error: String)
+ func showLoading()
+ func hideLoading()
}
diff --git a/GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift b/GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
index 678fc388..932579c3 100644
--- a/GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
+++ b/GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
@@ -154,7 +154,8 @@ class KycForm1ViewController: UIViewController {
@IBAction func save(_ sender: UIButton) {
self.view.endEditing(true)
self.continueActionInitiated = true
- validate()
+ self.delegate?._continue(model: self.kycForm1Model)
+// validate()
}
// MARK: Other Functions
@@ -204,6 +205,7 @@ class KycForm1ViewController: UIViewController {
@objc private func handleDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter()
+// test ccr
dateFormatter.dateFormat = "yyyy-MM-dd"
self.dobTextField.text = dateFormatter.string(from: sender.date)
}
diff --git a/GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift b/GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift
index 3ccd05d8..668760f1 100644
--- a/GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift
+++ b/GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift
@@ -132,13 +132,13 @@ class KycForm2ViewController: UIViewController {
@IBAction func _continue(_ sender: UIButton) {
continueActionInitiated = true
- validate()
+ self.delegate?._continue(model: self.kycForm2Model)
}
// MARK: Other Functions
private func createModel() {
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.issueDate = self.issueDateTextField.text!
}
@@ -185,12 +185,14 @@ class KycForm2ViewController: UIViewController {
@objc private func handleIssueDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
+// test ccr
self.issueDateTextField.text = dateFormatter.string(from: sender.date)
}
@objc private func handleExpiryDatePicker(sender: UIDatePicker) {
let dateFormatter = DateFormatter()
+ // test ccr
dateFormatter.dateFormat = "yyyy-MM-dd"
self.expiryDateTextField.text = dateFormatter.string(from: sender.date)
}
@@ -308,19 +310,21 @@ extension KycForm2ViewController: IndicatorInfoProvider {
extension KycForm2ViewController: UITextFieldDelegate {
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
textField.layer.addShadow(with: Constants.clearColor)
+ textField.layer.borderWidth = 0
switch textField {
case bankTextField:
// show bank picker
showBankPickerView()
self.bankErrorLabel.isHidden = true
- self.bankTextField.layer.borderWidth = 0
return false
case verificationIdTextField:
+ self.verificationIdErrorLabel.isHidden = true
showVerificationIdTypePicker()
// show list of verificationId type
return false
case sourceOfFundTextField:
// show source of fund picker
+ self.sourceOfFundErrorLabel.isHidden = true
self.showSourceOfFundPicker()
return false
default:
diff --git a/GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard b/GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard
index 1ea7aaff..231d5552 100644
--- a/GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard
+++ b/GMERemittance/Module/SendMoney/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPicker.storyboard
@@ -231,17 +231,9 @@
-
-
-
-
-
-
-
-
diff --git a/GMERemittance/RestApiManager.swift b/GMERemittance/RestApiManager.swift
index b82e2643..fe36998a 100644
--- a/GMERemittance/RestApiManager.swift
+++ b/GMERemittance/RestApiManager.swift
@@ -99,7 +99,6 @@ class RestApiMananger {
failure: @escaping (Error) -> ()) {
if NetworkReachabilityManager()?.isReachable == true {
- func makeRequest() {
let headers = needsAuthorization ? getContentHeaderAfterLogin() : getContentHeaderBeforeLogin()
self.manager.upload(
@@ -129,8 +128,6 @@ class RestApiMananger {
}
}
)
-
- }
}else {
let error = NSError.init(domain: "NETWORK_REACHABILITY_DOMAIN", code: 0, userInfo: [NSLocalizedDescriptionKey : "No Internet connection found.
Check your connection."])