File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -26,4 +26,11 @@ extension Keychain {
2626 get { self [ WooConstants . siteCredentialPassword] }
2727 set { self [ WooConstants . siteCredentialPassword] = newValue }
2828 }
29+
30+ /// AI key provided by the merchant
31+ ///
32+ var merchantAIProviderKey : String ? {
33+ get { self [ WooConstants . merchantAIProviderKey] }
34+ set { self [ WooConstants . merchantAIProviderKey] = newValue }
35+ }
2936}
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ public enum WooConstants {
4545 ///
4646 static let sharedUserDefaultsSuiteName = " group.com.automattic.woocommerce "
4747
48+ /// Keychain Access's Key for the AI key entered by the merchant in AI settings
49+ ///
50+ static let merchantAIProviderKey = " merchantAIProviderKey "
51+
4852 /// Push Notifications ApplicationID
4953 ///
5054#if DEBUG
Original file line number Diff line number Diff line change 11import SwiftUI
2+ import KeychainAccess
23
34@Observable final class AISettingsViewModel {
5+ var keychain = Keychain ( service: WooConstants . keychainServiceName)
6+
47 var usesJetpackAsDefaultAIProviderSource : Bool = false
58 var isEditingApiKey : Bool = false
69 var apiKey : String = " "
@@ -20,11 +23,12 @@ import SwiftUI
2023 }
2124
2225 func clearAPIKey( ) {
23- // TODO
26+ apiKey = " "
27+ keychain. merchantAIProviderKey = nil
2428 }
2529
2630 private func saveSettings( ) {
27- // TODO
31+ keychain . merchantAIProviderKey = apiKey
2832 }
2933}
3034
You can’t perform that action at this time.
0 commit comments