pse.ServicesCreditsServiceglobal with sharing class ServicesCreditsService
This class contains methods to manage the allocation, adjustment, and expiry of services credits. Methods
manuallyAllocateCreditsForMilestonesglobal static pse.ServicesCreditsService.ManualAllocationResponse manuallyAllocateCreditsForMilestones(List<pse.ServicesCreditsService.ManualAllocationRequest> allocationRequests) Allocates available services credits to the given milestones. Input Parameters
Return ValueThis method returns an object containing a map of the milestone ID for which the process was called for to an object containing the result for that milestone. The result object contains the milestone ID and the ID of the allocation record created. Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
List<Id> milestoneIdsToAllocate = new List<Id>{'a1r000000000001AAA', 'a1r000000000002AAA'};
List<Id> purchaseIdsToConsume = new List<Id>{'a2y000000000001AAA', 'a2y000000000002AAA'};
//create a request object for each milestone, with the credits to consume from each purchase
Map<Id, Integer> creditsToConsumePerPurchaseForMilestone1 = new Map<Id, Integer>{
purchaseIdsToConsume[0] => 30,
purchaseIdsToConsume[1] => 10
};
pse.ServicesCreditsService.ManualAllocationRequest req1 = new pse.ServicesCreditsService.ManualAllocationRequest(
creditsToConsumePerPurchaseForMilestone1,
milestoneIdsToAllocate[0]
);
Map<Id, Integer> creditsToConsumePerPurchaseForMilestone2 = new Map<Id, Integer>{
purchaseIdsToConsume[1] => 20
};
pse.ServicesCreditsService.ManualAllocationRequest req2 = new pse.ServicesCreditsService.ManualAllocationRequest(
creditsToConsumePerPurchaseForMilestone2,
milestoneIdsToAllocate[1]
);
//run the manual allocation
pse.ServicesCreditsService.ManualAllocationResponse response = pse.ServicesCreditsService.manuallyAllocateCreditsForMilestones(
new List<pse.ServicesCreditsService.ManualAllocationRequest>{ req1, req2 }
);
//the results can be accessed from the response
Map<Id, pse.ServicesCreditsService.ManualAllocationResult> results = response.results;
pse.ServicesCreditsService.ManualAllocationResult result = results.get(milestoneIdsToAllocate[0]);
allocateCreditsForMilestonesglobal static pse.ServicesCreditsService.ServicesCreditsAllocationResponse allocateCreditsForMilestones(pse.ServicesCreditsService.ServicesCreditsAllocationRequest request) Allocates available services credits to the given milestones. Input Parameters
Return ValueThis method returns an object containing a List of objects representing the results. Each object is the result for one milestone, containing the milestone ID and the ID of the created allocation record. Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
//construct the request object
List<Id> milestoneIds = new List<Id>{'a1r000000000001AAA', 'a1r000000000002AAA', 'a1r000000000003AAA'};
pse.ServicesCreditsService.ServicesCreditsAllocationRequest request = new pse.ServicesCreditsService.ServicesCreditsAllocationRequest(milestoneIds);
//call the service
pse.ServicesCreditsService.ServicesCreditsAllocationResponse response = pse.ServicesCreditsService.allocateCreditsForMilestones(request);
//read the response object
pse.ServicesCreditsService.ServicesCreditsAllocationResult firstResult = response.results[0];
Id firstAllocationId = firstResult.allocationId;
adjustCreditsForMilestonesglobal static pse.ServicesCreditsService.ServicesCreditsAdjustmentResponse adjustCreditsForMilestones(pse.ServicesCreditsService.ServicesCreditsAdjustmentRequest request) Adjusts number of services credits on given milestones to the given number. Input Parameters
Return ValueThis method currently returns an empty object which is reserved for future use. Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
//construct the request object
Map<Id,Integer> milestoneIdsToNewCredits = new Map<Id,Integer>{'a1r000000000001AAA'=> 100, 'a1r000000000002AAA'=>50, 'a1r000000000003AAA'=>75};
pse.ServicesCreditsService.ServicesCreditsAdjustmentRequest request = new pse.ServicesCreditsService.ServicesCreditsAdjustmentRequest(milestoneIdsToNewCredits);
//call the service
pse.ServicesCreditsService.ServicesCreditsAdjustmentResponse response = pse.ServicesCreditsService.adjustCreditsForMilestones(request);
expireCreditsForPurchaseglobal static pse.ServicesCreditsService.ExpireCreditsForPurchaseResponse expireCreditsForPurchase(pse.ServicesCreditsService.ExpireCreditsForPurchaseRequest request) A method that expires Services Credits Customer Purchases. Partial success is allowed. Input Parameters
Return ValueExpireCreditsForPurchaseResponse Structure containing a map of Services Credits Customer Purchase Id to expiry result. Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
//construct the request object
List<Id> purchaseIds = new List<Id>{'a1r000000000001AAA', 'a1r000000000002AAA', 'a1r000000000003AAA'};
pse.ServicesCreditsService.ExpireCreditsForPurchaseRequest request = new pse.ServicesCreditsService.ExpireCreditsForPurchaseRequest(purchaseIds);
//call the service
pse.ServicesCreditsService.ExpireCreditsForPurchaseResponse response = pse.ServicesCreditsService.expireCreditsForPurchase(request);
//response if successful
pse.ServicesCreditsService.ServicesCreditsExpiryResult firstResult = response.resultsMap.get('a1r000000000001AAA');
Id firstAllocationId = firstResult.allocationId; // this will be populated
String errorMessage = firstResult.errorMessage; // this will be null
//response if there was an error
pse.ServicesCreditsService.ServicesCreditsExpiryResult secondResult = response.resultsMap.get('a1r000000000001AAA');
Id secondAllocationId = secondResult.allocationId; // this would be null
String errorMessage = secondResult.errorMessage; // this will be populated
pse.ServicesCreditsService.ServicesCreditsAllocationResultglobal with sharing class ServicesCreditsAllocationResult The result of allocation for a single milestone. Properties
pse.ServicesCreditsService.ServicesCreditsAllocationRequestglobal with sharing class ServicesCreditsAllocationRequest A structure containing the List of milestone IDs to allocate. Properties
MethodsServicesCreditsAllocationRequestglobal ServicesCreditsAllocationRequest(List<Id> milestones) pse.ServicesCreditsService.ManualAllocationResultglobal with sharing class ManualAllocationResult The result of manual allocation for a single milestone. Properties
pse.ServicesCreditsService.ManualAllocationResponseglobal with sharing class ManualAllocationResponse A structure containing the results of manuallyAllocateCreditsForMilestones Properties
pse.ServicesCreditsService.ManualAllocationRequestglobal with sharing class ManualAllocationRequest A structure containing details needed to perform manual allocation for a milestone Properties
MethodsManualAllocationRequestglobal ManualAllocationRequest(Map<Id, Integer> creditsToConsumeByPurchaseId, Id milestoneId) pse.ServicesCreditsService.ServicesCreditsAllocationResponseglobal with sharing class ServicesCreditsAllocationResponse A structure containing the results of allocateCreditsForMilestones Properties
pse.ServicesCreditsService.ServicesCreditsAdjustmentRequestglobal with sharing class ServicesCreditsAdjustmentRequest A structure containing a map of milestone IDs to the number of credits to adjust to. Properties
MethodsServicesCreditsAdjustmentRequestglobal ServicesCreditsAdjustmentRequest(Map<Id, Integer> newNumberOfCreditsByMilestoneId) pse.ServicesCreditsService.ServicesCreditsAdjustmentResponseglobal with sharing class ServicesCreditsAdjustmentResponse This is currently an empty object which is reserved for future use. pse.ServicesCreditsService.ExpireCreditsForPurchaseResponseglobal with sharing class ExpireCreditsForPurchaseResponse A structure containing the response to expiring Services Credits Customer Purchases. Properties
pse.ServicesCreditsService.ServicesCreditsExpiryResultglobal with sharing class ServicesCreditsExpiryResult The result of the expiry for an individual Services Credits Customer Purchase. Properties
Methodspse.ServicesCreditsService.ExpireCreditsForPurchaseRequestglobal with sharing class ExpireCreditsForPurchaseRequest A structure containing the request to expire Services Credits Customer Purchases. Properties
MethodsExpireCreditsForPurchaseRequestglobal ExpireCreditsForPurchaseRequest(List<Id> purchaseIds) |