2016-01-12 22:23:01 +03:00
|
|
|
import RESTSerializer from 'ember-data/serializers/rest';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {decamelize} from '@ember/string';
|
|
|
|
import {pluralize} from 'ember-inflector';
|
2016-01-23 21:12:22 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
export default RESTSerializer.extend({
|
|
|
|
serializeIntoHash(hash, type, record, options) {
|
2014-05-09 09:00:10 +04:00
|
|
|
// Our API expects an id on the posted object
|
|
|
|
options = options || {};
|
|
|
|
options.includeId = true;
|
|
|
|
|
|
|
|
// We have a plural root in the API
|
2016-06-11 19:52:36 +03:00
|
|
|
let root = pluralize(type.modelName);
|
2015-10-28 14:36:45 +03:00
|
|
|
let data = this.serialize(record, options);
|
2014-05-09 09:00:10 +04:00
|
|
|
|
|
|
|
hash[root] = [data];
|
2016-01-23 21:12:22 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
keyForAttribute(attr) {
|
|
|
|
return decamelize(attr);
|
2014-05-09 09:00:10 +04:00
|
|
|
}
|
2014-06-09 15:02:51 +04:00
|
|
|
});
|