Skip to content

Latest commit

 

History

History
111 lines (78 loc) · 3.27 KB

File metadata and controls

111 lines (78 loc) · 3.27 KB

#API Object: OWF.Preferences.deleteUserPreference(cfg)#

#####Definition: Use the /deleteUserPreference API to remove a user preference based on its namespace and name. The preference could be user metadata such as name, email, etc.

#####How it works:##### A system makes a call to another system that asks to reference data instead of return it. To make this call, one of the following REST Calls will request user data from the user profile URI [IS THIS RIGHT?]

#####Request URL:#####

https://localhost:8443/marketplace/api/prefs/preference/com.company.widget/First%20President

#####Request Method:##### POST, Form_Method:Delete

#####Requirements:##### The call must include namespace and name

  • If namespace or name are null, it will change the null to 'undefined' and search for a namespace and/or name that is called 'undefined'.

  • If name is “” (empty but not null). It will not throw an error but will also not delete anything.

  • If namespace is “” (empty but not null) it will throw an error since the url will be “prefs/preference//name” and that is not a valid url.

#####Response:#####

If the system could not find a matching preference and there was not an error it returns:

{“success”:true, “preference”:null}

If a preference was deleted the system returns:
{"id":7,"namespace":”com.company.widget”,"path":"First President","value":"foo val","user":{"userId":"testUser1"}}

#####How to use it:##### Use it to delete user preferences.


###Example###

The following is an example of a call to delete user preference:

function onSuccess(pref){
	alert(pref.value);
}

function onFailure(error,status){
	alert('Error ' + error);
	alert(status);
}


var cfg = {
    namespace: 'com.company.widget',
    name: 'First President',
    onSuccess: onSuccess,
    onFailure: onFailure
};


OWF.Preferences.deleteUserPreference(cfg);

###Resource Information###

Parameter Description
{Object} cfg Use the following properties to configure the object.
{String} cfg.namespace The namespace of the user preference.
{String} cfg.name The name of the user preference.
{Function} cfg.onSuccess The function that will be called if the user preference is successfully deleted from the database.
{Function} cfg.onFailure Optional The system returns this function if the user preference cannot be deleted from the database or if the preference does not exist. If this function is not specified a default error message display.
This function passes back the following parameters:
error: String
Status: The HTTP Status code

###Possible Errors###

Error Action
HTTP Status 403: Access to the specified resource () has been forbidden” when namespace is blank. Enter a preference name in the namespace.