Browse Source

optimize GMEDB

pull/1/head
InKwon James Kim 5 years ago
parent
commit
6dc722d815
  1. 80
      GMERemittance/Utility/Database/GMEDB.swift
  2. 6
      GMERemittance/Utility/Database/UserDefaultsWrapper.swift

80
GMERemittance/Utility/Database/GMEDB.swift

@ -6,31 +6,25 @@
// 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"
enum UserKeys: String, KeyProtocol {
case pennyTestServerMessage
case pennyTestStatusCode
case pennyTestRequested
case pennyTestPresentedOnce
case accessTokenRegTime = "accessTokenRegTime"
case accessTokenExpTime = "accessTokenExpTime"
case accessTokenRegTime
case accessTokenExpTime
case yearlyLimit = "yearlyLimit"
case yearlyLimit
case userId = "com.gmeremit.username"
case senderId = "senderId"
case senderId
case fullName = "com.gmeremit.fullName"
case firstName = "firstName"
case middleName = "middleName"
case lastName = "lastName"
case firstName
case middleName
case lastName
case nickName = "com.gmeremit.nickName"
case dateOfBirth = "date_of_birth"
@ -40,43 +34,43 @@ class GMEDB {
case walletNumber = "com.gmeremit.walletNumber"
case availableBalance = "com.gmeremit.balance"
case primaryBankName = "com.gmeremit.bankName"
case primaryAccountNumber = "PrimaryAccountNumber"
case 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 active
case cmRegistrationId = "cmRegistrationId"
case isReferred = "com.gmeremit.isReferred"
case country = "country"
case province = "province"
case provinceId = "provinceId"
case country
case province
case 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 idType
case idNumber
case countryCode
case ErrorCode
case hasRequestedPennyTest
case isPennyTestPending
case kftcClientId
case Msg
case Id
case Data
case isUseBiometricAuth = "com.gmeremit.isUseBiometricAuth"
case remindKFTCTokenDay = "remindKFTCTokenDay"
case remindKFTCTokenDay
}
enum AppKey: String, GMEDBKeyProtocol {
case uuid = "uuid"
case firstTimeLanguageIsSet = "firstTimeLanguageIsSet"
case criticalUpdate = "criticalUpdate"
case currentLanguage = "currentLanguage"
enum AppKey: String, KeyProtocol {
case uuid
case firstTimeLanguageIsSet
case criticalUpdate
case currentLanguage
case dateOfDontShowNotification = "dateOfDontShowNotification"
case dateOfExpireNotification = "dateOfExpireNotification"
case dateOfDontShowNotification
case dateOfExpireNotification
case isOpenedTokenRenwalAlert = "isOpenedTokenRenwalAlert"
case isOpenedPopupNotification = "isOpenedPopupNotification"
case isOpenedTokenRenwalAlert
case isOpenedPopupNotification
}
let user = UserDefaultsWrapper<UserKeys>()

6
GMERemittance/Utility/Database/UserDefaultsWrapper.swift

@ -6,7 +6,11 @@
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
class UserDefaultsWrapper<Keys: GMEDBKeyProtocol> where Keys.RawValue == String {
protocol KeyProtocol: RawRepresentable, CaseIterable {}
class UserDefaultsWrapper<Keys: KeyProtocol> where Keys.RawValue == String {
func float(_ key: Keys) -> Float? {
return UserDefaults.standard.float(forKey: key.rawValue)
}

Loading…
Cancel
Save