FieloPLT.BadgeService Class includes two methods.
Obtain Badges (getBadgesMap)
static List<FieloPLT.BadgeService.BadgeWrapper> FieloPLT.BadgeService.getBadgesMap (Set<String> fieldsBadge, Set<String> fieldsBadgeMember, Set<String> fieldsRule, Set<String> fieldsChallengeReward, Set<Id> badgesIds, Id memberId, Boolean filterBySegments, String orderBy, Integer quantity, Integer offset, String dynamicFilter)
It allows obtaining a Badge map for a specific Member. It also enables you to identify which Badges Members have already obtained (either with Active or Expired status), those they can get (Achievable) and the ones they can't obtain (Lost or Not applicable).
Badges statusesBadges may have any of the following statuses when linked to a specific Member:
- Active: Member has at least a Badge either without expiration date or whose expiration date is equal or greater than today.
- Expired: Member has at least a Badge which has already expired.
- Achievable: Member may obtain a Badge as they share same Segment and Program, and the Incentive (either a Promotion or Challenge) granting the Badge is Active.
- Lost: Member can't obtain the Badge as the Incentive (either a Promotion or Challenge) granting the Badge is Inactive.
- Not Applicable: Members can't obtain the Badge as they do not share the same Segment.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsBadge | Set<String> | Set of API Names from Badge fields to return in the response. |
| fieldsBadgeMember | Set<String> | Set of API Names from Badge Member fields to return in the response. |
| fieldsRule | Set<String> | Set of API Names from Rules fields to return in the response. |
| fieldsChallengeReward | Set<String> | Set of API Names from Challenge Reward fields to return in the response. |
| badgesIds | Set<Id> | Set of Badges IDs. |
| memberId | Id | Member ID. |
| filterBySegments | Boolean | It returns the Badges 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. |
Return Value
| Type | Description |
|---|---|
List<FieloPLT.BadgeService.BadgeWrapper> | List of Badge Wrappers. |
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Active","operator":"eq","andOrOperator":""}]'
List<FieloPLT.BadgeService.BadgeWrapper> result = FieloPLT.BadgeService.getBadgesMap(
new Set<String>{'Id','Name'},
new Set<String>{'Id'},
new Set<String>{'Id','Name'},
new Set<String>{'Id'},
null,
memberId,
true,
'CreatedDate ASC',
100,
0,
dynamicFilter);Expire Badges (setBadgeMemberExpirationDate)
static String FieloPLT.BadgeService.setBadgeMemberExpirationDate (Set<Id> memberIds)
It enables you to select all Badges from specific Members (represented in the object Badge Members). For Badges which have not expired yet, Badge Member Expiration is set on the date when the method is called (System Date).
Parameters
| Parameter | Type | Description |
|---|---|---|
| memberIds | Set<Id> | Set of Member IDs to expire their Badges. |
Return Value
| Type | Description |
|---|---|
| String | Badges are expired successfully. |
Exceptions
| Type | Description |
|---|---|
| FieloException | When Member ID is either invalid or empty. |
Set<Id> memberIds = new Set<Id>();
for(FieloPLT__Member__c m : [Select Id from FieloPLT__Member__c]){
memberIds.add(m.Id);
}
String result = FieloPLT.BadgesService.setBadgeMemberExpirationDate(memberIds);