CLASS

HaapiFlowViewModel

Contents

swift
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:)

swift
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:)

swift
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

swift
deinit

start()

swift
public func start()

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

submit(form:parameters:)

swift
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(_:)

swift
public func followLink(_ link: Link)

Follows a link to an alternative HAAPI flow.

Parameters

Name Description
link The link to be followed.

fetchAccessToken(authorizationCode:)

swift
public func fetchAccessToken(authorizationCode: String)

Fetches an access token using an authorization code grant.

Parameters

Name Description
authorizationCode The authorization code.

refreshAccessToken(refreshToken:)

swift
public func refreshAccessToken(refreshToken: String)

Refreshes an access token.

Parameters

Name Description
refreshToken The refresh token.