Closed monotasker closed 10 months ago
Current (projected) format for JSON responses is an object with keys for data to be updated:
{'id': 'my_commons_id',
'primary_email': 'myaddress@myserver.edu`,
'name': 'Jane Goodall',
'preferredUsername': 'Jane',
'groups': [
{'name': 'chimpanzees', 'type': 'topical', 'role': 'administrator'},
{'name': 'admin', 'type': 'administrative', 'role': 'administrator'},
{'name': 'msu', 'type': 'organization', 'role': 'curator'},
{'name': 'hcommons', 'type': 'commons', 'role': 'member'}
],
'institutional_affiliations': [
{'id': 'MSU'},
{'id': 'British Academy'}
],
'preferred_language': 'en',
'profile_visibility': 'true',
'email_visibility': 'false'
}
Response is stateless. Not changes, but the current state of user's data on Commons. (So 'groups' gives complete current list of groups.)
Endpoint is at https://hcommons-dev.org/wp-json/commons/v1/users/:username .
The API is using token authentication, so you need to set the authorization header to Bearer <token>
. Token is set in .env .
Response format:
{
"username": "<WordPress username>",
"email": "<registered email>",
"name": "<WordPress display name>",
"first_name": "<first name>",
"last_name": "<last name>",
"institutional_affiliation": "<affiliation---only one value is tracked>",
"groups": [
{
"id": <group_id (int)>,
"name": "<group display name>",
"role": "<member|moderator|admin>" (Note: We don't actually seem to use the moderator role, though it exists)
},
{
"id": 1002890,
"name": "MDPx",
"role": "member"
},
....
}
Notes:
We need to implement an API endpoint on the Commons that serves user data to Invenio.
Could be something like:
hcommons.org/api/members/
With a JSON response object.
This is assuming