The FieloPLT.RedemptionService class includes three methods.
Obtain Redemptions (getRedemptions)
static List<FieloPLT__Redemption__c> FieloPLT.RedemptionService.getRedemptions (Set<String> fieldsRedemptions, Set<String> fieldsRedemptionItem, Set<Id> redemptionIds, Id memberId, String orderBy, Integer quantity, Integer offset, String dynamicFilter)
Returns information about a specific number of Redemptions, which can also be from a particular Member. It also allows filtering Redemptions based on specific information you need to obtain. E.g. You need to get Redemptions from a specific Program.
Parameters
| Parameter | Type | Description |
|---|---|---|
| fieldsRedemptions | Set<String> | Set of API names of Redemption fields to return in the response. When null or empty, default value is Set<String>{'id','name'}. |
| fieldsRedemptionItem | Set<String> | Set of API names from Redemption Items fields to return in the response. When NULL or empty, no Redemption Items are returned. |
| redemptionIds | Set<Id> | Set of Redemption IDs. |
| memberId | Id | ID of a specific Member. |
| quantity | Integer | Number of items to be retrieved. |
| offset | Integer | Number of records from a collection to skip. |
| 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__Redemption__c> | A list of Redemptions. |
FieloPLT__Member__c member = [SELECT Id FROM FieloPLT__Member__c];
FieloPLT.RedemptionService.getRedemptions(new Set<String>{'Name','FieloPLT__Status__c'},new Set<String>{'Name','FieloPLT__Status__c'},null,member.Id,null,10,0,'');Create Redemptions (createRedemptions)
static List<FieloPLT__Redemption__c> FieloPLT.RedemptionService.createRedemptions (Map <Id, Integer> quantityPerReward, Id memberId)
It creates and closes a Redemption for a specific Member. It also lets adding more Redemption Items to the Redemption as well.
Parameters
| Parameter | Type | Description |
|---|---|---|
| quantityPerReward | Map<Id, Integer> | ID of a Reward and its quantity. |
| memberId | Id | ID of a specific Member. |
Return Values
| Type | Description |
|---|---|
| List<FieloPLT__Redemption__c> | A list of Redemptions. |
Redemption ListA Redemption list is generated for each different provider as specified in Rewards.
Exceptions
| Type | Description |
|---|---|
| FieloCustomException | Neither the Redemption nor its Redemption Items can be created. |
FieloPLT__Member__c member = [SELECT Id FROM FieloPLT__Member__c LIMIT 1];
FieloPLT__Reward__c rewards = [SELECT Id from FieloPLT__Reward__c];
Map<Id, Integer> quantityPerReward = new Map<Id, Integer> quantityPerReward();
quantityPerReward.put(rewards.get(0).Id, 2);
List<FieloPLT__Redemption__c> redemptions;
try{
redemptions = FieloPLT.RedemptionService.createRedemptions(quantityPerReward, member.Id);
}catch(FieloCustomException e){
ApexPages.addMessage(new ApexPages.Message(severity.ERROR, e.getMessage()));
}Create Provider Order (createProviderOrder)
static FieloPLT__ProviderOrder__c FieloPLT.RedemptionService.createProviderOrder (Id memberId, FieloPLT__ProviderOrder__c providerOrder, List<FieloPLT__RedemptionItem__c> redemptionItems)
It creates a Redemption and a Provider Order for a specific Member when Rewards are not part of Platform (i.e. Internal Reward Catalog) or Salesforce. It also lets you add Redemption Items linked to both the Redemption and the Provider Order.
Redemption statusRedemption status is updated to either Pending or Closed.
Parameters
| Parameter | Type | Description |
|---|---|---|
| memberId | Id | ID of a specific Member. |
| providerOrder | FieloPLT__ProviderOrder__c | A created Provider Order. |
| redemptionItems | List<FieloPLT\_\_RedemptionItem\_\_c> | A list of Redemption Items. |
Return Values
| Type | Description |
|---|---|
| FieloPLT__ProviderOrder__c | It returns a single Provider Order record. |
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
Id accountId = [SELECT Id FROM Account LIMIT 1].Id;
FieloPLT__ProviderOrder__c providerOrder = new FieloPLT__ProviderOrder__c(
FieloPLT__Account__c = accountId
//Add more Provider Order fields
);
List<FieloPLT__RedemptionItem__c> redemptionItems = new List<FieloPLT__RedemptionItem__c>();
redemptionItems.add(new FieloPLT__RedemptionItem__c(
FieloPLT__Quantity__c = 1,
FieloPLT__Points__c = 100
//Add more Redemption item fields
)
);
//Add more Redemption Items records
providerOrder = FieloPLT.RedemptionService.createProviderOrder(memberId, providerOrder, redemptionItems);