CLASS

HaapiFlowViewModel

Contents

public final class HaapiFlowViewModel: NSObject, ObservableObject

An HaapiFlowViewModel is responsible for storing state and managing interactions with the server during the HaapiFlow execution.

Methods

init(haapiUIKitApplication:)

public convenience init(haapiUIKitApplication: HaapiUIKitApplication) throws

Creates an instance of HaapiFlowViewModel based on the provided parameters: HaapiUIKitApplication.

Parameters

Name Description
haapiUIKitApplication The HaapiUIKitApplication configuration.

init(haapiUIKitConfiguration:dataMapper:)

public init(haapiUIKitConfiguration: HaapiUIKitConfiguration,
            dataMapper: DataMapper) throws

Creates an instance of HaapiFlowViewModel based on the provided parameters: HaapiUIKitConfiguration and DataMapper.

Parameters

Name Description
haapiUIKitConfiguration The HaapiUIKit configuration.
dataMapper The data mapper to map Haapi SDK object to Haapi UIKit object.

deinit

deinit

start()

public func start()

Prepares and starts the execution of an HAAPI flow interaction with the server.

submit(form:parameters:)

public func submit(form: FormActionModel, parameters: [String: Any])

Submits a form action model to move forward in the HAAPI flow. The parameters supplied to this method override the field values present in the form. If the parameters do not include a value for a given form field name, the original value in the form is used.

Parameters

Name Description
form A form action model to be submitted.
parameters The parameters that are sent along with the form. Keys should match the corresponding form field names otherwise they will be discarded.

followLink(_:)

public func followLink(_ link: Link)

Follows a link to an alternative HAAPI flow.

Parameters

Name Description
link The link to be followed.

fetchAccessToken(authorizationCode:additionalParameters:)

public func fetchAccessToken(authorizationCode: String, additionalParameters: [String: String]? = nil)

Fetches an access token using an authorization code grant.

Parameters

Name Description
authorizationCode The authorization code.
additionalParameters The additional parameters for the request body. The default value is nil.

refreshAccessToken(refreshToken:additionalParameters:)

public func refreshAccessToken(refreshToken: String, additionalParameters: [String: String]? = nil)

Refreshes an access token.

Parameters

Name Description
refreshToken The refresh token.
additionalParameters The additional parameters for the request body. The default value is nil.