2018-09-25 16:28:26 +00:00
|
|
|
import ApplicationSerializer from './application';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default ApplicationSerializer.extend({
|
2018-04-03 14:16:57 +00:00
|
|
|
extractLazyPaginatedData(payload) {
|
|
|
|
if (payload.zero_address_roles) {
|
2021-12-17 03:44:29 +00:00
|
|
|
payload.zero_address_roles.forEach((role) => {
|
2018-04-03 14:16:57 +00:00
|
|
|
// mutate key_info object to add zero_address info
|
|
|
|
payload.data.key_info[role].zero_address = true;
|
|
|
|
});
|
|
|
|
}
|
2018-11-19 21:48:24 +00:00
|
|
|
if (!payload.data.key_info) {
|
2021-12-17 03:44:29 +00:00
|
|
|
return payload.data.keys.map((key) => {
|
2022-11-09 23:15:31 +00:00
|
|
|
const model = {
|
2018-11-19 21:48:24 +00:00
|
|
|
id: key,
|
|
|
|
};
|
|
|
|
if (payload.backend) {
|
|
|
|
model.backend = payload.backend;
|
|
|
|
}
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-09 23:15:31 +00:00
|
|
|
const ret = payload.data.keys.map((key) => {
|
|
|
|
const model = {
|
2018-04-03 14:16:57 +00:00
|
|
|
id: key,
|
|
|
|
key_type: payload.data.key_info[key].key_type,
|
|
|
|
zero_address: payload.data.key_info[key].zero_address,
|
|
|
|
};
|
|
|
|
if (payload.backend) {
|
|
|
|
model.backend = payload.backend;
|
|
|
|
}
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
delete payload.data.key_info;
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
});
|