-
Notifications
You must be signed in to change notification settings - Fork 8
User Profile Update
js.sevestre edited this page Oct 16, 2019
·
18 revisions
Get a list of user directory modules on an instance.
body = {
"instanceId": xxx,
"lang": "en", # adapt
"type": ["user_directory"],
"excludeType": ["community", "custom", "custom_list", "image_gallery", "menu", "news", "news_list", "page", "post"],
"action": "CUSTOM_EDIT"}
user_directories = api.get_call(
"content", "list", body=body, fields="cursor,items(template/components, uid)")
# nb: the fields parameter ask the api to return only the requested fields in the response,
# the returned content could not be used for a save.
The user_directories will be a list of user directory module.
Each user directory module has a list of custom profile fields define in template.components
and an id
use later as USER_DIRECTORY_ID.
{
"title": {
"en": "Users Directory"
},
"id": "6486401110769664",
"uid": "6486401110769664",
"instance": "6288388086038528",
"customer": "4664706704080896",
"isDefaultUserDirectory": false,
"type": "user_directory",
"status": "LIVE",
"slug": {
"en": "users-directory"
},
"template": {
"components": [
{
"uuid": "be3363f3-4df8-4a93-b27c-9c8c69258801",
"title": {
"en": "Title"
},
"type": "inputText",
"properties": {
"index": 0,
"isBound": true,
"boundMap": {
"text": "organizations[primary=true]/title",
"name": "API_PROFILE_FIELD_TITLE"
},
"icon": "bank"
},
"status": "LIVE",
},
{
"uuid": "b72127e4-867a-4aba-a843-70c11dc599ef",
"title": {
"fr": "A really long name to test something"
},
"type": "inputText",
"properties": {
"editFeeds": [],
"availableValues": [
{}
],
"icon": "account"
},
"status": "LIVE",
}
],
"heritable": false,
"createdAt": "2018-04-12T07:43:23.624150",
"uid": ""
}
}
CUSTOMER_ID = 'XXX'
INSTANCE_ID = 'YYY'
api = ApiClient()
USER_DIRECTORY_ID = 'ZZZ'
USER_TO_UPDATE_EMAIL = 'me@customer.com'
userToUpdate = api.get_call('user', 'directory', 'get', email=USER_TO_UPDATE_EMAIL, contentId=USER_DIRECTORY_ID)
# To modify them, get the "uid" you want and proceed like so.
customProfileFieldToEdit1 = '1a3227d9-fa9b-4019-abf0-3525334e655f'
userToUpdate['customProfile'][customProfileFieldToEdit1] = '1990-08-15'
# To save a user in a user directory, you must add the user_directory ID in the user params.
userToUpdate['contentId'] = USER_DIRECTORY_ID
response = api.get_call('user', 'directory', 'save', body=userToUpdate)
print response['customProfile']