InKwon James Kim
5 years ago
76 changed files with 823 additions and 594 deletions
-
BIN.DS_Store
-
37GME Remit.xcodeproj/project.pbxproj
-
BINGMERemittance/.DS_Store
-
240GMERemittance/Api/RestApiManager.swift
-
21GMERemittance/AppDelegate.swift
-
2GMERemittance/Base/WireframeInput.swift
-
20GMERemittance/Extension/UIViewControllerExtension.swift
-
4GMERemittance/Extension/UIViewExtension.swift
-
46GMERemittance/Library/MultiMediaManager.swift
-
4GMERemittance/Library/WebLinks/WebLinksViewController.swift
-
4GMERemittance/Library/WebLinks/WkWebView/WkWebViewController.swift
-
47GMERemittance/Model/User.swift
-
8GMERemittance/Module/AppUpdate/User Interface/View/AppUpdate.storyboard
-
11GMERemittance/Module/AppUpdate/User Interface/View/AppUpdateViewController.swift
-
2GMERemittance/Module/AutoDebitModules/AddAccount/User Interface/View/AddAccountViewController.swift
-
4GMERemittance/Module/AutoDebitModules/AutoDebit/Application Logic/Interactor/AutoDebitInteractor.swift
-
8GMERemittance/Module/AutoDebitModules/AutoDebit/User Interface/View/AutoDebitViewController.swift
-
2GMERemittance/Module/Cell/GmeContactsTableViewCell.swift
-
14GMERemittance/Module/ExchangeRates/User Interface/View/ExchangeRatesViewController.swift
-
4GMERemittance/Module/ForgotPassword/User Interface/View/ForgotPasswordViewController.swift
-
6GMERemittance/Module/GmeContacts/User Interface/View/GmeContactsViewController.swift
-
4GMERemittance/Module/Home/User Interface/View/Cell/HomeRemainingLimitTableViewCell.swift
-
35GMERemittance/Module/Home/User Interface/View/HomeViewController.swift
-
4GMERemittance/Module/Login/User Interface/View/LoginViewController.swift
-
8GMERemittance/Module/Main/User Interface/View/MainViewController.swift
-
40GMERemittance/Module/Main/User Interface/Wireframe/MainWireframe.swift
-
11GMERemittance/Module/PopupNotification/User Interface/View/PopupNotificationViewController.swift
-
14GMERemittance/Module/PopupNotification/User Interface/Wireframe/PopupNotificationWireframe.swift
-
2GMERemittance/Module/Profile/ProfileChangePasswordViewController.swift
-
17GMERemittance/Module/Profile/ProfileViewController.swift
-
7GMERemittance/Module/RegisterModules/KYC/Kyc/Application Logic/Interactor/KycInteractor.swift
-
2GMERemittance/Module/RegisterModules/KYC/Kyc/User Interface/View/KycViewController.swift
-
4GMERemittance/Module/RegisterModules/KYC/kycForm1/User Interface/View/kycForm1ViewController.swift
-
6GMERemittance/Module/RegisterModules/KYC/kycForm2/User Interface/View/kycForm2ViewController.swift
-
4GMERemittance/Module/RegisterModules/KYC/kycForm3/User Interface/View/kycForm3ViewController.swift
-
18GMERemittance/Module/RegisterModules/PennyTest/User Interface/View/PennyTestViewController.swift
-
26GMERemittance/Module/RegisterModules/PennyTestSubmit/User Interface/View/PennyTestSubmitViewController.swift
-
2GMERemittance/Module/RegisterModules/Register/User Interface/View/RegisterViewController.swift
-
2GMERemittance/Module/RewardModules/OrderHistory/Application Logic/Service/OrderHistoryService.swift
-
2GMERemittance/Module/RewardModules/OrderHistory/User Interface/View/OrderHistoryViewController.swift
-
10GMERemittance/Module/RewardModules/Redeem/User Interface/View/RedeemViewController.swift
-
2GMERemittance/Module/RewardModules/Reward/User Interface/View/Cell/RewardItemCollectionViewCell.swift
-
4GMERemittance/Module/RewardModules/Reward/User Interface/View/RewardViewController.swift
-
2GMERemittance/Module/SendMoneyModules/PaymentSelection/User Interface/View/PaymentSelectionViewController.swift
-
2GMERemittance/Module/SendMoneyModules/Recipient/AddReciepient/User Interface/View/AddReciepientViewController.swift
-
3GMERemittance/Module/SendMoneyModules/Recipient/EditReciepient/Application Logic/Interactor/EditReciepientInteractor.swift
-
2GMERemittance/Module/SendMoneyModules/Recipient/EditReciepient/User Interface/View/EditReciepientViewController.swift
-
12GMERemittance/Module/SendMoneyModules/Recipient/RecipientListViewController.swift
-
2GMERemittance/Module/SendMoneyModules/Resend/User Interface/View/ResendViewController.swift
-
6GMERemittance/Module/SendMoneyModules/ResendExchange/User Interface/View/ResendExchangeViewController.swift
-
9GMERemittance/Module/SendMoneyModules/SendMoneyCode/User Interface/View/SendMoneyCodeViewController.swift
-
8GMERemittance/Module/SendMoneyModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift
-
12GMERemittance/Module/SendMoneyModules/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift
-
6GMERemittance/Module/SendMoneyModules/SendMoneyPaymentMode/User Interface/View/BankBranchPicker/BankBranchPickerViewController.swift
-
2GMERemittance/Module/SendMoneyModules/SendMoneyPaymentMode/User Interface/View/SendMoneyPaymentModeViewController.swift
-
4GMERemittance/Module/SendMoneyModules/SendMoneyPaymentMode/User Interface/View/ViewModels/BankPicker/BankPickerViewController.swift
-
10GMERemittance/Module/SendMoneyModules/SendMoneyReceipt/User Interface/View/SendMoneyReceiptViewController.swift
-
8GMERemittance/Module/SendMoneyModules/SendMoneyVerification/Application Logic/Interactor/SendMoneyVerificationInteractor.swift
-
6GMERemittance/Module/SendMoneyModules/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift
-
12GMERemittance/Module/SideMenu/AboutGMEViewController.swift
-
10GMERemittance/Module/SideMenu/Auto refund/AutoRefundsViewController.swift
-
2GMERemittance/Module/SideMenu/SettingViewController.swift
-
31GMERemittance/Module/SideMenu/SideMenuViewController.swift
-
20GMERemittance/Module/SplashScreen/User Interface/View/SplashScreenViewController.swift
-
4GMERemittance/Module/TransactionHistoryModules/MessageCompose/User Interface/View/MessageComposeViewController.swift
-
4GMERemittance/Module/TransactionHistoryModules/TransactionHistory/User Interface/View/DatePickerViewController.swift
-
2GMERemittance/Module/TransactionHistoryModules/TransactionHistory/User Interface/View/TransactionHistoryViewController.swift
-
2GMERemittance/Module/WalletStatement/User Interface/View/WalletStatementViewController.swift
-
BINGMERemittance/Utility/.DS_Store
-
148GMERemittance/Utility/AppConstants.swift
-
138GMERemittance/Utility/Database/GMEDB.swift
-
119GMERemittance/Utility/Database/UserDefaultsWrapper.swift
-
2GMERemittance/Utility/GMENumberTextField.swift
-
4GMERemittance/Utility/HotLine/Application Logic/Interactor/HotLineInteractor.swift
-
4GMERemittance/Utility/KeyChain.swift
-
113GMERemittanceTests/DatabaseTest.swift
@ -0,0 +1,138 @@ |
|||
// |
|||
// Database.swift |
|||
// GME Remit |
|||
// |
|||
// Created by InKwon James Kim on 17/07/2019. |
|||
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. |
|||
// |
|||
|
|||
protocol GMEDBKeyProtocol: RawRepresentable, CaseIterable {} |
|||
|
|||
class GMEDB { |
|||
static let shared = GMEDB() |
|||
|
|||
private var database: UserDefaults { |
|||
return UserDefaults.standard |
|||
} |
|||
|
|||
enum UserKeys: String, GMEDBKeyProtocol { |
|||
case pennyTestServerMessage = "pennyTestServerMessage" |
|||
case pennyTestStatusCode = "pennyTestStatusCode" |
|||
case pennyTestRequested = "pennyTestRequested" |
|||
case pennyTestPresentedOnce = "pennyTestPresentedOnce" |
|||
|
|||
case accessTokenRegTime = "accessTokenRegTime" |
|||
case accessTokenExpTime = "accessTokenExpTime" |
|||
|
|||
case yearlyLimit = "yearlyLimit" |
|||
case userId = "com.gmeremit.username" |
|||
case senderId = "senderId" |
|||
case fullName = "com.gmeremit.fullName" |
|||
case firstName = "firstName" |
|||
case middleName = "middleName" |
|||
case lastName = "lastName" |
|||
case nickName = "com.gmeremit.nickName" |
|||
case dateOfBirth = "date_of_birth" |
|||
|
|||
case email = "com.gmeremit.email" |
|||
case mobileNumber = "com.gmeremit.mobileNumber" |
|||
case rewardPoint = "com.gmeremit.rewardPoint" |
|||
case walletNumber = "com.gmeremit.walletNumber" |
|||
case availableBalance = "com.gmeremit.balance" |
|||
case primaryBankName = "com.gmeremit.bankName" |
|||
case primaryAccountNumber = "PrimaryAccountNumber" |
|||
case accessCode = "com.gmeremit.accessCode" |
|||
case dpUrl = "com.gmeremit.dpUrl" |
|||
case kyc = "com.gmeremit.isKYCSubmitted" |
|||
case verified = "com.gmeremit.isVerified" |
|||
case active = "active" |
|||
case cmRegistrationId = "cmRegistrationId" |
|||
case isReferred = "com.gmeremit.isReferred" |
|||
case country = "country" |
|||
case province = "province" |
|||
case provinceId = "provinceId" |
|||
case sourceId = "com.gmeremit.sourceId" |
|||
case idType = "idType" |
|||
case idNumber = "idNumber" |
|||
case countryCode = "countryCode" |
|||
case ErrorCode = "ErrorCode" |
|||
case hasRequestedPennyTest = "hasRequestedPennyTest" |
|||
case isPennyTestPending = "isPennyTestPending" |
|||
case kftcClientId = "kftcClientId" |
|||
case Msg = "Msg" |
|||
case Id = "Id" |
|||
case Data = "Data" |
|||
case isUseBiometricAuth = "com.gmeremit.isUseBiometricAuth" |
|||
case remindKFTCTokenDay = "remindKFTCTokenDay" |
|||
} |
|||
|
|||
enum AppKey: String, GMEDBKeyProtocol { |
|||
case uuid = "uuid" |
|||
case firstTimeLanguageIsSet = "firstTimeLanguageIsSet" |
|||
case criticalUpdate = "criticalUpdate" |
|||
case currentLanguage = "currentLanguage" |
|||
|
|||
case dateOfDontShowNotification = "dateOfDontShowNotification" |
|||
case dateOfExpireNotification = "dateOfExpireNotification" |
|||
|
|||
case isOpenedTokenRenwalAlert = "isOpenedTokenRenwalAlert" |
|||
case isOpenedPopupNotification = "isOpenedPopupNotification" |
|||
} |
|||
|
|||
let user = UserDefaultsWrapper<UserKeys>() |
|||
let app = UserDefaultsWrapper<AppKey>() |
|||
|
|||
} |
|||
|
|||
extension GMEDB { |
|||
@discardableResult |
|||
func setUser(_ user: User?) -> UserDefaultsWrapper<UserKeys> { |
|||
let firstName = user?.firstName ?? "" |
|||
let middleName = user?.lastName ?? "" |
|||
let lastName = user?.lastName ?? "" |
|||
let fullName = firstName + " " + middleName + " " + lastName |
|||
|
|||
self.user |
|||
.set(user?.dpUrl, .dpUrl) |
|||
.set(user?.walletNumber, .walletNumber) |
|||
.set(user?.primaryBankName, .primaryBankName) |
|||
|
|||
self.user |
|||
.set(fullName, .fullName) |
|||
.set(firstName, .firstName) |
|||
.set(lastName, .lastName) |
|||
.set(user?.userId, .userId) |
|||
.set(user?.nickName, .nickName) |
|||
|
|||
self.user |
|||
.set(user?.availableBalance, .availableBalance) |
|||
.set(user?.rewardPoint, .rewardPoint) |
|||
.set(user?.verified, .verified) |
|||
.set(user?.kyc, .kyc) |
|||
|
|||
self.user |
|||
.set(user?.email, .email) |
|||
.set(user?.mobileNumber, .mobileNumber) |
|||
.set(user?.sourceId, .sourceId) |
|||
.set(user?.isReferred, .isReferred) |
|||
|
|||
self.user |
|||
.set(user?.idType, .idType) |
|||
.set(user?.idNumber, .idNumber) |
|||
.set(user?.country, .country) |
|||
.set(user?.countryCode, .countryCode) |
|||
|
|||
self.user |
|||
.set(user?.primaryAccountNumber, .primaryAccountNumber) |
|||
.set(user?.senderId, .senderId) |
|||
.set(user?.yearlyLimit, .yearlyLimit) |
|||
.set(user?.dateOfBirth, .dateOfBirth) |
|||
|
|||
self.user |
|||
.set(user?.pennyTestStatus, .pennyTestStatusCode) |
|||
.set(user?.accessTokenRegTime, .accessTokenRegTime) |
|||
.set(user?.accessTokenExpTime, .accessTokenExpTime) |
|||
|
|||
return self.user |
|||
} |
|||
} |
@ -0,0 +1,119 @@ |
|||
// |
|||
// InnerDatabase.swift |
|||
// GME Remit |
|||
// |
|||
// Created by InKwon James Kim on 17/07/2019. |
|||
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. |
|||
// |
|||
|
|||
class UserDefaultsWrapper<Keys: GMEDBKeyProtocol> where Keys.RawValue == String { |
|||
func float(_ key: Keys) -> Float? { |
|||
return UserDefaults.standard.float(forKey: key.rawValue) |
|||
} |
|||
|
|||
func string(_ key: Keys) -> String? { |
|||
return UserDefaults.standard.string(forKey: key.rawValue) |
|||
} |
|||
|
|||
func bool(_ key: Keys) -> Bool { |
|||
return UserDefaults.standard.bool(forKey: key.rawValue) |
|||
} |
|||
|
|||
func double(_ key: Keys) -> Double? { |
|||
return UserDefaults.standard.double(forKey: key.rawValue) |
|||
} |
|||
|
|||
func integer(_ key: Keys) -> Int { |
|||
return UserDefaults.standard.integer(forKey: key.rawValue) |
|||
} |
|||
|
|||
func object(_ key: Keys) -> Any? { |
|||
return UserDefaults.standard.object(forKey: key.rawValue) |
|||
} |
|||
} |
|||
|
|||
extension UserDefaultsWrapper { |
|||
@discardableResult |
|||
func set(_ url: URL?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(url, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: Any?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: Bool?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: Double?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: String?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: Int?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func set(_ value: Float?, _ key: Keys) -> Self { |
|||
UserDefaults.standard.set(value, forKey: key.rawValue) |
|||
return self |
|||
} |
|||
} |
|||
|
|||
extension UserDefaultsWrapper { |
|||
@discardableResult |
|||
func remove(_ key: Keys) -> Self { |
|||
UserDefaults.standard.removeObject(forKey: key.rawValue) |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func remove(_ keys: [Keys]) -> Self { |
|||
keys.forEach { |
|||
UserDefaults.standard.removeObject(forKey: $0.rawValue) |
|||
} |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func removeAll() -> Self { |
|||
Keys.allCases.forEach{ |
|||
UserDefaults.standard.removeObject(forKey: $0.rawValue) |
|||
} |
|||
return self |
|||
} |
|||
} |
|||
|
|||
extension UserDefaultsWrapper { |
|||
@discardableResult |
|||
func debugPrint(_ key: Keys) -> UserDefaultsWrapper { |
|||
print("\(key.rawValue): \(object(key) as Any)") |
|||
return self |
|||
} |
|||
|
|||
@discardableResult |
|||
func debugPrintAllElement() -> Self { |
|||
print("\(Keys.self)'s All Elements") |
|||
|
|||
Keys.allCases.forEach{ |
|||
print("\($0.rawValue): \(object($0) as Any)") |
|||
} |
|||
return self |
|||
} |
|||
} |
@ -0,0 +1,113 @@ |
|||
// |
|||
// DatabaseTest.swift |
|||
// GMERemittanceTests |
|||
// |
|||
// Created by InKwon James Kim on 17/07/2019. |
|||
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. |
|||
// |
|||
|
|||
import XCTest |
|||
@testable import GME_Remit |
|||
class DatabaseTest: XCTestCase { |
|||
|
|||
let testUserJson = |
|||
""" |
|||
|
|||
{ |
|||
"Id" : "", |
|||
"Extra" : "", |
|||
"Extra2" : "", |
|||
"Data" : { |
|||
"accessCode" : null, |
|||
"accessTokenRegTime" : "", |
|||
"kyc" : false, |
|||
"mobileNumber" : "", |
|||
"provinceId" : "", |
|||
"availableBalance" : "0", |
|||
"country" : "", |
|||
"ErrorCode" : "0", |
|||
"pennyTestStatus" : "0", |
|||
"accessTokenExpTime" : "", |
|||
"Extra" : "", |
|||
"firstName" : "iosDemo@gmeremit.com", |
|||
"Data" : null, |
|||
"yearlyLimit" : "30,000", |
|||
"dob" : "1988-03-27", |
|||
"dpUrl" : null, |
|||
"email" : "iosDemo@gmeremit.com", |
|||
"sourceId" : "", |
|||
"countryCode" : "", |
|||
"senderId" : "17", |
|||
"active" : true, |
|||
"appUpdate" : [ |
|||
{ |
|||
"Info" : "This version of the app is out of date and will stop working soon. To keep using GME, please install the latest update.", |
|||
"OS" : "IOS", |
|||
"Build" : "6", |
|||
"Version" : "2.2.2", |
|||
"Critical" : "Y" |
|||
}, |
|||
{ |
|||
"Info" : "This version of the app is out of date and will stop working soon. To keep using GME, please install the latest update.", |
|||
"OS" : "ANDROID", |
|||
"Build" : "17", |
|||
"Version" : "2.3.0", |
|||
"Critical" : "Y" |
|||
} |
|||
], |
|||
"Extra2" : "", |
|||
"isReferred" : false, |
|||
"rewardPoint" : "0", |
|||
"province" : "", |
|||
"cmRegistrationId" : "", |
|||
"Msg" : "", |
|||
"primaryBankName" : "", |
|||
"Id" : "", |
|||
"verified" : false, |
|||
"walletNumber" : "", |
|||
"userId" : "iosDemo@gmeremit.com", |
|||
"kftcClientId" : null |
|||
}, |
|||
"ErrorCode" : "0", |
|||
"Msg" : "success" |
|||
} |
|||
|
|||
""" |
|||
|
|||
|
|||
func testSetUser() { |
|||
let object = UserContainer(JSONString: testUserJson) |
|||
GMEDB |
|||
.shared |
|||
.setUser(object?.data) |
|||
.debugPrintAllElement() |
|||
|
|||
XCTAssert(GMEDB.shared.user.string(.availableBalance) == Optional("0")) |
|||
XCTAssert(GMEDB.shared.user.string(.country) == Optional("")) |
|||
XCTAssert(GMEDB.shared.user.string(.ErrorCode) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.pennyTestStatusCode) == Optional("0")) |
|||
XCTAssert(GMEDB.shared.user.string(.firstName) == Optional("iosDemo@gmeremit.com")) |
|||
XCTAssert(GMEDB.shared.user.string(.Data) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.yearlyLimit) == Optional("30,000")) |
|||
XCTAssert(GMEDB.shared.user.string(.dateOfBirth) == Optional("1988-03-27")) |
|||
XCTAssert(GMEDB.shared.user.string(.senderId) == Optional("17")) |
|||
} |
|||
|
|||
func testRemoveAll() { |
|||
GMEDB |
|||
.shared |
|||
.user |
|||
.removeAll() |
|||
.debugPrintAllElement() |
|||
|
|||
XCTAssert(GMEDB.shared.user.string(.availableBalance) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.country) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.ErrorCode) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.pennyTestStatusCode) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.firstName) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.Data) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.yearlyLimit) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.dateOfBirth) == nil) |
|||
XCTAssert(GMEDB.shared.user.string(.senderId) == nil) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue