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

FieloPLT.TransactionService Class

The FieloPLT.TransactionService class includes two methods.

Obtain Transactions (getTransactions)

static List<FieloPLT__Transaction__c> FieloPLT.TransactionService.getTransactions (Set<String> fieldsTransactions, Id memberId, String orderBy, Integer quantity, Integer offset, String dynamicFilter)

Returns information about a specific number of Transactions from a particular Member. It also allows Transaction filtering based on specific information you need to obtain (e.g. you need to get Transactions from a specific Program).

Parameters

ParameterTypeDescription
fieldsTransactionsSet<String>Set of API names from Transaction fields to return in the response. When null or empty, default value is Set<String>name.
memberIdIdID of a specific Member.
quantityIntegerNumber of items to be retrieved.
offsetIntegerNumber of records from a collection to skip.
orderByStringRecords returned in an ascending or descending order.
dynamicFilterStringJSON parameter to filter by an additional WHERE Clause. When null, no filter is applied.

Return Value

TypeDescription
List<FieloPLT__Transaction__c>A list of Transactions.
Set<String> fieldsTransactions = new set<String>{'Id', 'Name', 'FieloPLT__Type__c', 'FieloPLT__Points__c', 'FieloPLT__Member__r.Name'};
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
String orderBy = 'CreatedDate DESC';
Integer quantity = 10;
Integer offset = 0;
String dynamicFilter = null;

//Build dynamicFilter
Date fromDate = date.today().addMonths(-1);
Date toDate = date.today();

List<String> filters = new List<String>();
filters.add('{"field":"CreatedDate",      "operator": ">=","value":"' + (Datetime.newInstance(fromDate, Time.newInstance(00, 0, 0, 0))).format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'') + '"}');
filters.add('{"field":"CreatedDate",      "operator": "<=","value":"' + (Datetime.newInstance(toDate, Time.newInstance(23, 59, 59, 0))).format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'') + '"}');
filters.add('{"field":"FieloPLT__Type__c","operator": "=", "value":"Adjustment"}');

String dynamicFilter = '[' + String.join(filters,',') + ']';

List<FieloPLT__Transaction__c> listTransactions = FieloPLT.TransactionService.getTransactions(fieldsTransactions, memberId, orderBy, quantity, offset, dynamicFilter);

Revert Transactions (revertTransactions)

static Map<Id,String> FieloPLT.TransactionService.revertTransactions (List<Id> transactionIds)

Lets you get a list of Transaction IDs from records which have been already processed and which can be reverted. Only the specified Transactions are reverted.

Parameters

ParameterTypeDescription
recordIdsList<Id>IDs of a Transaction list to revert.

Return Value

TypeDescription
Map<Id,String>Map of errors from Record IDs. If operation is successful, value is NULL.
❗️

Records

IDs must be from the same Object.

List<Id> transactionIds = new List<Id>();
for(FieloPLT__Transaction__c transaction : [SELECT Id FROM FieloPLT__Transaction__c LIMIT 10]){
     transactionIds.add(transaction.Id);
}
Map<Id,String> resultsMap = FieloPLT.TransactionService.revertTransactions(transactionIds);
if(resultsMap != null){
    for(Id transactionId : resultsMap.keySet()){
        ApexPages.addMessage(new ApexPages.Message(severity.ERROR, resultsMap.get(transactionId)));
    }
}