FieloPLT.ChallengeService class includes one method.
Obtain Challenges (getChallengesMap)
static List<FieloPLT.ChallengeService.ChallengeWrapper> FieloPLT.ChallengeService.getChallengesMap (Set<String> fieldsChallenge, Set<String> fieldsMission, Set<String> fieldsChReward, Set<String> fieldsMissionMember, Set<String> fieldsChMember, Set<String> fieldsTransaction, Set<Id> challengeIds, Id memberId, String status, Boolean filterBySegments, String orderBy, Integer quantity, Integer offset, String dynamicFilter, String translate)
It allows you to retrieve information about a number of Challenges map from a particular Member. It can also provide details about the Missions, Challenge Rewards, Challenge Members, Mission Members and Transactions linked to a Challenge.
Members are considered subscribed to a Challenge when Members and Challenge share the same Segment and Subscription Mode is Global. When Subscription Mode is Closed, Members are considered subscribed by means of a Challenge Member record.
Challenges StatusChallenges may have any of the following Status when linked to a specific member:
Active: It returns all Active challenges which the member is participating in (challegeMember exists and challengeMember status is not accomplished) and also the ones which the member belong to the segmentation and the subscription is global.
Completed: Returns all Challenges completed by the member, which has challengeMember status equals to ‘Accomplish’,or all finished challenges, which has Challenge status equals to ‘Completed.
Open: Returns all Challenges which members can subscribe to, as they belong to its segmentation. Challenge returned are Active and its subscription is either private or open (Opt-In).
Lost: Returns all Challenges which the member could have had enrolled, meaning that the member belongs to the segmentation but there is not challengeMember, but it is over, so Challenge Status is equals to completed
Not Applicable: Returns all Active challenges that the member cannot participate, as they don’t share the member's segmentation. The challenges the member has participated in already but do not belong to the segment anymore will be excluded from the returned challenges.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsChallenge | Set<String> | Set of API Names from Challenge fields to return in the response. |
| fieldsMission | Set<String> | Set of API Names from Mission fields to return in the response. If there are no fields, an empty list will be returned. |
| fieldsChReward | Set<String> | Set of API Names from Challenge Reward fields to return in the response. |
| fieldsMissionMember | Set<String> | Set of API Names from Mission Member fields to return in the response. |
| fieldsChMember | Set<String> | Set of API Names from Challenge Member fields to return in the response. |
| fieldsTransaction | Set<String> | Set of API Names from Transaction fields to return in the response. |
| challengeIds | Set<Id> | Set of Challenge IDs. |
| memberId | Id | ID of a specific Member. |
| status | String | Challenge status to filter values in the response (Values may be: Active, Completed, Open, Lost and Not Applicable). |
| filterBySegments | Boolean | It returns the Challenges that belong to Member's Segment. |
| quantity | Integer | Number of items to be retrieved. When NULL, query return all items. |
| offset | Integer | Number of records from a collection to skip. When null, no records are skipped. |
| orderBy | String | Records returned in an ascending or descending order. |
| dynamicFilter | String | JSON parameter to filter by an additional WHERE Clause. When null, no filter is applied. |
| translate | Boolean | If this parameter is set to true, it fetches the available translation and changes the language of the component according to the member’s Salesforce user language, while if false, it’ll return the components in the default language. |
Return Value
| Type | Description |
|---|---|
| List<FieloPLT.ChallengeService.ChallengeWrapper> | List of Challenge Wrappers. Challenge Wrappers include the following attributes: |
Class FieloPLT.ChallengeWrapper{
FieloPLT__Challenge__c challenge;
String status;
FieloPLT__ChallengeMember__c challengeMember;
List<FieloPLT__Mission__c> missions;
List<FieloPLT__ChallengeReward__c> challengeRewards;
Map<Id,List<FieloPLT__ChallengeReward__c>> missionRewards;
Map<Id,FieloPLT__MissionMember__c> missionsMember;
List<FieloPLT__Transaction__c> transactions;
}Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Active","operator":"eq","andOrOperator":""}]';
List<FieloPLT.ChallengeService.ChallengeWrapper> result = FieloPLT.ChallengeService.getChallengesMap(
new Set<String>{'Name'},
new Set<String>{'Name'},
new Set<String>{'Name'},
null,
null,
null,
null,
memberId,
null,
true,
'CreatedDate ASC',
100,
0,
dynamicFilter);Obtain Mission Leaderboard (getMissionLeaderboard)
static List<FieloPLT__MissionMember__c> getMissionLeaderboard (Set<String> fieldsMissionMember, Id missionId, Id memberId, String orderBy, Integer quantity, Integer offset, String dynamicFilter)
It enables you to retrieve information about Member rankings in a Leaderboard of a specific Mission, which is stored in Mission Member records. You can also obtain information about how a particular Member has performed on the Leaderboard.
| Parameter | Type | Description |
|---|---|---|
| fieldsMissionMember | Set<String> | Set of API Names from Mission Member fields to return in the response. |
| challengeIds | Set<Id> | Set of Challenge IDs. |
| memberId | Id | ID of a specific Member. |
| quantity | Integer | Number of items to be retrieved. When NULL, query return all items. |
| offset | Integer | Number of records from a collection to skip. When null, no records are skipped. |
| orderBy | String | Records returned in an ascending or descending order. |
| dynamicFilter | String | JSON parameter to filter by an additional WHERE Clause. When NULL, no filter is applied. |
Return Value
Challenge Leaderboard BatchYou must run Challenge Leaderboard batch job before calling Obtain Mission Leaderboard method.
| Type | Description |
|---|---|
| List<FieloPLTMissionMemberc> | List of Mission Members. If the Challenge Leaderboard batch job is not run, it returns value is either NULL or empty. |
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
Id missionId = [SELECT Id FROM FieloPLT__Mission__c LIMIT 1].Id;
String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Accomplished","operator":"eq","andOrOperator":""}]';
List<FieloPLT__MissionMember__c> FieloPLT.ChallengeService.getMissionLeaderboard(new Set<String>{'Name'},
missionId,
memberId,
'CreatedDate ASC',
100,
0,
dynamicFilter);