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
sapURLSession
an SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
clientResourcesURL
the full URL of the client resources
-
Default initializer for using SAPcpmsSettingsParameters as an input
Declaration
Swift
public convenience 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
-
Downloads client resources from SAPcpms
Declaration
Swift
open func downloadResource(named: String? = nil, version: String? = nil, completionHandler: @escaping (Data?, Error?) -> Void)
Parameters
named
resource name. Optional in case of downloading the default resource.
version
version 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.
completionHandler
The 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
named
resource name. Optional in case of downloading the default resource.
version
version 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.
toFile
the file will be written into this URL of file. The given filepath should not contain a file.
canOverwrite
if the toFile parameter already exist and this parameter true, the file will be overwritten
completionHandler
The 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
completionHandler
The completion handler that gets invoked at the end of the download process with the array of the resources in sruct of
SAPcpmsClientResourceInfo
or error in case of failure.