HomeGuidesDeveloper HubRelease Notes
Get supportBook a chat
Developer Hub
These docs are for v2.96. Click to read the latest docs for v2.208.

FieloPLT.RewardService Class

The FieloPLT.RewardService class includes one method.

Get Rewards (getRewards)

static List<FieloPLT__Reward__c> FieloPLT.RewardService.getRewards (Set<String> fields, Id memberId, Integer quantity, Integer offset, String orderBy, String whereCondition)

Returns information about a specific number of Rewards from a particular Member. It includes an optional parameter - whereCondition - which allows for criteria-based filtering of Rewards (e.g. You want only Rewards that cost 100 Points or more and are available to use as Instant Rewards).

Parameters

ParameterTypeDescription
fieldsSet<String>The API names of the Reward fields you want to be included in the response.
memberIdIdID of a specific Member.
quantityIntegerMaximum number of items to be retrieved.
offsetIntegerNumber of records from the collection to skip.
orderByStringThe order, by field name then ASC or DESC, in which you want results to be returned. (e.g. 'CreatedDate DESC, FieloPLT__Points__c ASC')
whereConditionString[Optional] WHERE condition(s) in JSON form to filter your results. If no conditions are required, pass null.

whereCondition Formatting

If applying a WHERE condition, you must pass it to the method as a JSON string.

For instance, the SOQL fragment WHERE FieloPLT__UniqueVoucher__c = false OR FieloPLT__UniqueVoucher__c = true AND FieloPLT__Segment__c IN FieloPLT__IsActive__c can be expressed as follows:

[
  {
    "andOrOperator": "",
    "field": "FieloPLT__UniqueVoucher__c",
    "operator": "=",
    "value": "false",
    "subQueryFilter": null
  },
  {
    "andOrOperator": "or",
    "field": "FieloPLT__UniqueVoucher__c",
    "operator": "=",
    "value": "true",
    "subQueryFilter":
    {
      "field": "FieloPLT__IsActive__c",
      "objectName": "FieloPLT__Segment__c",
      "filters":
      [
        {
          "andOrOperator": "and",
          "field": "FieloPLT__Segment__c",
          "operator": "in",
          "value": "FieloPLT__IsActive__c",
          "subQueryFilter": null
        }
      ]
    }
  }
]

Each JSON object represents an expression.

For the "andOrOperator" key, use an empty string ("") for the first expression. Use "and" or "or" in subsequent expressions to indicate the relation with the previous expression. If your WHERE condition will only contain one expression, set "andOrOperator" to null.

For "field", enter the API name of the field being used in the expression.

For "operator", specify how you want to compare "field" with "value". Use can choose from "=", "!=", "<", "<=", ">", ">=", "in", "not in" and "like".

For "value", enter the value you want to compare "field" with, which could be "true" or "false", a numerical value, or even the API name of another field.

For simple queries, you can set "subQueryFilter" to null. If using subqueries, the object should specify the "field" to be compared and, for "objectName", the API name of its related object. The subquery "filters" have the same structure as simple queries.

Return Values

TypeDescription
List<Fielo__Reward__c>List of Rewards.
🚧

Note that Rewards are automatically filtered by the Member's applied Segments. Additionally, only non-expired Rewards will be returned by this method.

Exceptions

TypeDescription
ExceptionWhen whereCondition is invalid.
Set<String> fields = new Set<String>{'Name','FieloPLT__Description__c'};
Id IdMemberToQuery = 'a0Of000000A29BNEAZ';

//Get up to 100 unexpired rewards
List<FieloPLT__Reward__c> rewards1 = FieloPLT.RewardData.getRewards(fields, IdMemberToQuery, 100, 0, 'Name ASC, CreatedDate DESC', null);

//Get up to 50 unexpired rewards with a Point cost of 100 or more that are available for use as Instant Rewards
String whereCondition = '[{"andOrOperator":"","field":"FieloPLT__Points__c","operator":">=","value":"100","subQueryFilter":null},{"andOrOperator":"and","field":"FieloPLT__IsInstantReward__c","operator":"=","value":"true","subQueryFilter":null}]';
List<FieloPLT__Reward__c> rewards2 = FieloPLT.RewardService.getRewards(fields, IdMemberToQuery, 50, 0, 'Name ASC, CreatedDate DESC', whereCondition);