Last active
November 14, 2019 22:44
-
-
Save agiguere/9838219f6b948fee67f185e21a78b037 to your computer and use it in GitHub Desktop.
SAP Fiori for iOS SDK Code Snippet: ODataOnboardingStep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SAPCommon | |
import SAPFioriFlows | |
import SAPFoundation | |
class ODataOnboardingStep: OnboardingStep { | |
var controller: OnlineODataController? | |
func onboard(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void) { | |
configureOData(using: context, completionHandler: completionHandler) | |
} | |
func restore(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void) { | |
configureOData(using: context, completionHandler: completionHandler) | |
} | |
func reset(context: OnboardingContext, completionHandler: @escaping () -> Void) { | |
completionHandler() | |
} | |
} | |
// MARK: - Private API | |
private extension ODataOnboardingStep { | |
func configureOData(using context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void) { | |
let configurationURL = context.info[.authenticationURL] as! URL | |
do { | |
let onlineOdataController = OnlineODataController() | |
try onlineOdataController.configureOData(sapURLSession: context.sapURLSession, serviceRoot: configurationURL) | |
controller = onlineOdataController | |
completionHandler(.success(context)) | |
} catch { | |
completionHandler(.failed(error)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment