Generally used for the Rewards Catalog component, the FieloPLT.PointTypeAPI Class includes one method.
Create Redemptions (createRedemptions)
RedemptionResultWrapper FieloPLT.RedemptionAPI.createRedemptions(List<RedemptionWrapper> wrappers)
This method creates several redemptions for more than one member, so that you are able to create them at once. Use createRedemptions to allow members to exchange the currencies that they have received through Incentives for the prizes that you have in your program's catalog.
Take a look at a step by step guide on how to use this method.
Parameters
Check an example of how the API can be used below and a definition of its parameters right after:
List<RedemptionAPI.RedemptionWrapper> wrappers = new List<RedemptionAPI.RedemptionWrapper>();
List<FieloPLT__Member__c> members = [SELECT Id FROM FieloPLT__Member__c LIMIT 2];
FieloPLT__Reward__c reward = [SELECT Id FROM FieloPLT__Reward__c Limit 1];
RedemptionAPI.RedemptionWrapper wrapper1 = new RedemptionAPI.RedemptionWrapper();
wrapper1.fieldsMap.put('Redemption__c', new Map<String,Object>());
wrapper1.fieldsMap.get('Redemption__c').put('Description__c','Test1');
wrapper1.rewardsQuantity.put(reward.Id, 3);
wrapper1.memberId = members.get(0).Id;
wrappers.add(wrapper1);
RedemptionAPI.RedemptionWrapper wrapper2 = new RedemptionAPI.RedemptionWrapper();
wrapper2.fieldsMap.put('Redemption__c', new Map<String,Object>());
wrapper2.fieldsMap.get('Redemption__c').put('Description__c','Test2');
wrapper2.rewardsQuantity.put(reward.Id, 1);
wrapper2.memberId = members.get(1).Id;
wrappers.add(wrapper2);
RedemptionAPI.createRedemptions(wrappers);| Parameter | Type | Description | Required |
|---|---|---|---|
| wrappers | List<RedemptionWrapper> | List of the rewards that are going to be redeemed per member. | Yes |
Wrapper's Parameters
Within the wrapper, use RedemptionWrapper: {Map<String, Map<String,Object>> fieldsMap, Map<Id, Integer> rewardsQuantity, Id memberId}
| Parameter | Type | Description | Required |
|---|---|---|---|
| fieldsMap | Map<String, Map<String, Object>> | Specifies the fields from the Redemption and Redemption Item Objects that are going to be filled in with the value defined in the Map. | No |
| rewardsQuantity | Map<Id, Integer> | Defines the quantity of the same reward that is going to be redeemed and its ID. | No |
| memberId | Id | ID from a specific member. | Yes |
Return
This method returns the wrapper RedemptionResultWrapper: {Boolean hasErrors, Map<Integer,Redemption__c> successMap, Map<Integer,String> errorsMap} with a map of the redemptions that were successful and another map with the ones that weren't.
If the redemption is successful, the return will contain the redemption(s) index number (an Integer) and the redemption created. If an error occurs, the wrapper will identify the redemption at fault by their position (its index) and describe the error message.
Take a look below at an example of what is returned in the call:
RedemptionAPI.RedemptionResultWrapper
{"successMap":{"1":{"attributes":{"type":"FieloPLT__Redemption__c","url":"/services/data/v51.0/sobjects/FieloPLT__Redemption__c/a0v1k000000lPkoAAE"},"FieloPLT__Description__c":"Test2","FieloPLT__Member__c":"a0d1k000001GpTWAA0","Id":"a0v1k000000lPkoAAE","FieloPLT__Status__c":"Closed"},"0":{"attributes":{"type":"FieloPLT__Redemption__c","url":"/services/data/v51.0/sobjects/FieloPLT__Redemption__c/a0v1k000000lPknAAE"},"FieloPLT__Description__c":"Test1","FieloPLT__Member__c":"a0d1k000001GpL7AAK","Id":"a0v1k000000lPknAAE","FieloPLT__Status__c":"Closed"}},"hasErrors":false,"errorsMap":{}}Exception
Errors can occur when you use the endpoint. See below the exception that you can receive when using the RedemptionAPI:
| Type | Description |
|---|---|
| FieloApiException |
|
| FieloApiException | Exceeded quantity |
| FieloApiException |
|
