SAPcpmsClientResources
open class SAPcpmsClientResources
The SAPcpmsClientResources Downloads client resources or information about resources from mobile services.
It uses the SAP Mobile Services Client Resources Service API endpoint for that.
This sample code demonstrates how to create an SAPcpmsClientResources instance:
var urlSession = SAPURLSession()
let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
let clientResources = SAPcpmsClientResources(sapURLSession: urlSession, settingsParameters: settingsParameters)
-
URL pattern: /mobileservices/application/{applicationId}/bundles/v1/runtime/bundle/application/{applicationId} URL pattern: /mobileservices/application/{applicationId}/bundles/v1/runtime/bundle/application/{applicationId}/bundle/{bundleName} URL pattern: /mobileservices/application/{applicationId}/bundles/v1/runtime/bundle/application/{applicationId}/bundle/{bundleName}/version/{version} URL pattern: /mobileservices/application/{applicationId}/bundles/v1/runtime/bundle/application/{applicationId}/list 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, clientResourcesURL: URL)Parameters
sapURLSessionan SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
clientResourcesURLthe full URL of the client resources
-
Default initializer for using SAPcpmsSettingsParameters as an input
Declaration
Swift
public convenience init(sapURLSession: SAPURLSession, settingsParameters: SAPcpmsSettingsParameters)Parameters
sapURLSessionan SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
settingsParametersSAPcpms settings metadata to be able to concatenate the SAPcpms URL
-
Downloads client resources from SAPcpms
Declaration
Swift
open func downloadResource(named: String? = nil, version: String? = nil, completionHandler: @escaping (Data?, Error?) -> Void)Parameters
namedresource name. Optional in case of downloading the default resource.
versionversion of the resource. Giving the version w/o named parameter isn’t possible. If the version is not filled, the maximum version will be download.
completionHandlerThe completion handler that gets invoked at the end of the download process with the received data or error in case of failure.
-
Downloads client resources from SAPcpms into file. Recommended for downloading larger resources.
Declaration
Swift
open func downloadResource(named: String? = nil, version: String? = nil, toFile: URL, canOverwrite: Bool = true, completionHandler: @escaping (Error?) -> Void)Parameters
namedresource name. Optional in case of downloading the default resource.
versionversion of the resource. Giving the version w/o named parameter isn’t possible. If the version is not filled, the maximum version will be download.
toFilethe file will be written into this URL of file. The given filepath should not contain a file.
canOverwriteif the toFile parameter already exist and this parameter true, the file will be overwritten
completionHandlerThe completion handler that gets invoked at the end of the download process with the received data or error in case of failure.
-
Lists the resources from SAPcpms
Declaration
Swift
open func fetchResourceInfo(completionHandler: @escaping ([ResourceInfo]?, Error?) -> Void)Parameters
completionHandlerThe completion handler that gets invoked at the end of the download process with the array of the resources in sruct of
SAPcpmsClientResourceInfoor error in case of failure.