Initialize Save For Later
Create a new list of type 'save for later' for a user.
swat.SaveForLater Init
The swat object contains all Save for Later API under the "SaveForLater" object. This is a special object that is separate from lists API, powering the Save for later metrics and actions.
Before you call other APIs such as add, remove, update. you must first Initialise a Save for Later list.
This will provide you with the specific lid
for a type of sfl
which will be used in subsequent api calls.
This API should be called first before all other Save for Later API.
Definition
swat.SaveForLater.init(onSuccess, onError)
Example
(function() {
// Execute inside a swym callback functio
function initializeSaveForLater(swat) {
let onSuccess = function(response) {
// WARN Remove logs in production code
console.log("Successfully Initialized, And we created a Save for Later List", response);
// Store the SFL list ID in the window object for global access.
window._saveforLaterListId = response.list.lid;
}
let onError = function(error) {
// Error is an xhrObject
// WARN Remove logs in production code
console.log("There was an Error, while creating the Save For Later List", error);
}
// Call the Init function.
swat.SaveForLater.init(onSuccess, onError);
}
window.SwymCallbacks = window.SwymCallbacks || [];
window.SwymCallbacks.push(initializeSaveForLater);
})();
API Parameters
Argument | Type | Description |
---|---|---|
onSuccess | function | Called when the Save for Later List is successfully created. |
onError | function | Called when there is an error while creating the Save for Later List. |
Response
{
"list": {
"di": "fb283019-487b-4447-99e6-133178f6477e",
"lty": "sfl",
"uid": "/sOYTTOc0WqrpkhmWttqouvi3wygUngPfiHU=",
"cts": 1679667114911,
"lnote": null,
"lname": "My SFL List",
"cby": "[email protected]",
"lid": "7f69f914-d413-48dc-b449-77e9c3ff08e8",
"pid": "/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"st": 1,
"cprops": {},
"id": "ba3b87ac-715e-4b9c-bb87-ac715efb9cb0",
"uts": 1679667114911,
"ldesc": {},
"uby": null,
"cfor": null
},
"userinfo": {
"fname": "Support",
"uid": "/sOYTTOc0WqrpkhmWttqouvi3wygUngPfiHU=",
"m": null,
"em": "[email protected]",
"cts": 1652286963869,
"lname": "Example",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"uts": 1674475641105
}
}
Updated 7 months ago