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> fieldsRank, Set<String> fieldsChReward, Set<String> fieldsMissionMember, Set<String> fieldsChMember, Set<String> fieldsTransaction, Set<Id> challengeIds, Id memberId, String setName, String orderBy, String orderByMemberActivity, Integer quantity, Integer offset, String dynamicFilter, Boolean 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 setNameThis parameter displays a set of challenges according to the set name:
MyChallenges: It returns all the challenges which the member is participating in (exists challangeMember, challengeMember status can be any).
Apply: It returns all challenges which the member can participate in (doesn’t exist ChallegeMember), meaning they are not subscribed yet and the member doesn't belong to the challenge segmentation. The challenge status can be either Active or Scheduled and the subscription must be either Open or Global.
Not Apply: It returns all challenges where the member cannot participate (doesn’t exist ChallengeMember), meaning they are not subscribed yet but belong to the challenge segmentation. The challenge status can be either Active or Scheduled and the subscription must be either Open or Global.
All Available: The aggregation of Apply and Not Apply. It returns all the challenges which the member can and cannot participate (doesn’t exist ChallengeMember) regardless of segmentation.
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.
Open: It returns all the Active challenges which the member can participate in, meaning they belong to the challenge segmentation, with subscription mode either Private or Open (Opt-in).
Completed: It returns both challenges completed by the member, which the challengeMember status is equals to Accomplished, or finished challenges, which Challenge status is equals to Completed.
Lost: It returns all challenges which the member could have participated in, as they belonged to the challenge’s segment, but they didn’t, meaning ChallengeMember doesn’t exist, and now the challenge Status is equals to completed.
Not Applicable: It returns all active challenges which the member cannot participate in, as the member doesn't belong to the challenge’s segment.
Apply by Segmentation: It returns all Challenges that share the Member's Segmentation listed.
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. |
| fieldsRank | Set<String> | Returns each Challenge’s rank. If inactive, nothing 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. |
| setName | String | Challenge status to filter values in the response (Values may be: MyChallenges, Apply, Not Apply, All Available, Active, Open, Completed, Lost , Not Applicable and Apply by Segmentation). |
| 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. |
| orderByMemberActivity | String | Records returned sorted by either the member's most recent activities or the oldest ones. |
| 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<FieloPLT__MissionMember__c> | 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);