2023-03-01 09:39:41 -06:00
|
|
|
/**
|
2026-01-28 17:09:06 -08:00
|
|
|
* Copyright IBM Corp. 2021, 2026
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
2020-09-01 10:42:16 -04:00
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
|
|
|
|
|
export default class GroupSerializer extends ApplicationSerializer {
|
|
|
|
|
// =methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If `adapterOptions.memberIDs` is set (to an array of user IDs),
|
|
|
|
|
* then the payload is serialized via `serializewithMembers`.
|
|
|
|
|
* @override
|
|
|
|
|
* @param {Snapshot} snapshot
|
|
|
|
|
* @return {object}
|
|
|
|
|
*/
|
|
|
|
|
serialize(snapshot) {
|
|
|
|
|
let serialized = super.serialize(...arguments);
|
|
|
|
|
const memberIDs = snapshot?.adapterOptions?.memberIDs;
|
|
|
|
|
if (memberIDs) serialized = this.serializewithMembers(snapshot, memberIDs);
|
|
|
|
|
return serialized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a payload containing only the `member_ids` array (and version).
|
|
|
|
|
* @param {Snapshot} snapshot
|
|
|
|
|
* @param {[string]} memberIDs
|
|
|
|
|
* @return {object}
|
|
|
|
|
*/
|
|
|
|
|
serializewithMembers(snapshot, memberIDs) {
|
|
|
|
|
return {
|
|
|
|
|
version: snapshot.attr('version'),
|
2020-09-16 14:29:02 -04:00
|
|
|
member_ids: memberIDs,
|
2020-09-01 10:42:16 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|