getUserPointsHistory
Get the points history of a connected user.
Description
Get the points history of a connected user. You can filter these points.
Parameters
Parameter | Values | Description | Required |
---|---|---|---|
type | 'positive' 'negative' | Filter the type of points (positive for credit, negative for debit) | optional |
before | string (cursor) | Pagination: points before the cursor | optional |
after | string (cursor) | Pagination: points after the cursor | optional |
Response
Returns a Promise
containing an object
with the 50 last operations on the user points history, grouped by month. Example:
{
count_element: 50,
elements: {
'Avril 2023': [
{
reason: {
interaction_id: '{{id}}',
interaction_type: 'sending',
message: 'Congrats ! You earned points',
},
card_code: '{{cardCode}}',
event_date: '2023-04-28 15:47:28',
points_type: 'non-qualifying',
program_name: '{{programName}}',
status: 'pending',
tier_name: 'Bronze',
validity_end: '2023-06-28 15:47:12',
validity_start: '2023-04-29 15:47:12',
value_date: '2023-04-28 15:47:12',
id: 12345,
points_credited: 0,
points_earned: 12,
points_remaining: 0,
},
// 49 more objects
],
},
paging: {
cursors: {
after: 'WzQ2MDAyNDcyXQ==',
before: 'QwZ3dsYnvEIXuy=',
},
next: '{{baseUrl}}/{{cardCode}}?limit=50&after=WzQ2MDAyNDcyXQ==&sorting_by=ID',
previous:
'{{baseUrl}}/{{cardCode}}?limit=50&before=QwZ3dsYnvEIXuy=&sorting_by=ID',
},
};
The
before
andafter
cursors in thePromise
response could be used as parameters for your next call to this method to get previous or next history page.
This method response could be different if your Loyalty SDK is set to another language. Here,
'Avril 2023'
would be'April 2023'
.
Code example
splioSDK.getUserPointsHistory({type: 'positive'}).then((pointsHistory) => {
console.log("Points earned in 'Avril 2023'", pointsHistory.elements['Avril 2023']);
console.log('Cursor for next page', pointsHistory.paging.cursors.after);
});
Updated over 1 year ago