User Roles
SAPcpmsUserRoles
Loads information (name, id, roles) about the current user from SAP Mobile Services.
The id
and the userName
of the user are always available. Roles parameter is available only if the access control is enabled in SAP Mobile Services Cockpit. If the response from the server contains information about the current user’s name or email address, that information is parsed as well. One might setup custom fields on the server, these fields and its values are gathered under the others
dictionary.
Overview of the SAP Mobile Services – Role Service API: GET Role Service
Usage
Setting up SAPcpmsUserRoles
Use the SAPFoundation
framework’s SAPcpmsUserRoles
component implementation.
Create an SAPURLSession
and add it to one of the initializers.
a.) Convenience initializer
The recommended initializer is using the SAPcpmsSettingsParameters
as a parameter:
var urlSession = SAPURLSession()
let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
let userRoles = SAPcpmsUserRoles(sapURLSession: urlSession, settingsParameters: settingsParameters)
b.) Default initializer
The default initializer is using SAPURLSession and the full URL of the mobile services role service as an input
var urlSession = SAPURLSession()
let userRoles = SAPcpmsUserRoles(sapURLSession: urlSession, roleServiceUrl: <#role service URL#>)
Loading information about the user
This sample code demonstrates how to load information about the current user:
userRoles.load { userInfo, error in
// use userInfo struct and handle error here
}
-
Loads information (name, id, roles) about the current user from SAP Mobile Services.
This sample code demonstrates how to create an SAPcpmsUserRoles instance:
See morevar urlSession = SAPURLSession() let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>) let userRoles = SAPcpmsUserRoles(sapURLSession: urlSession, settingsParameters: settingsParameters)
Declaration
Swift
open class SAPcpmsUserRoles
-
Enum covering all errors occuring in the SAPcpmsUserRoles.
See moreDeclaration
Swift
public enum SAPcpmsUserRolesError : Error
extension SAPcpmsUserRolesError: SAPError