SAPcpmsSettings
open class SAPcpmsSettings
A settings reading and storing settings JSON from and to SAP Mobile Services. It uses the SAP Mobile Services Store API endpoint for that.
These protocols represent the following JSON payload which is returned by the Settings Exchange API of SAP Mobile Services
{
"mobileservices": {
"__metadata": {
"writeRoles": ["Administrator"]
},
"settingsExchange": {
"passwordPolicy": {
"passwordPolicyMinLength": "8",
"passwordPolicyLowerRequired": "false",
"passwordPolicyDefaultPasswordAllowed": "false",
"passwordPolicyRetryLimit": "10",
"passwordPolicyUpperRequired": "false",
"passwordPolicyEnabled": "false",
"passwordPolicySpecialRequired": "false",
"passwordPolicyExpiresInNDays": "0",
"passwordPolicyLockTimeout": "300",
"passwordPolicyDigitRequired": "false",
"passwordPolicyMinUniqueChars": "0"
},
"featureVectorPolicies": {
"featureVectorPolicyAllEnabled": "true",
"restrictedPolicies": null
},
"attestationSettings": {
"iOS": {
"enabled": true,
"enforced": false
},
"android": {
"enabled": "false",
"enforced": "false"
}
}
"logSettings": {
"logEntryExpiry": "7",
"logLevel": "NONE"
}
}
},
//Custom App-Specific data (structure unknown and defined by app)
customAppDefinedConfigs1: {
appConfig1: "value1",
appConfig2: "value2"
},
//Custom App-Specific data (structure unknown and defined by app)
customAppDefinedConfigs2: {
appConfig1: "value1",
appConfig2: "value2"
},
}
This sample code demonstrates how to create an SAPcpmsSettings instance:
var urlSession = SAPURLSession()
let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
let settings = SAPcpmsSettings(sapURLSession: urlSession, settingsParameters: settingsParameters)
-
Enum for decide which level properties have to store/read
See moreDeclaration
Swift
public enum SettingsTarget
-
Default initializer for using URL and URL parts as inputs The .user is the default settingsTarget and therefore “userSettingsURL” should not be nil.
Declaration
Swift
public init(sapURLSession: SAPURLSession, applicationSettingsURL: URL, userSettingsURL: URL?, deviceSettingsURL: URL?)
Parameters
sapURLSession
an SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
applicationSettingsURL
the full URL of the application settings
userSettingsURL
the full URL of the user specific settings.
deviceSettingsURL
the full URL of the device specific settings
-
Default initializer for using SAPcpmsSettingsParameters as an input The .user is the default settingsTarget and therefore “userName” should not be nil in SAPcpmsSettingsParameters.
Declaration
Swift
public init(sapURLSession: SAPURLSession, settingsParameters: SAPcpmsSettingsParameters)
Parameters
sapURLSession
an SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
settingsParameters
SAPcpms settings metadata to be able to concatenate the SAPcpms URL
-
Loads SAP Mobile Services settings on the server. Send a REST request to SAP Mobile Services Store API endpoint. Retrieves JSON payload. Converts the response to a Dictionary and returns it to the completion handler.
Declaration
Swift
open func loadSAPcpmsSettings(completionHandler: @escaping ([String : Any]?, Error?) -> Void)
Parameters
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
completionHandler
called on a background queue with the result received from the server. The parameters are the retrieved settings Dictionary and the Error. One of them could be nil.
-
Loads SAP Mobile Services settings on the server. Send a REST request to SAP Mobile Services Store API endpoint. Retrieves JSON payload. Converts the response to a Dictionary and returns it asynchronously.
Declaration
Swift
open func loadSAPcpmsSettings() async throws -> [String : Any]
-
Loads settings from the server. Send a REST request to SAP Mobile Services Store API endpoint. Retrieves JSON payload. Converts the response to a Dictionary and return it to the completion handler.
Declaration
Swift
open func load(settingsKeyPath: String? = nil, for settingsTarget: SettingsTarget = .user, completionHandler: @escaping ([String : Any]?, Error?) -> Void)
Parameters
settingsKeyPath
path as a key for the dictionary to load. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
completionHandler
called on a background queue with the result received from the server. The parameters are the retrieved settings Dictionary and the Error. One of them could be nil.
-
Loads settings from the server. Send a REST request to SAP Mobile Services Store API endpoint. Retrieves JSON payload. Converts the response to a Dictionary and returns it asynchronously.
Declaration
Swift
open func load(settingsKeyPath: String? = nil, for settingsTarget: SettingsTarget = .user) async throws -> [String : Any]
Parameters
settingsKeyPath
path as a key for the dictionary to load. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
-
Deletes settings on the server
Declaration
Swift
open func delete(settingsKeyPath: String, for settingsTarget: SettingsTarget = .user, completionHandler: @escaping (Error?) -> Void = SAPcpmsSettings.defaultCompletionHandler)
Parameters
settingsKeyPath
path as a key for the dictionary to delete. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
completionHandler
called when the result received from the server on background queue. The parameter is an error that could be nil.
-
Deletes settings on the server
Declaration
Swift
open func delete(settingsKeyPath: String, for settingsTarget: SettingsTarget = .user) async throws
Parameters
settingsKeyPath
path as a key for the dictionary to delete. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
-
Creates or updates settings on the server The complete settings dictionary of the remote data will be overwritten with the dictionary that is passed to this method.
Declaration
Swift
open func store(settings: [String : Any], settingsKeyPath: String, for settingsTarget: SettingsTarget = .user, completionHandler: @escaping (Error?) -> Void = SAPcpmsSettings.defaultCompletionHandler)
Parameters
settings
the settings that can be stored on the
settingsKeyPath
path as a key for the dictionary to store. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
completionHandler
called when the result received from the server on background queue. The parameter is an error that could be nil.
-
Creates or updates settings on the server The complete settings dictionary of the remote data will be overwritten with the dictionary that is passed to this method.
Declaration
Swift
open func store(settings: [String : Any], settingsKeyPath: String, for settingsTarget: SettingsTarget = .user) async throws
Parameters
settings
the settings that can be stored on the
settingsKeyPath
path as a key for the dictionary to store. The slash separated keys are specifying different levels. With this parameter the API can reach either a part of the JSON or a property directly.
settingsTarget
router to application/user/device specific setting storage. The .user is the default settingsTarget and therefore user settings URL should not be nil.
-
The default completion handler for SAPcpmsSettings. Logs the error with the root logger if there is any.
Declaration
Swift
public static func defaultCompletionHandler(_ error: Error?)
Parameters
error
error that will be logged