Browse Source

add APIRouter

pull/1/head
InKwon James Kim 5 years ago
parent
commit
d87db81dc5
  1. 16
      GME Remit.xcodeproj/project.pbxproj
  2. 39
      GME Remit/APIs/CommonServiceType.swift
  3. 63
      GME Remit/APIs/ExchangeRateApiService.swift
  4. 266
      GME Remit/APIs/Router/APIRouter.swift
  5. 2
      GME Remit/AppDelegate.swift
  6. 19
      GME Remit/Models/ExchangeRateRequestModel.swift
  7. 16
      GME Remit/Modules/ExchangeRates/User Interface/View/ExchangeRatesViewController.swift
  8. 28
      GME Remit/Modules/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift
  9. 36
      GME Remit/Modules/Home/Application Logic/Interactor/HomeInteractor.swift
  10. 42
      GME Remit/Modules/Home/Application Logic/Service/HomeServiceType.swift
  11. 45
      GME Remit/Modules/Login/Application Logic/Service/LoginService.swift
  12. 4
      GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Service/SetupRecipientService.swift
  13. 2
      GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Service/SetupRecipientServiceType.swift
  14. 12
      GME Remit/Modules/RegisterModules/PennyTestSubmit/User Interface/View/PennyTestSubmitViewController.swift
  15. 11
      GME Remit/Modules/RegisterModules/Register/Application Logic/Interactor/RegisterInteractor.swift
  16. 41
      GME Remit/Modules/RegisterModules/Register/Application Logic/Service/RegisterServiceType.swift
  17. 14
      GME Remit/Modules/RewardModules/Redeem/Application Logic/Service/RedeemService.swift
  18. 4
      GME Remit/Modules/SplashScreen/Application Logic/Interactor/SplashScreenInteractor.swift
  19. 2
      GME Remit/Modules/SplashScreen/Application Logic/Interactor/SplashScreenInteractorIO.swift
  20. 2
      GME Remit/Modules/SplashScreen/Module Interface/SplashScreenModuleInterface.swift
  21. 4
      GME Remit/Modules/SplashScreen/User Interface/Presenter/SplashScreenPresenter.swift
  22. 14
      GME Remit/Modules/SplashScreen/User Interface/View/SplashScreenViewController.swift

16
GME Remit.xcodeproj/project.pbxproj

@ -195,6 +195,7 @@
73157BA422DC1EEC009B836F /* PopupNotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73157B9922DC1EEC009B836F /* PopupNotificationViewController.swift */; };
73157BA522DC1EEC009B836F /* PopupNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 73157B9A22DC1EEC009B836F /* PopupNotification.storyboard */; };
73157BA722DC3F14009B836F /* Date+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73157BA622DC3F14009B836F /* Date+Ext.swift */; };
731627A52301009800BA48A8 /* ExchangeRateRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731627A42301009800BA48A8 /* ExchangeRateRequestModel.swift */; };
73168A1F22F3CC4C00878038 /* NativeCountry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73168A1E22F3CC4B00878038 /* NativeCountry.swift */; };
73168A2322F3D01A00878038 /* TablePresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73168A2222F3D01900878038 /* TablePresenterProtocol.swift */; };
73195AB222FD14D500151434 /* SetupRecipientModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73195A9D22FD14D400151434 /* SetupRecipientModuleInterface.swift */; };
@ -209,6 +210,7 @@
73195ABB22FD14D500151434 /* SetupRecipientViewModelInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73195AAF22FD14D400151434 /* SetupRecipientViewModelInterface.swift */; };
73195ABC22FD14D500151434 /* SetupRecipient.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 73195AB022FD14D400151434 /* SetupRecipient.storyboard */; };
73195ABD22FD14D500151434 /* SetupRecipientViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73195AB122FD14D400151434 /* SetupRecipientViewController.swift */; };
73195B3522FD5BC600151434 /* APIRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73195B3422FD5BC600151434 /* APIRouter.swift */; };
73210DA122FBE73100715D6C /* RecipientsModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73210D8E22FBE73100715D6C /* RecipientsModuleInterface.swift */; };
73210DA222FBE73100715D6C /* RecipientsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73210D9222FBE73100715D6C /* RecipientsService.swift */; };
73210DA322FBE73100715D6C /* RecipientsServiceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73210D9322FBE73100715D6C /* RecipientsServiceType.swift */; };
@ -2418,6 +2420,7 @@
73157B9922DC1EEC009B836F /* PopupNotificationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopupNotificationViewController.swift; sourceTree = "<group>"; };
73157B9A22DC1EEC009B836F /* PopupNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = PopupNotification.storyboard; sourceTree = "<group>"; };
73157BA622DC3F14009B836F /* Date+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Ext.swift"; sourceTree = "<group>"; };
731627A42301009800BA48A8 /* ExchangeRateRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ExchangeRateRequestModel.swift; path = "GME Remit/Models/ExchangeRateRequestModel.swift"; sourceTree = "<group>"; };
73168A1E22F3CC4B00878038 /* NativeCountry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeCountry.swift; sourceTree = "<group>"; };
73168A2222F3D01900878038 /* TablePresenterProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TablePresenterProtocol.swift; sourceTree = "<group>"; };
73195A9D22FD14D400151434 /* SetupRecipientModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetupRecipientModuleInterface.swift; sourceTree = "<group>"; };
@ -2432,6 +2435,7 @@
73195AAF22FD14D400151434 /* SetupRecipientViewModelInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetupRecipientViewModelInterface.swift; sourceTree = "<group>"; };
73195AB022FD14D400151434 /* SetupRecipient.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SetupRecipient.storyboard; sourceTree = "<group>"; };
73195AB122FD14D400151434 /* SetupRecipientViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetupRecipientViewController.swift; sourceTree = "<group>"; };
73195B3422FD5BC600151434 /* APIRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIRouter.swift; sourceTree = "<group>"; };
73210D8E22FBE73100715D6C /* RecipientsModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipientsModuleInterface.swift; sourceTree = "<group>"; };
73210D9222FBE73100715D6C /* RecipientsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipientsService.swift; sourceTree = "<group>"; };
73210D9322FBE73100715D6C /* RecipientsServiceType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipientsServiceType.swift; sourceTree = "<group>"; };
@ -5709,6 +5713,14 @@
path = View;
sourceTree = "<group>";
};
731627A623010C5B00BA48A8 /* Router */ = {
isa = PBXGroup;
children = (
73195B3422FD5BC600151434 /* APIRouter.swift */,
);
path = Router;
sourceTree = "<group>";
};
73168A1B22F3C9E300878038 /* ThirdParty */ = {
isa = PBXGroup;
children = (
@ -6676,6 +6688,7 @@
9FD260EB1FD00458007A511D = {
isa = PBXGroup;
children = (
731627A42301009800BA48A8 /* ExchangeRateRequestModel.swift */,
D94838D421757F8C00FFC19E /* GME Remit.entitlements */,
9FD260F61FD00458007A511D /* GME Remit */,
9FD2610B1FD00458007A511D /* GME RemitTests */,
@ -10890,6 +10903,7 @@
D96848CA212D3F1200EF12B1 /* APIs */ = {
isa = PBXGroup;
children = (
731627A623010C5B00BA48A8 /* Router */,
D96848CD212D419400EF12B1 /* ApiServiceType.swift */,
73538B2122EFC5FA00188CDD /* CommonServiceType.swift */,
D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.swift */,
@ -14233,6 +14247,7 @@
73FE8838228A4A8C00A5EB56 /* OrderHistoryService.swift in Sources */,
BEC9B000224FC49C00A2DA06 /* BiometricAuthenticationInteractor.swift in Sources */,
D945F11D213E1D5100A24824 /* SendMoneyReceiptModuleInterface.swift in Sources */,
73195B3522FD5BC600151434 /* APIRouter.swift in Sources */,
73A6E20222CEE51600E9BC68 /* BadgeAppearance.swift in Sources */,
D97785AA215DD04400754079 /* TransactionHistoryTableViewCell.swift in Sources */,
730D7894227A94E1007E517E /* RewardItemCollectionViewCell.swift in Sources */,
@ -14310,6 +14325,7 @@
730197A322535135001954AB /* kycForm3Service.swift in Sources */,
D922D96C2135145F00D43053 /* SendMoneyParentViewController.swift in Sources */,
D922D98C21351AAE00D43053 /* SendMoneyExchangeRateViewController.swift in Sources */,
731627A52301009800BA48A8 /* ExchangeRateRequestModel.swift in Sources */,
D922D9402135124200D43053 /* SendMoneyPaymentModeModuleInterface.swift in Sources */,
D92E6569222620A0004D1B3D /* SendMoneyCodeService.swift in Sources */,
BEC9B001224FC49C00A2DA06 /* BiometricAuthenticationPresenter.swift in Sources */,

39
GME Remit/APIs/CommonServiceType.swift

@ -24,28 +24,23 @@ extension CommonServiceType {
idNumber: String = "",
idType: String = "",
success: @escaping (Bool, String?) -> Void,
failure: @escaping (Error) -> ()
) {
let url = "http://gmeuat.gmeremit.com:5022/api/v3/validation"
let paramaters = [
"Username": userName,
"IdNumber": idNumber,
"IdType": idType
]
auth.request(
method: .post,
url: url,
params: paramaters,
needsAuthorization: false,
success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
success(false, response.message)
}else {
success(true, nil)
}
},
failure: { failure($0) }
failure: @escaping (Error) -> Void
) {
APIRouter.validation(
userName: userName,
idNumber: idNumber,
idType: idType
)
.request(
needsAuthorization: false,
success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
success(false, response.message)
}else {
success(true, nil)
}
},
failure: { failure($0)}
)
}
}

63
GME Remit/APIs/ExchangeRateApiService.swift

@ -17,39 +17,56 @@ protocol FetchCountryCurrencyInformation: ApiServiceType {
extension FetchCountryCurrencyInformation {
func fetchCountryCurrencyInfo(isAuth: Bool = true, success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "/mobile/countriesServices"
auth.request(method: .get, url: url , params: nil, needsAuthorization: isAuth, success: { (response: ExchangeRateContainer) 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
APIRouter
.countriesServices
.request(
needsAuthorization: isAuth,
success: { (response: ExchangeRateContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError(domain: "Network", code: 0, message: response.message ?? "")
failure(error)
}
}
} else {
let model = response.data
success(model)
}
},
failure: {failure($0)}
)
}
}
protocol getExchangeRateInformation: ApiServiceType {
func getExchangeRateInformation(isAuth: Bool, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> ())
func getExchangeRateInformation(
isAuth: Bool,
model: ExchangeRateRequestModel,
success: @escaping (ExchangeRateDetailModel?) -> (),
failure: @escaping (Error) -> ()
)
}
extension getExchangeRateInformation {
func getExchangeRateInformation(isAuth: Bool = true, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> () ) {
let url = baseUrl + "/mobile/calculateDefExRate"
auth.request(method: .post, url: url, params: params, needsAuthorization: isAuth, success: { (response: ExchangeRateDetailContainer) in
func getExchangeRateInformation(
isAuth: Bool = true,
model: ExchangeRateRequestModel,
success: @escaping (ExchangeRateDetailModel?) -> (),
failure: @escaping (Error) -> ()
) {
APIRouter.calculateDefExRate(model: model)
.request(
needsAuthorization: isAuth,
success: { (response: ExchangeRateDetailContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
let error = NSError(domain: "Network", code: 0, message: response.message ?? "")
failure(error)
}else {
let model = response.data
success(model)
let model = response.data
success(model)
}
}, failure: failure)
}
},
failure: failure
)
}
}

266
GME Remit/APIs/Router/APIRouter.swift

@ -0,0 +1,266 @@
//
// APIRouter.swift
// GME Remit
//
// Created by InKwon James Kim on 09/08/2019.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
import Alamofire
import Localize_Swift
import ObjectMapper
enum APIRouter: ApiServiceType {
case accesscode(username: String, password: String)
case customerProfile(firebaseToken: String)
case customerRegister(registerModel: RegisterRequestModel, firebaseToken: String)
case passwordReset(userName: String)
case validation(userName: String, idNumber: String, idType: String)
case countriesServices
case calculateDefExRate(model: ExchangeRateRequestModel)
case recipientRequirement(country: String)
}
extension APIRouter {
private var manager: SessionManager {
let manager = Alamofire.SessionManager.default
manager.session.configuration.timeoutIntervalForRequest = 150
return manager
}
private var uuid: String {
guard let uuid = GMEDB.shared.app.string(.uuid) else {
let uuid = UUID().uuidString
GMEDB.shared.app.set(uuid, .uuid)
return uuid
}
return uuid
}
private var beforeLoginHeader: [String: String] {
let currentLanguage = Localize.currentLanguage()
let lang = Utility.getLanguageHeader(for: currentLanguage)
let authValue = "172017F9EC11222E8107142733:QRK2UM0Q:\(uuid)".toBase64()
return [
"Authorization": "Basic \(authValue)",
"GME-TOKEN" : "39587YT398@FBQOW8RY3#948R7GB@CNEQW987GF87$TD18$1981..919@@##joghndvberteiru",
"Content-Type": "application/json",
"lang" : lang
]
}
private var afterLoginHeader: [String: String] {
let accessCode = GMEDB.shared.user.string(.accessCode) ?? ""
let currentLanguage = Localize.currentLanguage()
let lang = Utility.getLanguageHeader(for: currentLanguage)
return [
"Authorization": "Bearer " + accessCode,
"GME-TOKEN" : "39587YT398@FBQOW8RY3#948R7GB@CNEQW987GF87$TD18$1981..919@@##joghndvberteiru",
"Content-Type": "application/json",
"clientId": Utility.getMyKftcClientId(),
"lang" : lang
]
}
func request<T: Mappable>(
encoding: ParameterEncoding = JSONEncoding.default,
needsAuthorization: Bool = true,
success: @escaping (T) -> Void,
failure: @escaping (Error) -> Void
) {
guard
let isReachable = NetworkReachabilityManager()?.isReachable,
isReachable else {
let error = NSError(
domain: "NETWORK_REACHABILITY_DOMAIN",
code: -99,
message: "No Internet connection found. Check your connection."
)
return failure(error)
}
manager.request(
self.endpoint,
method: self.method,
parameters: self.parameters,
encoding: encoding,
headers: needsAuthorization ? afterLoginHeader : beforeLoginHeader
).handle(success: success, failure: failure)
}
func kftcRequest<T: Mappable>(
method: HTTPMethod,
header: [String: String],
url: String,
params: [String: Any]?,
encoding: ParameterEncoding = JSONEncoding.default,
needsAuthorization: Bool = true,
success: @escaping (T) -> Void,
failure: @escaping (Error) -> Void
) {
guard
let isReachable = NetworkReachabilityManager()?.isReachable,
isReachable else {
let error = NSError(
domain: "NETWORK_REACHABILITY_DOMAIN",
code: -99,
message: "No Internet connection found. Check your connection."
)
return failure(error)
}
manager.request(
url,
method: method,
parameters: params,
encoding: encoding,
headers: header
).handle(success: success, failure: failure)
}
func requestMultipart<T: Mappable>(
method: HTTPMethod,
_ URLString: URLConvertible,
parameters: [String: String]? = nil,
images: [String: Data],
encoding: Alamofire.ParameterEncoding = URLEncoding.default,
needsAuthorization: Bool = true,
success: @escaping (T)-> Void,
failure: @escaping (Error) -> Void
) {
guard
let isReachable = NetworkReachabilityManager()?.isReachable,
isReachable else {
let error = NSError(
domain: "NETWORK_REACHABILITY_DOMAIN",
code: -99,
message: "No Internet connection found. Check your connection."
)
return failure(error)
}
manager.upload(
multipartFormData: { multipartFormData in
if !images.isEmpty {
images.forEach({ (data) in
multipartFormData.append(data.value, withName: data.key, fileName: data.key + ".jpeg", mimeType: "image/jpeg")
})
}
parameters?.forEach { (params) in
multipartFormData.append(params.value.data(using: String.Encoding.utf8, allowLossyConversion: false)!, withName: params.key)
}
},
to: URLString,
method: method,
headers: needsAuthorization ? afterLoginHeader : beforeLoginHeader,
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.handle(success: success, failure: failure)
case .failure:
let error = NSError(
domain: "NETWORK_REACHABILITY_DOMAIN",
code: -99,
message: "No Internet connection found. Check your connection."
)
failure(error)
}
}
)
}
}
extension APIRouter {
private var endpoint: String {
switch self {
case .accesscode: return "\(baseUrl)/users/access-code"
case .customerProfile: return "\(baseUrl)/mobile/CustomerProfile"
case .customerRegister: return "\(baseUrlWithoutVersion)/v3/mobile/customerRegister"
case .passwordReset: return "\(baseUrl)/mobile/passwordReset"
case .validation: return "\(baseUrlWithoutVersion)/v3/validation"
case .countriesServices: return "\(baseUrl)/mobile/countriesServices"
case .calculateDefExRate: return "\(baseUrl)/mobile/calculateDefExRate"
case .recipientRequirement(let country): return "\(country)"
}
}
private var method: HTTPMethod {
switch self {
case .accesscode: return .post
case .customerProfile: return .post
case .customerRegister: return .post
case .passwordReset: return .post
case .validation: return .post
case .countriesServices: return .get
case .calculateDefExRate: return .post
case .recipientRequirement: return .get
}
}
private var parameters: Parameters? {
switch self {
case .accesscode(let username, let password):
return [
"userId": username,
"password": password
]
case .customerProfile(let firebaseToken):
return [
"userId" : Utility.getMyUserName(),
"uuid": self.uuid,
"appVersion": Utility.getAppVersion() ?? "",
"phoneBrand": Utility.getPhoneBrand(),
"phoneOs": Utility.getPhoneOs(),
"fcmId": firebaseToken,
"osVersion": Utility.getOsVersion()
]
case .customerRegister(let registerModel, let firebaseToken):
return [
"username": registerModel.username ?? "",
"password": registerModel.encryptedPassword ?? "",
"nativecountry": registerModel.nativeCountry ?? "",
"mobilenumber": registerModel.mobileNumber ?? "",
"clientId": Utility.getCliendId(),
"uuid": self.uuid,
"appVersion": Utility.getAppVersion() ?? "",
"phoneBrand": Utility.getPhoneBrand(),
"phoneOs": Utility.getPhoneOs(),
"fcmId": firebaseToken,
"osVersion": Utility.getOsVersion()
]
case .passwordReset(let userName):
return ["username": userName]
case .validation(let userName, let idNumber, let idType):
return [
"Username": userName,
"IdNumber": idNumber,
"IdType": idType
]
case .countriesServices: return nil
case .calculateDefExRate(let model):
return [
"cAmount" : model.senderAmount,
"sCurrency" : model.senderCurrency,
"pAmount" : model.recipientAmount,
"pCurrency" : model.recipientCurrency,
"pCountry" : model.recipientCountryID,
"serviceType": model.serviceType,
"calcBy" : model.calcBy,
"sCountry" : model.senderCountryID,
"pCountryName": model.recipientCountry
]
case .recipientRequirement: return nil
}
}
}

2
GME Remit/AppDelegate.swift

@ -21,7 +21,7 @@ import LGSideMenuController
import Localize_Swift
import ChannelIO
let server: Server = .staging
let server: Server = .live
var overlayView: UIView?
@UIApplicationMain

19
GME Remit/Models/ExchangeRateRequestModel.swift

@ -0,0 +1,19 @@
//
// ExchangeRateRequestModel.swift
// GME Remit
//
// Created by InKwon James Kim on 12/08/2019.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
struct ExchangeRateRequestModel {
let senderAmount: String
let senderCurrency: String
let senderCountryID: String
let recipientAmount: String
let recipientCurrency: String
let recipientCountryID: String
let recipientCountry: String
let serviceType: String
let calcBy: String
}

16
GME Remit/Modules/ExchangeRates/User Interface/View/ExchangeRatesViewController.swift

@ -186,11 +186,21 @@ class ExchangeRatesViewController: UIViewController {
ApiConstants.senderCountryId : senderCountryId ?? "",
ApiConstants.recieverCountryName: recieverCountryName ?? ""
]
// print(param)
// todo
let model = ExchangeRateRequestModel(
senderAmount: (senderAmt ?? "").stringRemovingComma(),
senderCurrency: (senderCurrency ?? ""),
senderCountryID: senderCountryId ?? "",
recipientAmount: (recieverAmt ?? "").stringRemovingComma(),
recipientCurrency: recieverCurrency ?? "",
recipientCountryID: recieverCountryId ?? "",
recipientCountry: recieverCountryName ?? "",
serviceType: paymentMethod ?? "",
calcBy: calcBy ?? ""
)
if shouldShowLoading { self.showProgressHud() }
self.getExchangeRateInformation(params: param, success: { (exchageRateDetail) in
self.getExchangeRateInformation(model: model, success: { (exchageRateDetail) in
self.reciepientTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: exchageRateDetail?.recipientAmount ?? "")
self.senderTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: exchageRateDetail?.senderAmount ?? "")

28
GME Remit/Modules/ForgotPassword/Application Logic/Service/ForgotPasswordServiceType.swift

@ -20,20 +20,22 @@ protocol PasswordResetService: ApiServiceType {
extension PasswordResetService {
func reset(username: String, dob: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "/mobile/passwordReset"
let params = ["username": username,"Dob": dob]
auth.request(method: .post, url: url, params: params, needsAuthorization: false, success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}else {
let model = response.message ?? ""
success(model)
}
}) { (error) in
APIRouter
.passwordReset(userName: username)
.request(
needsAuthorization: false,
success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}
}else {
let model = response.message ?? ""
success(model)
}
},
failure: { failure($0) }
)
}
}

36
GME Remit/Modules/Home/Application Logic/Interactor/HomeInteractor.swift

@ -32,28 +32,20 @@ extension HomeInteractor: HomeInteractorInput {
func fetchUserInfo() {
GMEDB.shared.getFcmToken { (token, error) in
let userId = Utility.getMyUserName()
var param = ["userId" : userId]
param["uuid"] = Utility.getUUid() ?? ""
param["appVersion"] = Utility.getAppVersion()
param["phoneBrand"] = Utility.getPhoneBrand()
param["phoneOs"] = Utility.getPhoneOs()
param["fcmId"] = token ?? ""
param["osVersion"] = Utility.getOsVersion()
self.service.fetchUserInfo(param: param, success: { user in
self.output?.show(model: user)
}) { error in
if let _error = error as? NSError {
if _error.code == AppConstants.emergencyLogoutErrorCode {
self.service.fetchUserInfo(
token: token ?? "",
success: { user in
self.output?.show(model: user)
},
failure: {
let error = $0 as NSError
if error.code == AppConstants.emergencyLogoutErrorCode {
self.output?.show(panicError: error)
return
}
return
}
self.output?.show(error: error)
}
self.output?.show(error: error)
})
}
}
@ -61,10 +53,10 @@ extension HomeInteractor: HomeInteractorInput {
service.fetchHotLines(
success: {
self.output?.setHotLine(with: $0)
},
},
failure: {
self.output?.show(error: $0)
}
}
)
}
}

42
GME Remit/Modules/Home/Application Logic/Service/HomeServiceType.swift

@ -16,28 +16,38 @@ protocol HomeServiceType: class, UserInfoService {
protocol UserInfoService: ApiServiceType {
func fetchUserInfo(param: [String: String], success: @escaping (User) -> (), failure: @escaping (Error) -> ())
func fetchUserInfo(token: String, success: @escaping (User) -> (), failure: @escaping (Error) -> ())
}
extension UserInfoService {
func fetchUserInfo(param: [String: String], success: @escaping (User) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "/mobile/CustomerProfile"
auth.request(method: .post, url: url, params: param, success: { (response: UserContainer ) in
func fetchUserInfo(token: String, success: @escaping (User) -> (), failure: @escaping (Error) -> ()) {
APIRouter
.customerProfile(firebaseToken: token)
.request(
success: { (response: UserContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: AppConstants.emergencyLogoutErrorCode, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
let error = NSError(
domain: "NetWork",
code: AppConstants.emergencyLogoutErrorCode,
message: response.message ?? ""
)
failure(error)
} else {
if let model = response.data {
success(model)
} else {
let error = NSError(
domain: "NetWork",
code: AppConstants.emergencyLogoutErrorCode,
message: response.message ?? ""
)
failure(error)
}else {
if let model = response.data {
success(model)
}else {
let error = NSError.init(domain: "UserInfoService", code: AppConstants.emergencyLogoutErrorCode, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}
}
}
}) { (error) in
failure(error)
}
},
failure: {failure($0)}
)
}
}

45
GME Remit/Modules/Login/Application Logic/Service/LoginService.swift

@ -23,19 +23,40 @@ protocol LoginApiService: ApiServiceType {
}
extension LoginApiService {
func _login(userId: String, password: String, success: @escaping (User?) -> (), failure: @escaping (Error) -> ()) {
let params = [ "userId": userId, "password": password ]
let url = baseUrl + "/users/access-code"
auth.request(method: .post, url: url, params: params,needsAuthorization: false, success: { (response: UserContainer ) in
func _login(
userId: String,
password: String,
success: @escaping (User?) -> (),
failure: @escaping (Error) -> ()
) {
APIRouter
.accesscode(username: userId, password: password)
.request(
needsAuthorization: false,
success: {(response: UserContainer ) 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)
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)
}
},
failure: {failure($0)}
)
// let params = [ "userId": userId, "password": password ]
// let url = baseUrl + "/users/access-code"
// auth.request(method: .post, url: url, params: params,needsAuthorization: false, success: { (response: UserContainer ) 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)
// }
}
}

4
GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Service/SetupRecipientService.swift

@ -9,5 +9,7 @@
import Foundation
class SetupRecipientService: SetupRecipientServiceType {
func fetchRecipientRequirement(of country: String) {
APIRouter.recipientRequirement(country: country)
}
}

2
GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Service/SetupRecipientServiceType.swift

@ -7,5 +7,5 @@
//
protocol SetupRecipientServiceType: class {
func fetchRecipientRequirement(of country: String)
}

12
GME Remit/Modules/RegisterModules/PennyTestSubmit/User Interface/View/PennyTestSubmitViewController.swift

@ -233,17 +233,7 @@ class PennyTestSubmitViewController: UIViewController {
func fetchUserInfo() {
GMEDB.shared.getFcmToken { (token, error) in
let userId = Utility.getMyUserName()
var param = ["userId" : userId]
param["uuid"] = Utility.getUUid() ?? ""
param["appVersion"] = Utility.getAppVersion()
param["phoneBrand"] = Utility.getPhoneBrand()
param["phoneOs"] = Utility.getPhoneOs()
param["fcmId"] = token ?? ""
param["osVersion"] = Utility.getOsVersion()
self.fetchUserInfo(param: param, success: { user in
self.fetchUserInfo(token: token ?? "", success: { user in
self.navigationController?.popToRootViewController(animated: true)
}) { error in
self.navigationController?.popToRootViewController(animated: true)

11
GME Remit/Modules/RegisterModules/Register/Application Logic/Interactor/RegisterInteractor.swift

@ -28,21 +28,12 @@ extension RegisterInteractor: RegisterInteractorInput {
func register(model: RegisterRequestModel) {
GMEDB.shared.getFcmToken { (token, error) in
model.uuid = Utility.getUUid()
model.appVersion = Utility.getAppVersion()
model.phoneBrand = Utility.getPhoneBrand()
model.phoneOs = Utility.getPhoneOs()
model.osVersion = Utility.getOsVersion()
model.fcmId = token ?? ""
model.clientId = Utility.getCliendId()
self.service.register(params: model.serialize(), success: { (message) in
self.service.register(model: model, token: token ?? "", success: { (message) in
self.output?.success(message: message ?? "")
}) { (error) in
self.output?.show(error: error)
}
}
}
func checkDuplicate(userName: String) {

41
GME Remit/Modules/RegisterModules/Register/Application Logic/Service/RegisterServiceType.swift

@ -14,24 +14,39 @@ protocol RegisterServiceType: class, CommonServiceType, RegisterUserService { }
protocol RegisterUserService: ApiServiceType {
func register(params: [String: String], success: @escaping (String?) -> (), failure: @escaping (Error) -> ())
func register(
model: RegisterRequestModel,
token: String,
success: @escaping (String?) -> Void,
failure: @escaping (Error) -> Void
)
}
extension RegisterUserService {
func register(params: [String: String], success: @escaping (String?) -> (), failure: @escaping (Error) -> ()) {
// FIXME: change URL
// let url = baseUrl + "/mobile/customerRegister"
let url = "https://mobileapi.gmeremit.com:8002/api/v3/mobile/customerRegister"
auth.request(method: .post, url: url, params: params, needsAuthorization: false, success: { (response: ResponseMessage) in
func register(
model: RegisterRequestModel,
token: String,
success: @escaping (String?) -> Void,
failure: @escaping (Error) -> Void
) {
APIRouter
.customerRegister(
registerModel: model,
firebaseToken: token
)
.request(
needsAuthorization: false,
success: {(response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}else {
success(response.message)
let error = NSError(domain: "Network", code: 0, message: response.message ?? "")
failure(error)
} else {
success(response.message)
}
}) { (error) in
failure(error)
}
},
failure: {failure($0)}
)
}
}

14
GME Remit/Modules/RewardModules/Redeem/Application Logic/Service/RedeemService.swift

@ -94,19 +94,7 @@ class RedeemService: RedeemServiceType {
GMEDB.shared.getFcmToken { (token, error) in
guard let error = error else {
let param = [
"userId" : Utility.getMyUserName(),
"uuid": Utility.getUUid() ?? "",
"appVersion": Utility.getAppVersion() ?? "",
"phoneBrand": Utility.getPhoneBrand(),
"phoneOs": Utility.getPhoneOs(),
"fcmId": token ?? "",
"osVersion": Utility.getOsVersion()
]
service.fetchUserInfo(param: param, success: success, failure: failure)
service.fetchUserInfo(token: token ?? "", success: success, failure: failure)
return
}

4
GME Remit/Modules/SplashScreen/Application Logic/Interactor/SplashScreenInteractor.swift

@ -34,10 +34,10 @@ extension SplashScreenInteractor: SplashScreenInteractorInput {
)
}
func exchangeCalculate(use param: [String: String]) {
func exchangeCalculate(use model: ExchangeRateRequestModel) {
service.getExchangeRateInformation(
isAuth: false,
params: param,
model: model,
success: { self.output?.setModel(with: $0) },
failure: { self.output?.setError(with: $0) }
)

2
GME Remit/Modules/SplashScreen/Application Logic/Interactor/SplashScreenInteractorIO.swift

@ -8,7 +8,7 @@
protocol SplashScreenInteractorInput: class {
func fetchExchangeRate()
func exchangeCalculate(use param: [String: String])
func exchangeCalculate(use model: ExchangeRateRequestModel)
}
protocol SplashScreenInteractorOutput: class {

2
GME Remit/Modules/SplashScreen/Module Interface/SplashScreenModuleInterface.swift

@ -11,5 +11,5 @@ protocol SplashScreenModuleInterface: class {
func register()
func fetchExchangeRate()
func exchangeCalculate(use param: [String: String])
func exchangeCalculate(use model: ExchangeRateRequestModel)
}

4
GME Remit/Modules/SplashScreen/User Interface/Presenter/SplashScreenPresenter.swift

@ -35,9 +35,9 @@ extension SplashScreenPresenter: SplashScreenModuleInterface {
interactor?.fetchExchangeRate()
}
func exchangeCalculate(use param: [String: String]) {
func exchangeCalculate(use model: ExchangeRateRequestModel) {
view?.showLoading()
interactor?.exchangeCalculate(use: param)
interactor?.exchangeCalculate(use: model)
}
}

14
GME Remit/Modules/SplashScreen/User Interface/View/SplashScreenViewController.swift

@ -516,7 +516,19 @@ extension SplashScreenViewController {
"pCountryName": selectedExchangeRateModel?.country ?? ""
]
presenter?.exchangeCalculate(use: param)
let model = ExchangeRateRequestModel(
senderAmount: (senderTextField.text ?? "").stringRemovingComma(),
senderCurrency: "KRW",
senderCountryID: "118",
recipientAmount: (recipientTextField.text ?? "").stringRemovingComma(),
recipientCurrency: selectedExchangeRateModel?.currency ?? "",
recipientCountryID: selectedExchangeRateModel?.countryId ?? "",
recipientCountry: selectedExchangeRateModel?.country ?? "",
serviceType: selectedExchangeRateModel?.availableServices?.elementAt(index: selectedPaymentModeIndex)?.id ?? "",
calcBy: calcBy
)
presenter?.exchangeCalculate(use: model)
}
private func showExchangeRateInfomation(isHidden flag: Bool) {

Loading…
Cancel
Save