Newer Version Available

This content describes an older version of this product. View Latest

APIManager

The APIManager class manages requests related to gamification, and invokes the gamification REST APIs. Use this class to interact with the Salesforce gamification APIs and retrieve member games, and game rewards.

The Gamification Mobile iOS SDK requires a valid access token to interact with the Salesforce gamification APIs. To provide a valid access token, pass an instance of GamificationForceAuthenticator protocol in your APIManager class at the time of initialization. The APIManager class manages authentication using the provided instance of GamificationForceAuthenticator.

Use this initializer to initialize the GamificationRemoteRepository class.

1public init(auth: GamificationForceAuthenticator, instanceURL: String, forceClient: GamificationForceClient) {
2        self.auth = auth
3        self.instanceURL = instanceURL
4        self.forceClient = forceClient
5    }
Parameter Type Description
auth GamificationForceAuthenticator An instance of the GamificationForceAuthenticator protocol.
instanceUrl String The URL of your Salesforce org.
forceClient GamificationForceClient An instance of the GamificationForceClient class.

Methods

getGames

Retrieve games for the specified participant ID. This method returns an instance of the GameModel object.

1public func getGames(
2           participantId: String,
3           version: String = APIVersion.defaultVersion,
4           devMode: Bool = false,
5           mockFileName: String = "GetGames_Success"
6       ) async throws -> GameModel
Parameter Type Description
participantId String The ID of a loyalty program member, an account, or a contact whose eligible games are to be retrieved.
version String The API version.
mockFileName String The name of the file that has the sample response.
devMode Boolean Indicates whether the method is run in the developer mode (true) or not (false).

getGameReward

Retrieve the details of the reward that’s provided to a participant after the game play. This method returns an instance of the PlayGameModel object.

1public func playGame(
2           gameParticipantRewardId: String,
3           version: String = APIVersion.defaultVersion,
4           devMode: Bool = false,
5           mockFileName: String = "PlayGame_Success"
6       ) async throws -> PlayGameModel
Parameter Type Description
gameParticipantRewardId String The ID of the participant's game reward won by the participant whose details are to be fetched.
version String The API version.
mockFileName String The name of the file that has the sample response.
devMode Boolean Indicates whether the method is run in the developer mode (true) or not (false).