2016-05-24 15:06:59 +03:00
|
|
|
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
2020-01-16 20:01:12 +03:00
|
|
|
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {pluralize} from 'ember-inflector';
|
2016-06-11 19:52:36 +03:00
|
|
|
|
2022-02-02 21:35:18 +03:00
|
|
|
export default class UserSerializer extends ApplicationSerializer.extend(EmbeddedRecordsMixin) {
|
|
|
|
attrs = {
|
2016-06-14 11:11:59 +03:00
|
|
|
roles: {embedded: 'always'},
|
2017-04-05 22:20:45 +03:00
|
|
|
lastLoginUTC: {key: 'last_seen'},
|
2016-06-14 11:11:59 +03:00
|
|
|
createdAtUTC: {key: 'created_at'},
|
|
|
|
updatedAtUTC: {key: 'updated_at'}
|
2022-02-10 13:41:36 +03:00
|
|
|
};
|
2014-07-21 01:48:24 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
extractSingle(store, primaryType, payload) {
|
|
|
|
let root = this.keyForAttribute(primaryType.modelName);
|
2016-06-11 19:52:36 +03:00
|
|
|
let pluralizedRoot = pluralize(primaryType.modelName);
|
2014-07-21 01:48:24 +04:00
|
|
|
|
|
|
|
payload[root] = payload[pluralizedRoot][0];
|
|
|
|
delete payload[pluralizedRoot];
|
|
|
|
|
2022-02-02 21:35:18 +03:00
|
|
|
return super.extractSingle(...arguments);
|
|
|
|
}
|
|
|
|
}
|